SimplePolygonXZ polygon,
Collection<SimplePolygonXZ> holes,
Collection<LineSegmentXZ> segments,
Collection<VectorXZ> points) {
ConformingDelaunayTriangulationBuilder triangulationBuilder =
new ConformingDelaunayTriangulationBuilder();
List<Geometry> constraints =
new ArrayList<Geometry>(1 + holes.size() + segments.size());
constraints.add(polygonXZToJTSPolygon(polygon));
for (SimplePolygonXZ hole : holes) {
constraints.add(polygonXZToJTSPolygon(hole));
}
for (LineSegmentXZ segment : segments) {
constraints.add(lineSegmentXZToJTSLineString(segment));
}
ArrayList<Point> jtsPoints = new ArrayList<Point>();
for (VectorXZ p : points) {
CoordinateSequence coordinateSequence =
new CoordinateArraySequence(new Coordinate[] {
vectorXZToJTSCoordinate(p)});
jtsPoints.add(new Point(coordinateSequence, GF));
}
triangulationBuilder.setSites(
new GeometryCollection(jtsPoints.toArray(EMPTY_GEOM_ARRAY), GF));
triangulationBuilder.setConstraints(
new GeometryCollection(constraints.toArray(EMPTY_GEOM_ARRAY), GF));
triangulationBuilder.setTolerance(0.01);
/* run triangulation */
Geometry triangulationResult = triangulationBuilder.getTriangles(GF);
/* interpret the resulting polygons as triangles,
* filter out those which are outside the polygon or in a hole */
Collection<PolygonWithHolesXZ> trianglesAsPolygons =