Commit df4700f2 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

construction of a new half-edge datastructure to solve the point location problem

parent 29283d40
...@@ -2,6 +2,7 @@ package org.vadere.util.delaunay; ...@@ -2,6 +2,7 @@ package org.vadere.util.delaunay;
import org.apache.commons.lang3.tuple.ImmutableTriple; import org.apache.commons.lang3.tuple.ImmutableTriple;
import org.apache.commons.lang3.tuple.Triple; import org.apache.commons.lang3.tuple.Triple;
import org.vadere.util.geometry.LinkedCellsGrid;
import org.vadere.util.geometry.shapes.VCircle; import org.vadere.util.geometry.shapes.VCircle;
import org.vadere.util.geometry.shapes.VLine; import org.vadere.util.geometry.shapes.VLine;
import org.vadere.util.geometry.shapes.VPoint; import org.vadere.util.geometry.shapes.VPoint;
......
...@@ -11,6 +11,7 @@ import java.util.List; ...@@ -11,6 +11,7 @@ import java.util.List;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.stream.StreamSupport; import java.util.stream.StreamSupport;
public class Face implements Iterable<HalfEdge> { public class Face implements Iterable<HalfEdge> {
/** /**
...@@ -18,13 +19,12 @@ public class Face implements Iterable<HalfEdge> { ...@@ -18,13 +19,12 @@ public class Face implements Iterable<HalfEdge> {
*/ */
private HalfEdge edge; private HalfEdge edge;
public Face(final HalfEdge edge) {
this.edge = edge;
}
public Face() {} public Face() {}
public void setEdge(@NotNull HalfEdge edge) { public void setEdge(@NotNull HalfEdge edge) {
}
public Face(final @NotNull HalfEdge edge) {
this.edge = edge; this.edge = edge;
} }
......
...@@ -4,8 +4,9 @@ import org.jetbrains.annotations.NotNull; ...@@ -4,8 +4,9 @@ import org.jetbrains.annotations.NotNull;
import org.vadere.util.geometry.shapes.VLine; import org.vadere.util.geometry.shapes.VLine;
import org.vadere.util.geometry.shapes.VPoint; import org.vadere.util.geometry.shapes.VPoint;
import java.util.Optional; /**
* Created by bzoennchen on 13.11.16.
*/
public class HalfEdge { public class HalfEdge {
/** /**
...@@ -35,7 +36,6 @@ public class HalfEdge { ...@@ -35,7 +36,6 @@ public class HalfEdge {
private Face face; private Face face;
public HalfEdge (@NotNull final VPoint end, @NotNull final Face face) { public HalfEdge (@NotNull final VPoint end, @NotNull final Face face) {
this.end = end; this.end = end;
this.face = face; this.face = face;
...@@ -61,13 +61,13 @@ public class HalfEdge { ...@@ -61,13 +61,13 @@ public class HalfEdge {
return previous; return previous;
} }
public Optional<HalfEdge> getTwin() { public HalfEdge getTwin() {
return Optional.ofNullable(twin); return twin;
} }
public void setTwin(final @NotNull HalfEdge twin) { public void setTwin(final @NotNull HalfEdge twin) {
this.twin = twin; this.twin = twin;
if(!twin.getTwin().isPresent() || twin.getTwin().get() != this) { if(twin.getTwin() != this) {
twin.setTwin(this); twin.setTwin(this);
} }
} }
......
...@@ -126,12 +126,7 @@ public class PointLocation { ...@@ -126,12 +126,7 @@ public class PointLocation {
return Optional.of(edge.getFace()); return Optional.of(edge.getFace());
} }
else { else {
if(edge.getTwin().isPresent()) { return Optional.empty();
return Optional.of(edge.getTwin().get().getFace());
}
else {
return Optional.empty();
}
} }
} }
} }
...@@ -24,12 +24,12 @@ public class TestFace { ...@@ -24,12 +24,12 @@ public class TestFace {
HalfEdge halfEdge1 = new HalfEdge(new VPoint(0,0), face); HalfEdge halfEdge1 = new HalfEdge(new VPoint(0,0), face);
HalfEdge halfEdge2 = new HalfEdge(new VPoint(3,0), face); HalfEdge halfEdge2 = new HalfEdge(new VPoint(3,0), face);
HalfEdge halfEdge3 = new HalfEdge(new VPoint(1.5,3.0), face); HalfEdge halfEdge3 = new HalfEdge(new VPoint(1.5,3.0), face);
halfEdge1.setNext(halfEdge2); halfEdge1.setNext(halfEdge2);
halfEdge2.setNext(halfEdge3); halfEdge2.setNext(halfEdge3);
halfEdge3.setNext(halfEdge1); halfEdge3.setNext(halfEdge1);
face.setEdge(halfEdge1); face.setEdge(halfEdge1);
face = new Face(halfEdge1);
} }
@Test @Test
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment