int y1 = (int)(yshift+qc[1]*yscale); if (_drawPolys || !cb.equals(cc)) { TriMesh.Tri ta = tri.triNabor(na); if (ta!=null && _mesh.isInner(ta)) { TriMesh.Node nn = tri.nodeNabor(ta); TriMesh.Tri tb = tri.triNabor(nb); if (tb!=null && _mesh.isInner(tb)) { TriMesh.Node nn = tri.nodeNabor(tb); TriMesh.Tri tc = tri.triNabor(nc); if (tc!=null && _mesh.isInner(tc)) { TriMesh.Node nn = tri.nodeNabor(tc);
/** * Constructs a directed edge that references the specified nodes. * Optionally, a tri may be specified. If non-null, that tri must * reference the specified nodes. * @param a a node of the edge. * @param b a node of the edge. * @param abc a tri that references nodes A and B; null, if none. */ public Edge(Node a, Node b, Tri abc) { Node c = (abc!=null)?otherNode(abc,a,b):null; Check.argument(abc==null || c!=null,"tri references nodes"); _a = a; _b = b; if (c!=null) { if (nodesInOrder(abc,a,b,c)) { _triLeft = abc; _nodeLeft = c; _triRight = abc.triNabor(c); _nodeRight = (_triRight!=null)?abc.nodeNabor(_triRight):null; } else { _triRight = abc; _nodeRight = c; _triLeft = abc.triNabor(c); _nodeLeft = (_triLeft!=null)?abc.nodeNabor(_triLeft):null; } } }
/** * Adds the mate of the edge of the specified tri that is opposite * the specified node, unless the edge is in the set, in which case * that edge is removed. Sets the current edge to the mate added or * the edge removed. * @param tri the tri that references the nodes in the edge. * @param node the other node in the tri that is not in the edge. * @return true, if the mate was added; false, if the edge was removed. */ boolean addMate(Tri tri, Node node) { Tri triNabor = tri.triNabor(node); Node nodeNabor = (triNabor!=null)?tri.nodeNabor(triNabor):null; if (node==tri._n0) { return add(tri._n2,tri._n1,nodeNabor,triNabor); } else if (node==tri._n1) { return add(tri._n0,tri._n2,nodeNabor,triNabor); } else if (node==tri._n2) { return add(tri._n1,tri._n0,nodeNabor,triNabor); } else { assert false:"node is referenced by tri"; return false; } }
/** * Validates the specified tri. */ private void validate(Tri tri) { Check.state(tri!=null,"tri not null"); Node na = tri.nodeA(); Node nb = tri.nodeB(); Node nc = tri.nodeC(); validate(na); validate(nb); validate(nc); Tri ta = tri.triA(); Tri tb = tri.triB(); Tri tc = tri.triC(); if (ta!=null) Check.state(ta.triNabor(tri.nodeNabor(ta))==tri,"a nabors ok"); if (tb!=null) Check.state(tb.triNabor(tri.nodeNabor(tb))==tri,"b nabors ok"); if (tc!=null) Check.state(tc.triNabor(tri.nodeNabor(tc))==tri,"c nabors ok"); }
/** * Given a node referenced by one edge of the hull, gets the next * edge on the hull that is opposite that node. */ private Edge getNextEdgeOnHull(Node node, Edge edge) { Tri tri = edge.triLeft(); Node next = edge.nodeLeft(); for (Tri tnext=tri.triNabor(node); tnext!=null; tnext=tri.triNabor(node)) { node = next; next = tri.nodeNabor(tnext); tri = tnext; } return new Edge(tri,node); }
/** * Given a tri and node on the hull, and another node, typically * inside (not on) the hull, gets the next tri on the hull that * is opposite the node on the hull. If the other node is also * on the hull, this method simply returns the specified tri. */ private Tri getNextTriOnHull(Tri tri, Node node, Node nodeOther) { for (Tri tnext=tri.triNabor(node); tnext!=null; tnext=tri.triNabor(node)) { node = nodeOther; nodeOther = tri.nodeNabor(tnext); tri = tnext; } return tri; }
private Edge(Tri triLeft, Node nodeLeft) { initLeft(triLeft,nodeLeft); _triLeft = triLeft; _nodeLeft = nodeLeft; _triRight = triLeft.triNabor(nodeLeft); _nodeRight = (_triRight!=null)?_triLeft.nodeNabor(_triRight):null; }