private ConstraintVertex createVertex(Coordinate p) { ConstraintVertex v = null; if (vertexFactory != null) v = vertexFactory.createVertex(p, null); else v = new ConstraintVertex(p); return v; }
/** * Inserts a site into the triangulation, maintaining the conformal Delaunay property. * This can be used to further refine the triangulation if required * (e.g. to approximate the medial axis of the constraints, * or to improve the grading of the triangulation). * * @param p the location of the site to insert */ public void insertSite(Coordinate p) { insertSite(createVertex(p)); }
/** * Sets the sites (vertices) which will be triangulated. * All vertices of the given geometry will be used as sites. * * @param geom the geometry from which the sites will be extracted. */ public void setSites(Geometry geom) { // remove any duplicate points (they will cause the triangulation to fail) siteCoords = extractUniqueCoordinates(geom); }
ConformingDelaunayTriangulationBuilder cdtb = new ConformingDelaunayTriangulationBuilder(); cdtb.setSites(this.geometries); QuadEdgeSubdivision qes = cdtb.getSubdivision(); Collection<QuadEdge> quadEdges = qes.getEdges(); List<QuadEdgeTriangle> qeTriangles = QuadEdgeTriangle.createOn(qes); Collection<com.vividsolutions.jts.triangulate.quadedge.Vertex> qeVertices = qes.getVertices(false); this.coordinates.put(v.getCoordinate(), iV); this.vertices.put(iV, new Vertex(iV, v.getCoordinate())); iV++; if (qes.isFrameBorderEdge(qe)) { qeFrameBorder.add(qe); if (qes.isFrameEdge(qe)) { qeFrame.add(qe); qes.delete(qe); qeDistances.put(qe, qe.toLineSegment().getLength()); LineSegment s = qe.toLineSegment(); s.normalize(); LineSegment sA = qet.getEdge(0).toLineSegment();
/** * Computes the Delaunay triangulation of the initial sites. */ public void formInitialDelaunay() { computeBoundingBox(); subdiv = new QuadEdgeSubdivision(computeAreaEnv, tolerance); subdiv.setLocator(new LastFoundQuadEdgeLocator(subdiv)); incDel = new IncrementalDelaunayTriangulator(subdiv); insertSites(initialVertices); }
private void create() { if (subdiv != null) return; Envelope siteEnv = envelope(siteCoords); List vertices = toVertices(siteCoords); subdiv = new QuadEdgeSubdivision(siteEnv, tolerance); IncrementalDelaunayTriangulator triangulator = new IncrementalDelaunayTriangulator(subdiv); triangulator.insertSites(vertices); }
/** * Creates a vertex on a constraint segment * * @param p the location of the vertex to create * @param seg the constraint segment it lies on * @return the new constraint vertex */ private ConstraintVertex createVertex(Coordinate p, Segment seg) { ConstraintVertex v = null; if (vertexFactory != null) v = vertexFactory.createVertex(p, seg); else v = new ConstraintVertex(p); v.setOnConstraint(true); return v; }
private void addConstraintVertices() { computeConvexHull(); // insert constraint vertices as sites insertSites(segVertices); }
/** * 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); }
/** * Computes the intersection point between this segment and another one. * * @param s a segment * @return the intersection point, or <code>null</code> if there is none */ public Coordinate intersection(Segment s) { return ls.intersection(s.getLineSegment()); }
/** * Gets the QuadEdgeSubdivision which models the computed triangulation. * * @return the subdivision containing the triangulation */ public QuadEdgeSubdivision getSubdivision() { create(); return subdiv; }
/** * Gets the {@link QuadEdgeSubdivision} which models the computed triangulation. * * @return the subdivision containing the triangulation */ public QuadEdgeSubdivision getSubdivision() { create(); return subdiv; }
/** * Gets the {@link QuadEdgeSubdivision} which models the computed diagram. * * @return the subdivision containing the triangulation */ public QuadEdgeSubdivision getSubdivision() { create(); return subdiv; }
/** * Creates a new instance with a given message and approximate location. * * @param msg a string * @param pt the location of the error */ public ConstraintEnforcementException(String msg, Coordinate pt) { super(msgWithCoord(msg, pt)); this.pt = new Coordinate(pt); }
/** * Sets the sites (vertices) which will be triangulated * from a collection of {@link Coordinate}s. * * @param coords a collection of Coordinates. */ public void setSites(Collection coords) { // remove any duplicate points (they will cause the triangulation to fail) siteCoords = unique(CoordinateArrays.toCoordinateArray(coords)); }
/** * Sets the sites (point or vertices) which will be diagrammed. * All vertices of the given geometry will be used as sites. * * @param geom the geometry from which the sites will be extracted. */ public void setSites(Geometry geom) { // remove any duplicate points (they will cause the triangulation to fail) siteCoords = DelaunayTriangulationBuilder.extractUniqueCoordinates(geom); }
/** * Determines whether two segments are topologically equal. * I.e. equal up to orientation. * * @param s a segment * @return true if the segments are topologically equal */ public boolean equalsTopo(Segment s) { return ls.equalsTopo(s.getLineSegment()); }
/** * Sets the sites (point or vertices) which will be triangulated. * All vertices of the given geometry will be used as sites. * The site vertices do not have to contain the constraint * vertices as well; any site vertices which are * identical to a constraint vertex will be removed * from the site vertex set. * * @param geom the geometry from which the sites will be extracted. */ public void setSites(Geometry geom) { siteCoords = DelaunayTriangulationBuilder.extractUniqueCoordinates(geom); }