The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 968f0b8d authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

simplify the splitEdge and splitTriangle operation and add a face iterator to...

simplify the splitEdge and splitTriangle operation and add a face iterator to the delaunay-triangulation
parent 897bde6e
......@@ -64,6 +64,8 @@ public class Face<P extends IPoint> implements Iterable<HalfEdge<P>> {
private boolean border;
private boolean destroyed = false;
/**
* Default constructor. To construct a face where you have already some half-edges
* bordering this face.
......@@ -95,12 +97,17 @@ public class Face<P extends IPoint> implements Iterable<HalfEdge<P>> {
return border;
}
public void destroy() {
setEdge(null);
destroyed = true;
}
/**
* Sets one of the half-edges bordering this face.
*
* @param edge half-edge bordering this face
*/
public void setEdge(@NotNull HalfEdge<P> edge) {
public void setEdge(final HalfEdge<P> edge) {
this.edge = edge;
}
......@@ -108,6 +115,10 @@ public class Face<P extends IPoint> implements Iterable<HalfEdge<P>> {
return edge;
}
public boolean isDestroyed() {
return destroyed;
}
/**
* Computes the area of this face.
*
......
......@@ -5,12 +5,12 @@ import org.vadere.util.geometry.shapes.IPoint;
import java.util.Set;
import java.util.stream.Stream;
public interface Triangulation<P extends IPoint> {
public interface Triangulation<P extends IPoint> extends Iterable<Face<P>> {
void compute();
Face<P> locate(final double x, final double y);
Face<P> locate(final IPoint point);
Stream<Face<P>> streamFaces();
Set<Face<P>> getFaces();
HalfEdge<P> insert(final P point);
void insert(final P point);
void remove(final P point);
}
......@@ -32,8 +32,8 @@ public class UniformTriangulation<P extends IPoint> extends DelaunayTriangulatio
this.minTriangleSideLength = minTriangleSideLength;
this.pointConstructor = pointConstructor;
List<P> pointList = new ArrayList<P>(generatePointSet());
Collections.shuffle(pointList);
List<P> pointList = new ArrayList<>(generatePointSet());
//Collections.shuffle(pointList);
for(P point : pointList) {
insert(point);
}
......
......@@ -14,6 +14,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
......@@ -39,11 +40,45 @@ public class TestBoyerWatson {
points.add(p3);
points.add(p4);
points.add(p6);
points.add(p5);
DelaunayTriangulation<VPoint> boyerWatsonImproved = new DelaunayTriangulation<>(points, (x, y) -> new VPoint(x, y));
boyerWatsonImproved.compute();
Collection<VTriangle> triangulation = boyerWatsonImproved.getTriangles();
triangulation.forEach(System.out::print);
boyerWatsonImproved.finalize();
Set<VTriangle> triangulation = new HashSet<>(boyerWatsonImproved.getTriangles());
Set<VPoint> triangle1 = new HashSet<>();
triangle1.add(p1);
triangle1.add(p5);
triangle1.add(p4);
Set<VPoint> triangle2 = new HashSet<>();
triangle2.add(p1);
triangle2.add(p2);
triangle2.add(p5);
Set<VPoint> triangle3 = new HashSet<>();
triangle3.add(p2);
triangle3.add(p3);
triangle3.add(p5);
Set<VPoint> triangle4 = new HashSet<>();
triangle4.add(p4);
triangle4.add(p5);
triangle4.add(p3);
Set<Set<VPoint>> pointSets = triangulation.stream().map(t -> new HashSet<>(t.getPoints())).collect(Collectors.toSet());
Set<Set<VPoint>> expextedPointSets = new HashSet<>();
expextedPointSets.add(triangle1);
expextedPointSets.add(triangle2);
expextedPointSets.add(triangle3);
expextedPointSets.add(triangle4);
assertTrue(expextedPointSets.equals(pointSets));
triangulation.forEach(System.out::println);
}
@Test
......@@ -61,12 +96,13 @@ public class TestBoyerWatson {
Face<VPoint> face = Face.of(p1,p2,p3);
DAG<DAGElement<VPoint>> dag = new DAG<>(new DAGElement<>(face, Triple.of(p1,p2,p3)));
DelaunayTriangulation<VPoint> boyerWatsonImproved = new DelaunayTriangulation<>(points, (x, y) -> new VPoint(x, y));
HalfEdge<VPoint> result = boyerWatsonImproved.split(centerPoint, dag);
DelaunayTriangulation<VPoint> triangulation = new DelaunayTriangulation<>(points, (x, y) -> new VPoint(x, y));
triangulation.splitTriangleDB(centerPoint, dag);
triangulation.finalize();
Set<VTriangle> triangulation = new HashSet<>(result.collectLeafs().stream().map(dagElement -> dagElement.getTriangle()).collect(Collectors.toList()));
Set<VTriangle> triangles = new HashSet<>(triangulation.getTriangles());
Set<VTriangle> expectedResult = new HashSet<>(Arrays.asList(new VTriangle(p1, p2, centerPoint), new VTriangle(p2, p3, centerPoint), new VTriangle(p1, p3, centerPoint)));
assertTrue(testTriangulationEquality(triangulation, expectedResult));
assertTrue(testTriangulationEquality(triangles, expectedResult));
}
@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