//-- // // ComputeVertexNormals // //-- // Compute unit normal of every vertex void Mesh::ComputeVertexNormals() { int i; // Assume that face normals are computed assert( FaceNormalNumber() == FaceNumber() ); // Resize and initialize vertex normal array vertex_normals.assign( VertexNumber(), Vector3d(0,0,0) ); // For every face for( i=0 ; i<FaceNumber() ; i++ ) { // Add face normal to vertex normal VertexNormal(i,0) += FaceNormal(i); VertexNormal(i,1) += FaceNormal(i); VertexNormal(i,2) += FaceNormal(i); } // For every vertex for( i=0 ; i<VertexNumber() ; i++) { // Normalize vertex normal VertexNormal(i).Normalize(); } }
//-- // // ComputeFaceNormals // //-- // Compute unit normal of every faces void Mesh::ComputeFaceNormals() { // Resize face normal array face_normals.resize( FaceNumber() ); // For every face for( int i=0; i<FaceNumber(); i++ ) { // Compute unit face normal FaceNormal(i) = ComputeFaceNormal(i); } }
//-- // // BuildProgressiveEdgeList // //-- void MultiresolutionMesh::BuildProgressiveEdgeList() { // Reset the edge list edge_list.clear(); // For every face for( int i=0; i<FaceNumber(); i++ ) { // Test if the face is valid if( !IsProgressiveFaceValid(i) ) continue; // Shortcuts to vertex indices of the current face const int& a = Face(i, 0); const int& b = Face(i, 1); const int& c = Face(i, 2); // Edge (a,b) if( a < b ) edge_list.push_back(Vector2i(a, b)); else edge_list.push_back(Vector2i(b, a)); // Edge (b,c) if( b < c ) edge_list.push_back(Vector2i(b, c)); else edge_list.push_back(Vector2i(c, b)); // Edge (c,a) if( c < a ) edge_list.push_back(Vector2i(c, a)); else edge_list.push_back(Vector2i(a, c)); } // Sort the edge list edge_list.sort(); // Remove redundant edges edge_list.unique(); }
bool neighbour3D::Build_P2P_Neigh(){ if(VertexNumber() == 0 || FaceNumber() == 0) return false; //building an array of empty sets of size of vertices int VertexSize = VertexNumber(); for(int i = 0; i < VertexSize; i++){ set<int> myset; P2P.push_back(myset); } int FaceSize = FaceNumber(); for(int i = 0; i<FaceSize; i++){ Vector3i V(Face(i)); //now we have three vertex INDICES of the face[i] in V P2P.at(V[0]).insert(V[1]);P2P.at(V[0]).insert(V[2]); P2P.at(V[1]).insert(V[2]);P2P.at(V[1]).insert(V[0]); P2P.at(V[2]).insert(V[0]);P2P.at(V[2]).insert(V[1]); } return true; }
bool neighbour3D :: Build_P2F_Neigh() { int vn = VertexNumber(); int fn = FaceNumber(); if(vn == 0 || fn == 0) return false; for( int i=0; i<vn; i++) { set <int> myset; P2F.push_back(myset); } // now span all the faces, and adds the faces within the corresponding sets for( int i=0; i<fn; i++) { Vector3i F(face(i)); for( int j=0; j<3; j++) P2F[F[j]].insert(i); } return true; }