/** * Computes the area-weighted average normal vector for this node. * @param vn array to contain the {X,Y,Z} components of the normal vector. */ public void normalVector(float[] vn) { vn[0] = vn[1] = vn[2] = 0.0f; FaceIterator fi = getFaces(); while (fi.hasNext()) { Face face = fi.next(); accNormalVector(face,vn); } float x = vn[0]; float y = vn[1]; float z = vn[2]; float s = 1.0f/(float)sqrt(x*x+y*y+z*z); vn[0] *= s; vn[1] *= s; vn[2] *= s; }
/** * Returns the number of faces that reference this node. * @return the number of faces. */ public int countFaces() { int nface = 0; FaceIterator fi = getFaces(); while (fi.hasNext()) { fi.next(); ++nface; } return nface; }
private void validate() { NodeIterator ni = getNodes(); while (ni.hasNext()) { Node node = ni.next(); node.validate(); } FaceIterator fi = getFaces(); while (fi.hasNext()) { Face face = fi.next(); face.validate(); } }