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;
import org.apache.commons.lang3.tuple.ImmutableTriple;
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.VLine;
import org.vadere.util.geometry.shapes.VPoint;
......
......@@ -11,6 +11,7 @@ import java.util.List;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
public class Face implements Iterable<HalfEdge> {
/**
......@@ -18,13 +19,12 @@ public class Face implements Iterable<HalfEdge> {
*/
private HalfEdge edge;
public Face(final HalfEdge edge) {
this.edge = edge;
}
public Face() {}
public void setEdge(@NotNull HalfEdge edge) {
}
public Face(final @NotNull HalfEdge edge) {
this.edge = edge;
}
......
......@@ -4,8 +4,9 @@ import org.jetbrains.annotations.NotNull;
import org.vadere.util.geometry.shapes.VLine;
import org.vadere.util.geometry.shapes.VPoint;
import java.util.Optional;
/**
* Created by bzoennchen on 13.11.16.
*/
public class HalfEdge {
/**
......@@ -35,7 +36,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 +61,13 @@ public class HalfEdge {
return previous;
}
public Optional<HalfEdge> getTwin() {
return Optional.ofNullable(twin);
public HalfEdge getTwin() {
return twin;
}
public void setTwin(final @NotNull HalfEdge twin) {
this.twin = twin;
if(!twin.getTwin().isPresent() || twin.getTwin().get() != this) {
if(twin.getTwin() != this) {
twin.setTwin(this);
}
}
......
......@@ -125,13 +125,8 @@ public class PointLocation {
if(edge.getFace().contains(point)) {
return Optional.of(edge.getFace());
}
else {
if(edge.getTwin().isPresent()) {
return Optional.of(edge.getTwin().get().getFace());
}
else {
return Optional.empty();
}
}
}
}
......@@ -24,12 +24,12 @@ public class TestFace {
HalfEdge halfEdge1 = new HalfEdge(new VPoint(0,0), face);
HalfEdge halfEdge2 = new HalfEdge(new VPoint(3,0), face);
HalfEdge halfEdge3 = new HalfEdge(new VPoint(1.5,3.0), face);
halfEdge1.setNext(halfEdge2);
halfEdge2.setNext(halfEdge3);
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