#ifndef IGL_ADJACENCY_MATRIX_H #define IGL_ADJACENCY_MATRIX_H #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET #include #include #include namespace igl { // Constructs the graph adjacency list of a given mesh (V,F) // Templates: // T should be a eigen sparse matrix primitive type like int or double // Inputs: // F #F by dim list of mesh faces (must be triangles) // sorted flag that indicates if the list should be sorted counter-clockwise // Outputs: // A vector > containing at row i the adjacent vertices of vertex i // // Example: // // Mesh in (V,F) // vector > A; // adjacency_list(F,A); // // See also: edges, cotmatrix, diag template inline void adjacency_list( const M & F, std::vector >& A, bool sorted = false ); } // Implementation #include "verbose.h" template inline void igl::adjacency_list( const M & F, std::vector >& A, bool sorted ) { A.clear(); A.resize(F.maxCoeff()+1); // Loop over faces for(int i = 0;i d int s = F(i,j); int d = F(i,(j+1)%F.cols()); A.at(s).push_back(d); A.at(d).push_back(s); } } // Remove duplicates for(int i=0; i > > SR; SR.resize(A.size()); for(int i = 0;i d int s = F(i,j); int d = F(i,(j+1)%F.cols()); // Get index of opposing vertex v int v = F(i,(j+2)%F.cols()); std::vector e(2); e[0] = d; e[1] = v; SR[s].push_back(e); } } for(int v=0; v& vv = A.at(v); std::vector >& sr = SR[v]; std::vector > pn = sr; // Compute previous/next for every element in sr for(int i=0;i