/** * Finds a quadedge of a triangle containing a location * specified by a {@link Coordinate}, if one exists. * * @param p the Coordinate to locate * @return a quadedge on the edge of a triangle which touches or contains the location * or null if no such triangle exists */ public QuadEdge locate(Coordinate p) { return locator.locate(new Vertex(p)); }
/** * 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; }
public void getEdgeSegment(int i, LineSegment seg) { seg.p0 = edge[i].orig().getCoordinate(); int nexti = (i + 1) % 3; seg.p1 = edge[nexti].orig().getCoordinate(); }
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(); LineSegment sB = qet.getEdge(1).toLineSegment(); LineSegment sC = qet.getEdge(2).toLineSegment(); sA.normalize(); sB.normalize(); Triangle triangle = new Triangle(i, qet.isBorder()?true:false);
/** * 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; }
/** * returns a new vertex that is mid-way between this vertex and another end point. * * @param a the other end point. * @return the point mid-way between this and that. */ public Vertex midPoint(Vertex a) { double xm = (p.x + a.getX()) / 2.0; double ym = (p.y + a.getY()) / 2.0; double zm = (p.z + a.getZ()) / 2.0; return new Vertex(xm, ym, zm); }
private void process(QuadEdgeTriangle currTri, TraversalVisitor visitor) { currTri.getNeighbours(); for (int i = 0; i < 3; i++) { QuadEdgeTriangle neighTri = (QuadEdgeTriangle) currTri.getEdge(i).sym().getData(); if (neighTri == null) continue; if (visitor.visit(currTri, i, neighTri)) triQueue.addLast(neighTri); } }
public int getAdjacentTriangleEdgeIndex(int i) { return getAdjacentTriangleAcrossEdge(i).getEdgeIndex(getEdge(i).sym()); }
/** * 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; }
/** * Gets the coordinates for each triangle in the subdivision as an array. * * @param includeFrame * true if the frame triangles should be included * @return a list of Coordinate[4] representing each triangle */ public List getTriangleCoordinates(boolean includeFrame) { TriangleCoordinatesVisitor visitor = new TriangleCoordinatesVisitor(); visitTriangles(visitor, includeFrame); return visitor.getTriangles(); }
/** * Gets a list of the triangles in the subdivision, * specified as an array of the triangle {@link Vertex}es. * * @param includeFrame * true if the frame triangles should be included * @return a List of Vertex[3] arrays */ public List getTriangleVertices(boolean includeFrame) { TriangleVertexListVisitor visitor = new TriangleVertexListVisitor(); visitTriangles(visitor, includeFrame); return visitor.getTriangleVertices(); }
/** * Gets a list of the triangles * in the subdivision, specified as * an array of the primary quadedges around the triangle. * * @param includeFrame * true if the frame triangles should be included * @return a List of QuadEdge[3] arrays */ public List getTriangleEdges(boolean includeFrame) { TriangleEdgesListVisitor visitor = new TriangleEdgesListVisitor(); visitTriangles(visitor, includeFrame); return visitor.getTriangleEdges(); }
private QuadEdge initSubdiv() { // build initial subdivision from frame QuadEdge ea = makeEdge(frameVertex[0], frameVertex[1]); QuadEdge eb = makeEdge(frameVertex[1], frameVertex[2]); QuadEdge.splice(ea.sym(), eb); QuadEdge ec = makeEdge(frameVertex[2], frameVertex[0]); QuadEdge.splice(eb.sym(), ec); QuadEdge.splice(ec.sym(), ea); return ea; }
/** * Locates an edge e, such that either v is on e, or e is an edge of a triangle containing v. * The search starts from the last located edge amd proceeds on the general direction of v. */ public QuadEdge locate(Vertex v) { if (! lastEdge.isLive()) { init(); } QuadEdge e = subdiv.locateFromEdge(v, lastEdge); lastEdge = e; return e; } }
/** * Gets the edge around the right face ccw following this edge. * * @return the next right face edge. */ public final QuadEdge rNext() { return rot.next.invRot(); }
/** * Tests whether this triangle is adjacent to the outside of the subdivision. * * @return true if the triangle is adjacent to the subdivision exterior */ public boolean isBorder() { for (int i = 0; i < 3; i++) { if (getAdjacentTriangleAcrossEdge(i) == null) return true; } return false; }
public Coordinate getCoordinate(int i) { return edge[i].orig().getCoordinate(); }