Face face = new Face(meshFace); init(face);
if (faceTwin.references(nodeA)) { Node nodeD = nodeC.edgeAfter().nodeB(); assert nodeD.isOnBoundary(); else if (faceTwin.references(nodeB)) { Node nodeD = nodeC.edgeBefore().nodeA(); assert nodeD.isOnBoundary();
Face face = (mfBest!=null)?new Face(mfBest):null; double grade = (vvBest>VV_LARGE)?1.0/rrBest:vvBest-1.0; if (grade<=0.0)
if (face.references(node2)) return face; Face face1 = face; face = node1.faceNext(face1); while (face!=face1 && face!=null) { if (face.references(node2)) return face; face = node1.faceNext(face); face = node1.facePrev(face1); while (face!=face1 && face!=null) { if (face.references(node2)) return face; face = node1.facePrev(face);
/** * Returns the node referenced by this face that is nearest to * the point with specified coordinates. * @param x the x coordinate. * @param y the y coordinate. * @param z the z coordinate. * @return the node nearest to the point (x,y,z). */ public final Node nodeNearest(float x, float y, float z) { Node na = nodeA(); Node nb = nodeB(); Node nc = nodeC(); double da = distanceSquared(na,x,y,z); double db = distanceSquared(nb,x,y,z); double dc = distanceSquared(nc,x,y,z); double dmin = da; Node nmin = na; if (db<dmin) { dmin = db; nmin = nb; } if (dc<dmin) { dmin = dc; nmin = nc; } return nmin; }
private void init(Face face) { trace("init: face="+face); trace(" meshFace A="+face._meshFace.nodeA()); trace(" meshFace B="+face._meshFace.nodeB()); trace(" meshFace C="+face._meshFace.nodeC()); face._faceA = null; face._faceB = null; face._faceC = null; Node nodeA = face.nodeA(); Node nodeB = face.nodeB(); Node nodeC = face.nodeC(); nodeA.setFace(face); nodeB.setFace(face); nodeC.setFace(face); Edge edgeCB = makeEdge(nodeC,nodeB,face); Edge edgeBA = makeEdge(nodeB,nodeA,face); Edge edgeAC = makeEdge(nodeA,nodeC,face); nodeA.setEdgeBefore(edgeBA); nodeB.setEdgeBefore(edgeCB); nodeC.setEdgeBefore(edgeAC); nodeA.setEdgeAfter(edgeAC); nodeB.setEdgeAfter(edgeBA); nodeC.setEdgeAfter(edgeCB); addEdge(edgeCB); addEdge(edgeBA); addEdge(edgeAC); addFace(face); }
private static void accNormalVector(Face face, float[] v) { Node na = face.nodeA(); Node nb = face.nodeB(); Node nc = face.nodeC(); float xa = na.x(); float ya = na.y(); float za = na.z(); float xb = nb.x(); float yb = nb.y(); float zb = nb.z(); float xc = nc.x(); float yc = nc.y(); float zc = nc.z(); float x0 = xc-xa; float y0 = yc-ya; float z0 = zc-za; float x1 = xa-xb; float y1 = ya-yb; float z1 = za-zb; v[0] += y0*z1-y1*z0; v[1] += x1*z0-x0*z1; v[2] += x0*y1-x1*y0; } }
/** * Returns a face that references the specified nodes. * @param node1 a node. * @param node2 a node. * @param node3 a node. * @return a face that references the specified nodes; or null, * if a node is not in the surface or the surface has no faces. */ public synchronized Face findFace(Node node1, Node node2, Node node3) { Face face = findFace(node1,node2); // if (face!=null) { // clearFaceMarks(); // face = findFace(face,node1,node2,node3); // } if (face!=null) { if (face.references(node3)) return face; face = face.faceNabor(node3); if (face!=null && face.references(node3)) return face; } return null; }
/** * Computes the circumcenter of this face. * @param cc array of circumcenter coordinates {xc,yc,zc}. * @return radius-squared of circumcircle. */ public double centerCircle(double[] cc) { Node na = nodeA(); Node nb = nodeB(); Node nc = nodeC(); double xa = na.x(); double ya = na.y(); double za = na.z(); double xb = nb.x(); double yb = nb.y(); double zb = nb.z(); double xc = nc.x(); double yc = nc.y(); double zc = nc.z(); Geometry.centerCircle3D(xa,ya,za,xb,yb,zb,xc,yc,zc,cc); double xcc = cc[0]; double ycc = cc[1]; double zcc = cc[2]; double dx = xcc-xc; double dy = ycc-yc; double dz = zcc-yc; return dx*dx+dy*dy+dz*dz; }
private static void linkFaces( Face face, Node node, Face faceNabor, Node nodeNabor) { if (face!=null) { if (node==face.nodeA()) { face._faceA = faceNabor; } else if (node==face.nodeB()) { face._faceB = faceNabor; } else if (node==face.nodeC()) { face._faceC = faceNabor; } else { assert false:"node referenced by face"; } } if (faceNabor!=null) { if (nodeNabor==faceNabor.nodeA()) { faceNabor._faceA = face; } else if (nodeNabor==faceNabor.nodeB()) { faceNabor._faceB = face; } else if (nodeNabor==faceNabor.nodeC()) { faceNabor._faceC = face; } else { assert false:"nodeNabor referenced by faceNabor"; } } }
/** * Determines whether this face references the specified nodes. * @param node1 a node. * @param node2 a node. * @return true, if this face references the nodes; false, otherwise. */ public boolean references(Node node1, Node node2) { Node na = nodeA(); Node nb = nodeB(); Node nc = nodeC(); if (node1==na) { return node2==nb || node2==nc; } else if (node1==nb) { return node2==na || node2==nc; } else if (node1==nc) { return node2==na || node2==nb; } else { return false; } }
private Edge(TetMesh.Edge meshEdge, Face face) { _meshEdge = meshEdge; Node nodeA = (Node)meshEdge.nodeA().data; Node nodeB = (Node)meshEdge.nodeB().data; Node nodeC = (face!=null)?otherNode(face,nodeA,nodeB):null; Check.argument(face==null || nodeC!=null,"face references edge"); if (nodeC!=null) { if (nodesInOrder(face,nodeA,nodeB,nodeC)) { _faceLeft = face; _faceRight = face.faceNabor(nodeC); } else { _faceLeft = face.faceNabor(nodeC); _faceRight = face; } } } }
private void validate() { assert _meshNode!=null; assert _face==null || _face.references(this); if (_edgeBefore==null) { assert _edgeAfter==null; } else { assert this==_edgeBefore.nodeB(); assert this==_edgeAfter.nodeA(); assert this==_edgeBefore.nodeA().edgeAfter().nodeB(); assert this==_edgeAfter.nodeB().edgeBefore().nodeA(); } assert _edgeBefore==null && _edgeAfter==null || _edgeBefore!=null && this==_edgeBefore.nodeB() && _edgeAfter!=null && this==_edgeAfter.nodeA(); } private void init() {
/** * Returns the mate of this face. * @return the mate of this face. */ public Face mate() { return new Face(_meshFace.mate()); }
/** * Determines whether the specified nodes are an internal edge. * An internal edge is not on the boundary; it has two nabor faces. */ private boolean hasInternalEdge(Node nodeA, Node nodeB) { Face face = findFace(nodeA,nodeB); if (face==null) return false; face = face.faceNabor(otherNode(face,nodeA,nodeB)); if (face==null) return false; return true; }