ConformingDelaunayTriangulationBuilder cdtb = new ConformingDelaunayTriangulationBuilder(); cdtb.setSites(this.geometries); QuadEdgeSubdivision qes = cdtb.getSubdivision();
/** * Gets the QuadEdgeSubdivision which models the computed triangulation. * * @return the subdivision containing the triangulation */ public QuadEdgeSubdivision getSubdivision() { create(); return subdiv; }
private void create() { if (subdiv != null) return; Envelope siteEnv = DelaunayTriangulationBuilder.envelope(siteCoords); List segments = new ArrayList(); if (constraintLines != null) { siteEnv.expandToInclude(constraintLines.getEnvelopeInternal()); createVertices(constraintLines); segments = createConstraintSegments(constraintLines); } List sites = createSiteVertices(siteCoords); ConformingDelaunayTriangulator cdt = new ConformingDelaunayTriangulator(sites, tolerance); cdt.setConstraints(segments, new ArrayList(constraintVertexMap.values())); cdt.formInitialDelaunay(); cdt.enforceConstraints(); subdiv = cdt.getSubdivision(); }
ConformingDelaunayTriangulationBuilder conformingDelaunayTriangulationBuilder = new ConformingDelaunayTriangulationBuilder(); conformingDelaunayTriangulationBuilder.setTolerance(10.0e-3); conformingDelaunayTriangulationBuilder.setSites(sites); QuadEdgeSubdivision subdivision; try conformingDelaunayTriangulationBuilder.setConstraints(constraintSegments); subdivision = conformingDelaunayTriangulationBuilder.getSubdivision(); conformingDelaunayTriangulationBuilder.setConstraints(null); subdivision = conformingDelaunayTriangulationBuilder.getSubdivision();
/** * Triangulate this {@link Polygon}, using the JTS library. * * @return All the triangles that form this {@link Polygon}. */ public List<Polygon> triangles() { final ConformingDelaunayTriangulationBuilder trianguler = new ConformingDelaunayTriangulationBuilder(); // Populate the delaunay triangulation builder trianguler.setSites(JTS_POLYGON_CONVERTER.convert(this)); final GeometryCollection triangleCollection = (GeometryCollection) trianguler .getTriangles(JtsPrecisionManager.getGeometryFactory()); // Get the output and convert back to Core Polygons, filter out the extraneous polygons from // the Delaunay triangulation. return Iterables.stream(GeometryStreamer.streamPolygons(triangleCollection)) .map(JTS_POLYGON_CONVERTER.revert()) .filter(polygon -> fullyGeometricallyEncloses(polygon.center())).collectToList(); }
private static List createConstraintSegments(Geometry geom) { List lines = LinearComponentExtracter.getLines(geom); List constraintSegs = new ArrayList(); for (Iterator i = lines.iterator(); i.hasNext(); ) { LineString line = (LineString) i.next(); createConstraintSegments(line, constraintSegs); } return constraintSegs; }
private static List createConstraintSegments(Geometry geom) { List lines = LinearComponentExtracter.getLines(geom); List constraintSegs = new ArrayList(); for (Iterator i = lines.iterator(); i.hasNext(); ) { LineString line = (LineString) i.next(); createConstraintSegments(line, constraintSegs); } return constraintSegs; }
private static QuadEdgeSubdivision createQuadEdgeSubdivision(PlanarRegionSegmentationRawData rawData) { List<Point2D> point2ds = rawData.getPointCloudInPlane(); MultiPoint multiPoint = SimpleConcaveHullFactory.createMultiPoint(point2ds); ConformingDelaunayTriangulationBuilder conformingDelaunayTriangulationBuilder = new ConformingDelaunayTriangulationBuilder(); conformingDelaunayTriangulationBuilder.setSites(multiPoint); return conformingDelaunayTriangulationBuilder.getSubdivision(); }
private void create() { if (subdiv != null) return; Envelope siteEnv = DelaunayTriangulationBuilder.envelope(siteCoords); List segments = new ArrayList(); if (constraintLines != null) { siteEnv.expandToInclude(constraintLines.getEnvelopeInternal()); createVertices(constraintLines); segments = createConstraintSegments(constraintLines); } List sites = createSiteVertices(siteCoords); ConformingDelaunayTriangulator cdt = new ConformingDelaunayTriangulator(sites, tolerance); cdt.setConstraints(segments, new ArrayList(constraintVertexMap.values())); cdt.formInitialDelaunay(); cdt.enforceConstraints(); subdiv = cdt.getSubdivision(); }
/** * Gets the faces of the computed triangulation as a {@link GeometryCollection} * of {@link Polygon}. * * @param geomFact the geometry factory to use to create the output * @return the faces of the triangulation */ public Geometry getTriangles(GeometryFactory geomFact) { create(); return subdiv.getTriangles(geomFact); }
/** * Gets the edges of the computed triangulation as a {@link MultiLineString}. * * @param geomFact the geometry factory to use to create the output * @return the edges of the triangulation */ public Geometry getEdges(GeometryFactory geomFact) { create(); return subdiv.getEdges(geomFact); }
/** * Gets the QuadEdgeSubdivision which models the computed triangulation. * * @return the subdivision containing the triangulation */ public QuadEdgeSubdivision getSubdivision() { create(); return subdiv; }
/** * Gets the edges of the computed triangulation as a {@link MultiLineString}. * * @param geomFact the geometry factory to use to create the output * @return the edges of the triangulation */ public Geometry getEdges(GeometryFactory geomFact) { create(); return subdiv.getEdges(geomFact); }
/** * Gets the faces of the computed triangulation as a {@link GeometryCollection} * of {@link Polygon}. * * @param geomFact the geometry factory to use to create the output * @return the faces of the triangulation */ public Geometry getTriangles(GeometryFactory geomFact) { create(); return subdiv.getTriangles(geomFact); }