public final boolean rightOf(QuadEdge e) { return isCCW(e.dest(), e.orig()); }
public final boolean leftOf(QuadEdge e) { return isCCW(e.orig(), e.dest()); }
Vertex vd = qe.dest();
/** * Creates a {@link LineSegment} representing the * geometry of this edge. * * @return a LineSegment */ public LineSegment toLineSegment() { return new LineSegment(vertex.getCoordinate(), dest().getCoordinate()); }
/** * Tests whether a QuadEdge is an edge incident on a frame triangle vertex. * * @param e * the edge to test * @return true if the edge is connected to the frame triangle */ public boolean isFrameEdge(QuadEdge e) { if (isFrameVertex(e.orig()) || isFrameVertex(e.dest())) return true; return false; }
/** * Converts this edge to a WKT two-point <tt>LINESTRING</tt> indicating * the geometry of this edge. * * @return a String representing this edge's geometry */ public String toString() { Coordinate p0 = vertex.getCoordinate(); Coordinate p1 = dest().getCoordinate(); return WKTWriter.toLineString(p0, p1); } }
/** * Tests whether a {@link Vertex} is the start or end vertex of a * {@link QuadEdge}, up to the subdivision tolerance distance. * * @param e * @param v * @return true if the vertex is a endpoint of the edge */ public boolean isVertexOfEdge(QuadEdge e, Vertex v) { if ((v.equals(e.orig(), tolerance)) || (v.equals(e.dest(), tolerance))) { return true; } return false; }
/** * Gets the geometry for the edges in the subdivision as a {@link MultiLineString} * containing 2-point lines. * * @param geomFact the GeometryFactory to use * @return a MultiLineString */ public Geometry getEdges(GeometryFactory geomFact) { List quadEdges = getPrimaryEdges(false); LineString[] edges = new LineString[quadEdges.size()]; int i = 0; for (Iterator it = quadEdges.iterator(); it.hasNext();) { QuadEdge qe = (QuadEdge) it.next(); edges[i++] = geomFact.createLineString(new Coordinate[] { qe.orig().getCoordinate(), qe.dest().getCoordinate() }); } return geomFact.createMultiLineString(edges); }
/** * Gets the length of the geometry of this quadedge. * * @return the length of the quadedge */ public double getLength() { return orig().getCoordinate().distance(dest().getCoordinate()); }
/** * Tests if this quadedge and another have the same line segment geometry * with the same orientation. * * @param qe a quadege * @return true if the quadedges are based on the same line segment */ public boolean equalsOriented(QuadEdge qe) { if (orig().getCoordinate().equals2D(qe.orig().getCoordinate()) && dest().getCoordinate().equals2D(qe.dest().getCoordinate())) return true; return false; }
/** * 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(); }
/** * Tests whether a {@link Coordinate} lies on a {@link QuadEdge}, up to a * tolerance determined by the subdivision tolerance. * * @param e * a QuadEdge * @param p * a point * @return true if the vertex lies on the edge */ public boolean isOnEdge(QuadEdge e, Coordinate p) { seg.setCoordinates(e.orig().getCoordinate(), e.dest().getCoordinate()); double dist = seg.distance(p); // heuristic (hack?) return dist < edgeCoincidenceTolerance; }
/** * 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; }
/** * Tests whether a QuadEdge is an edge on the border of the frame facets and * the internal facets. E.g. an edge which does not itself touch a frame * vertex, but which touches an edge which does. * * @param e * the edge to test * @return true if the edge is on the border of the frame */ public boolean isFrameBorderEdge(QuadEdge e) { // MD debugging QuadEdge[] leftTri = new QuadEdge[3]; getTriangleEdges(e, leftTri); // System.out.println(new QuadEdgeTriangle(leftTri).toString()); QuadEdge[] rightTri = new QuadEdge[3]; getTriangleEdges(e.sym(), rightTri); // System.out.println(new QuadEdgeTriangle(rightTri).toString()); // check other vertex of triangle to left of edge Vertex vLeftTriOther = e.lNext().dest(); if (isFrameVertex(vLeftTriOther)) return true; // check other vertex of triangle to right of edge Vertex vRightTriOther = e.sym().lNext().dest(); if (isFrameVertex(vRightTriOther)) return true; return false; }
/** * 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; }
/** * 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()); }
if ((v.equals(e.orig())) || (v.equals(e.dest()))) { break; } else if (v.rightOf(e)) {
QuadEdge e = locate(v); if ((v.equals(e.orig(), tolerance)) || (v.equals(e.dest(), tolerance))) { return e; // point already in subdivision.
/** * Converts this edge to a WKT two-point <tt>LINESTRING</tt> indicating * the geometry of this edge. * * @return a String representing this edge's geometry */ public String toString() { Coordinate p0 = vertex.getCoordinate(); Coordinate p1 = dest().getCoordinate(); return WKTWriter.toLineString(p0, p1); } }