Commit 210a40b1 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

implement a first simple point location algorithm

parent df4700f2
......@@ -11,7 +11,6 @@ import java.util.List;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
public class Face implements Iterable<HalfEdge> {
/**
......@@ -19,12 +18,13 @@ public class Face implements Iterable<HalfEdge> {
*/
private HalfEdge edge;
public Face(final @NotNull HalfEdge edge) {
this.edge = edge;
}
public Face() {}
public void setEdge(@NotNull HalfEdge edge) {
}
public Face(final @NotNull HalfEdge edge) {
this.edge = edge;
}
......
......@@ -4,9 +4,8 @@ import org.jetbrains.annotations.NotNull;
import org.vadere.util.geometry.shapes.VLine;
import org.vadere.util.geometry.shapes.VPoint;
/**
* Created by bzoennchen on 13.11.16.
*/
import java.util.Optional;
public class HalfEdge {
/**
......@@ -35,7 +34,6 @@ public class HalfEdge {
*/
private Face face;
public HalfEdge (@NotNull final VPoint end, @NotNull final Face face) {
this.end = end;
this.face = face;
......@@ -61,13 +59,13 @@ public class HalfEdge {
return previous;
}
public HalfEdge getTwin() {
return twin;
public Optional<HalfEdge> getTwin() {
return Optional.ofNullable(twin);
}
public void setTwin(final @NotNull HalfEdge twin) {
this.twin = twin;
if(twin.getTwin() != this) {
if(!twin.getTwin().isPresent() || twin.getTwin().get() != this) {
twin.setTwin(this);
}
}
......
......@@ -126,7 +126,12 @@ public class PointLocation {
return Optional.of(edge.getFace());
}
else {
return Optional.empty();
}
if(edge.getTwin().isPresent()) {
return Optional.of(edge.getTwin().get().getFace());
}
else {
return Optional.empty();
}
}
}
}
......@@ -29,7 +29,6 @@ public class TestFace {
halfEdge3.setNext(halfEdge1);
face.setEdge(halfEdge1);
face = new Face(halfEdge1);
}
@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