dcel klasse mit zugriffsmethoden hinzugefügt
This commit is contained in:
parent
f5e0322f70
commit
9b986b74f2
|
@ -11,51 +11,34 @@ import java.util.LinkedList;
|
|||
*/
|
||||
public class Arrangement {
|
||||
|
||||
private LinkedList<Model.Coordinates> nodes;
|
||||
private LinkedList<Model.Coordinates> lines;
|
||||
private LinkedList<Coordinates> nodes;
|
||||
private LinkedList<Coordinates> lines;
|
||||
|
||||
public Arrangement(){
|
||||
nodes = new LinkedList<>();
|
||||
lines = new LinkedList<>();
|
||||
}
|
||||
|
||||
public void addNode(Model.Coordinates node){
|
||||
public void addNode(Coordinates node){
|
||||
this.nodes.add(node);
|
||||
}
|
||||
|
||||
public void removeNode(int index){
|
||||
this.nodes.remove(index);
|
||||
}
|
||||
|
||||
public void removeNode(Model.Coordinates node){
|
||||
this.nodes.remove(node);
|
||||
}
|
||||
|
||||
public void addLine(Model.Coordinates line){
|
||||
public void addLine(Coordinates line){
|
||||
this.lines.add(line);
|
||||
}
|
||||
|
||||
public void removeLine(int index){
|
||||
this.lines.remove(index);
|
||||
}
|
||||
|
||||
public void removeLine(Model.Coordinates line){
|
||||
this.lines.remove(line);
|
||||
}
|
||||
|
||||
public LinkedList<Model.Coordinates> getNodes() {
|
||||
public LinkedList<Coordinates> getNodes() {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
public void setNodes(LinkedList<Model.Coordinates> nodes) {
|
||||
this.nodes = nodes;
|
||||
}
|
||||
|
||||
public LinkedList<Model.Coordinates> getLines() {
|
||||
public LinkedList<Coordinates> getLines() {
|
||||
return lines;
|
||||
}
|
||||
|
||||
public void setLines(LinkedList<Model.Coordinates> lines) {
|
||||
public void setLines(LinkedList<Coordinates> lines) {
|
||||
this.lines = lines;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
package Model;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
||||
*
|
||||
* @Author: Armin Wolf
|
||||
* @Email: a_wolf28@uni-muenster.de
|
||||
* @Date: 30.05.2017.
|
||||
*/
|
||||
public class DoublyConnectedEdgeList {
|
||||
|
||||
private LinkedList<Node> nodes;
|
||||
private LinkedList<Edge> edges;
|
||||
private LinkedList<Face> faces;
|
||||
|
||||
public DoublyConnectedEdgeList(){
|
||||
this.nodes = new LinkedList<>();
|
||||
this.edges = new LinkedList<>();
|
||||
this.faces = new LinkedList<>();
|
||||
}
|
||||
|
||||
public Node createNode(Coordinates point, String id){
|
||||
|
||||
Node node = new Node();
|
||||
node.setCoordinates(point);
|
||||
node.setID(id);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
public Edge createEdge(Node source, Node destination, String id){
|
||||
|
||||
Edge edge = new Edge();
|
||||
Edge twin = new Edge();
|
||||
|
||||
edge.setOrigin(source);
|
||||
edge.setID(id);
|
||||
twin.setOrigin(destination);
|
||||
twin.setID("#"+id);
|
||||
|
||||
source.setIncidentEdge(edge);
|
||||
destination.setIncidentEdge(twin);
|
||||
|
||||
return edge;
|
||||
}
|
||||
|
||||
public Face createFace(Edge outerComponent, Edge innerComponent, String id){
|
||||
|
||||
Face face = new Face();
|
||||
face.setOuterComponent(outerComponent);
|
||||
face.setID(id);
|
||||
Edge tempEdge;
|
||||
|
||||
if (!outerComponent.equals(null)){
|
||||
tempEdge = outerComponent;
|
||||
do {
|
||||
tempEdge.setIncidentFace(face);
|
||||
tempEdge = tempEdge.getNext();
|
||||
} while (!tempEdge.equals(outerComponent));
|
||||
}
|
||||
|
||||
if (!innerComponent.equals(null)){
|
||||
LinkedList<Edge> componentlist = face.getInnerComponents();
|
||||
componentlist.add(innerComponent);
|
||||
tempEdge = innerComponent;
|
||||
do {
|
||||
tempEdge.setIncidentFace(face);
|
||||
tempEdge = tempEdge.getNext();
|
||||
} while (!tempEdge.equals(innerComponent));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void createConnection(Edge edge, Edge pred){
|
||||
edge.setPrev(pred);
|
||||
pred.setNext(edge);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -14,6 +14,7 @@ public class Edge {
|
|||
private Face incidentFace;
|
||||
private Edge next;
|
||||
private Edge prev;
|
||||
private String id;
|
||||
|
||||
public Edge(){
|
||||
new Edge(null, null, null, null, null);
|
||||
|
@ -86,7 +87,7 @@ public class Edge {
|
|||
edge.setPrev(this);
|
||||
edge.setTwin(twin);
|
||||
edge.setIncidentFace(this.getIncidentFace());
|
||||
|
||||
|
||||
twin.setOrigin(this.getTwin().getOrigin());
|
||||
twin.setPrev(this.getTwin().getPrev());
|
||||
twin.setNext(this.getTwin());
|
||||
|
@ -105,4 +106,12 @@ public class Edge {
|
|||
|
||||
return edge;
|
||||
}
|
||||
|
||||
public String getID(){
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setID(String id){
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,11 @@ public class Face {
|
|||
|
||||
private LinkedList<Edge> innerComponents;
|
||||
private Edge outerComponent;
|
||||
private String id;
|
||||
|
||||
public Face(){
|
||||
new Face(null, null);
|
||||
}
|
||||
|
||||
public Face(Edge outerComponent, LinkedList<Edge> innerComponents){
|
||||
this.outerComponent = outerComponent;
|
||||
|
@ -101,4 +106,12 @@ public class Face {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public String getID(){
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setID(String id){
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ public class Node {
|
|||
|
||||
private Coordinates coordinates;
|
||||
private Edge incidentEdge;
|
||||
private String id;
|
||||
|
||||
public Node(){
|
||||
new Node(null, null);
|
||||
|
@ -21,7 +22,6 @@ public class Node {
|
|||
this.incidentEdge = incidentEdge;
|
||||
}
|
||||
|
||||
|
||||
public Coordinates getCoordinates() {
|
||||
return coordinates;
|
||||
}
|
||||
|
@ -37,4 +37,12 @@ public class Node {
|
|||
public void setIncidentEdge(Edge incidentEdge) {
|
||||
this.incidentEdge = incidentEdge;
|
||||
}
|
||||
|
||||
public String getID(){
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setID(String id){
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue