QuadEdge edge = (QuadEdge) edgeStack.pop(); if (! visitedEdges.contains(edge)) { QuadEdge priQE = edge.getPrimary(); edgeStack.push(edge.oNext()); edgeStack.push(edge.sym().oNext()); visitedEdges.add(edge.sym());
e = e.oPrev(); subdiv.delete(e.oNext()); QuadEdge base = subdiv.makeEdge(e.orig(), v); QuadEdge.splice(base, e); QuadEdge startEdge = base; do { base = subdiv.connect(e, base.sym()); e = base.oPrev(); } while (e.lNext() != startEdge); QuadEdge t = e.oPrev(); if (t.dest().rightOf(e) && v.isInCircle(e.orig(), t.dest(), e.dest())) { QuadEdge.swap(e); e = e.oPrev(); } else if (e.oNext() == startEdge) { return base; // no more suspect edges. } else { e = e.oNext().lPrev();
QuadEdge e = locate(v); if ((v.equals(e.orig(), tolerance)) || (v.equals(e.dest(), tolerance))) { return e; // point already in subdivision. QuadEdge base = makeEdge(e.orig(), v); QuadEdge.splice(base, e); QuadEdge startEdge = base; do { base = connect(e, base.sym()); e = base.oPrev(); } while (e.lNext() != startEdge);
/** * Creates a new QuadEdge connecting the destination of a to the origin of * b, in such a way that all three have the same left face after the * connection is complete. Additionally, the data pointers of the new edge * are set. * * @return the connected edge. */ public static QuadEdge connect(QuadEdge a, QuadEdge b) { QuadEdge e = makeEdge(a.dest(), b.orig()); splice(e, a.lNext()); splice(e.sym(), b); return e; }
continue; processed.add(e); int cut = cut(e.orig().getZ(), e.dest().getZ(), z0); if (cut == 0) { continue; // While, next edge if (triangulation.isFrameVertex(e.orig())) { cC = moveEpsilonTowards(e.dest().getCoordinate(), e.orig().getCoordinate()); } else if (triangulation.isFrameVertex(e.dest())) { cC = moveEpsilonTowards(e.orig().getCoordinate(), e.dest().getCoordinate()); } else { cC = e.orig().midPoint(e.dest()).getCoordinate(); QuadEdge E1 = ccw ? e.oNext().getPrimary() : e.oPrev().getPrimary(); QuadEdge E2 = ccw ? e.dPrev().getPrimary() : e.dNext().getPrimary(); int cut1 = E1 == null ? 0 : cut(E1.orig().getZ(), E1.dest().getZ(), z0); int cut2 = E2 == null ? 0 : cut(E2.orig().getZ(), E2.dest().getZ(), z0); boolean ok1 = cut1 != 0 && !processed.contains(E1); boolean ok2 = cut2 != 0 && !processed.contains(E2);
public Vertex getVertex(int i) { return edge[i].orig(); }
/** * Turns an edge counterclockwise inside its enclosing quadrilateral. * * @param e the quadedge to turn */ public static void swap(QuadEdge e) { QuadEdge a = e.oPrev(); QuadEdge b = e.sym().oPrev(); splice(e, a); splice(e.sym(), b); splice(e, a.lNext()); splice(e.sym(), b.lNext()); e.setOrig(a.dest()); e.setDest(b.dest()); }
/** * Gets the primary edge of this quadedge and its <tt>sym</tt>. * The primary edge is the one for which the origin * and destination coordinates are ordered * according to the standard {@link Coordinate} ordering * * @return the primary quadedge */ public QuadEdge getPrimary() { if (orig().getCoordinate().compareTo(dest().getCoordinate()) <= 0) return this; else return sym(); }
firstBorderEdge = borderEdge.getPrimary(); borderVertices.add(borderEdge.orig()); borderVertices.add(borderEdge.dest()); sortedByLengthQueue.add(new ImmutablePair<>(borderEdge, triangle)); if (isEdgeCollinearWithALineSemgentOfMultiLineString(edge, constraintSegments)) constraintEdges.add(edge.getPrimary()); Vertex startVertex = firstBorderEdge.orig(); Vertex currentDestVertex = firstBorderEdge.dest(); QuadEdge previousEdge = firstBorderEdge; QuadEdge currentIncidentEdge = previousEdge.dNext(); currentEdge = currentIncidentEdge.sym(); break; currentIncidentEdge = currentIncidentEdge.dNext(); currentDestVertex = currentEdge.dest();
public static double interpolateZ(DelaunayTriangulationBuilder triangulation, Coordinate coordinate) { QuadEdgeSubdivision quadEdgeSubdivision = triangulation.getSubdivision(); QuadEdge edge = quadEdgeSubdivision.locate(coordinate); return new Vertex(coordinate.x, coordinate.y) .interpolateZValue(edge.orig(), edge.dest(), edge.oNext().dest()); }
/** * Locates the edge between the given vertices, if it exists in the * subdivision. * * @param p0 a coordinate * @param p1 another coordinate * @return the edge joining the coordinates, if present * or null if no such edge exists */ public QuadEdge locate(Coordinate p0, Coordinate p1) { // find an edge containing one of the points QuadEdge e = locator.locate(new Vertex(p0)); if (e == null) return null; // normalize so that p0 is origin of base edge QuadEdge base = e; if (e.dest().getCoordinate().equals2D(p0)) base = e.sym(); // check all edges around origin of base edge QuadEdge locEdge = base; do { if (locEdge.dest().getCoordinate().equals2D(p1)) return locEdge; locEdge = locEdge.oNext(); } while (locEdge != base); return null; }
/** * Gets the neighbours of this triangle. If there is no neighbour triangle, * the array element is <code>null</code> * * @return an array containing the 3 neighbours of this triangle */ public QuadEdgeTriangle[] getNeighbours() { QuadEdgeTriangle[] neigh = new QuadEdgeTriangle[3]; for (int i = 0; i < 3; i++) { neigh[i] = (QuadEdgeTriangle) getEdge(i).sym().getData(); } return neigh; }
/** * Deletes a quadedge from the subdivision. Linked quadedges are updated to * reflect the deletion. * * @param e * the quadedge to delete */ public void delete(QuadEdge e) { QuadEdge.splice(e, e.oPrev()); QuadEdge.splice(e.sym(), e.sym().oPrev()); QuadEdge eSym = e.sym(); QuadEdge eRot = e.rot(); QuadEdge eRotSym = e.rot().sym(); // this is inefficient on an ArrayList, but this method should be called infrequently quadEdges.remove(e); quadEdges.remove(eSym); quadEdges.remove(eRot); quadEdges.remove(eRotSym); e.delete(); eSym.delete(); eRot.delete(); eRotSym.delete(); }