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(); }
/** * Enforces the supplied constraints into the triangulation. * * @throws ConstraintEnforcementException * if the constraints cannot be enforced */ public void enforceConstraints() { addConstraintVertices(); // if (true) return; int count = 0; int splits = 0; do { splits = enforceGabriel(segments); count++; Debug.println("Iter: " + count + " Splits: " + splits + " Current # segments = " + segments.size()); } while (splits > 0 && count < MAX_SPLIT_ITER); if (count == MAX_SPLIT_ITER) { Debug.println("ABORTED! Too many iterations while enforcing constraints"); if (!Debug.isDebugging()) throw new ConstraintEnforcementException( "Too many splitting iterations while enforcing constraints. Last split point was at: ", splitPt); } }
/** * 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 addConstraintVertices() { computeConvexHull(); // insert constraint vertices as sites insertSites(segVertices); }
/** * 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)); }
Coordinate encroachPt = findNonGabrielPoint(seg); ConstraintVertex splitVertex = createVertex(splitPt, seg); ConstraintVertex insertedVertex = insertSite(splitVertex); if (!insertedVertex.getCoordinate().equals2D(splitPt)) { Debug.println("Split pt snapped to: " + insertedVertex);
private void computeBoundingBox() { Envelope vertexEnv = computeVertexEnvelope(initialVertices); Envelope segEnv = computeVertexEnvelope(segVertices); Envelope allPointsEnv = new Envelope(vertexEnv); allPointsEnv.expandToInclude(segEnv); double deltaX = allPointsEnv.getWidth() * 0.2; double deltaY = allPointsEnv.getHeight() * 0.2; double delta = Math.max(deltaX, deltaY); computeAreaEnv = new Envelope(allPointsEnv); computeAreaEnv.expandBy(delta); }
Coordinate encroachPt = findNonGabrielPoint(seg); ConstraintVertex splitVertex = createVertex(splitPt, seg); ConstraintVertex insertedVertex = insertSite(splitVertex); if (!insertedVertex.getCoordinate().equals2D(splitPt)) { Debug.println("Split pt snapped to: " + insertedVertex);
private void addConstraintVertices() { computeConvexHull(); // insert constraint vertices as sites insertSites(segVertices); }
/** * 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)); }
private void computeBoundingBox() { Envelope vertexEnv = computeVertexEnvelope(initialVertices); Envelope segEnv = computeVertexEnvelope(segVertices); Envelope allPointsEnv = new Envelope(vertexEnv); allPointsEnv.expandToInclude(segEnv); double deltaX = allPointsEnv.getWidth() * 0.2; double deltaY = allPointsEnv.getHeight() * 0.2; double delta = Math.max(deltaX, deltaY); computeAreaEnv = new Envelope(allPointsEnv); computeAreaEnv.expandBy(delta); }
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(); }
/** * 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); }
/** * Enforces the supplied constraints into the triangulation. * * @throws ConstraintEnforcementException * if the constraints cannot be enforced */ public void enforceConstraints() { addConstraintVertices(); // if (true) return; int count = 0; int splits = 0; do { splits = enforceGabriel(segments); count++; Debug.println("Iter: " + count + " Splits: " + splits + " Current # segments = " + segments.size()); } while (splits > 0 && count < MAX_SPLIT_ITER); if (count == MAX_SPLIT_ITER) { Debug.println("ABORTED! Too many iterations while enforcing constraints"); if (!Debug.isDebugging()) throw new ConstraintEnforcementException( "Too many splitting iterations while enforcing constraints. Last split point was at: ", splitPt); } }