// // IGL Lib - Simple C++ mesh library // // Copyright 2011, Daniele Panozzo. All rights reserved. #ifndef IGL_EDGETOPOLOGY_H #define IGL_EDGETOPOLOGY_H #include #include #include namespace igl { // Initialize Edges and their topological relations // Output: // EV : #Ex2, Stores the edge description as pair of indices to vertices // FE : #Fx3, Stores the Triangle-Edge relation // EF : #Ex2: Stores the Edge-Triangle relation (unsorted) inline void edgetopology( const Eigen::MatrixXd& V, const Eigen::MatrixXi& F, const Eigen::MatrixXi& EV, const Eigen::MatrixXi& FE, const Eigen::MatrixXi& EF); } // Implementation #include #include "is_manifold.h" inline void edgetopology( const Eigen::MatrixXd& V, const Eigen::MatrixXi& F, const Eigen::MatrixXi& EV, const Eigen::MatrixXi& FE, const Eigen::MatrixXi& EF) { assert(igl::is_manifold(V,F)); std::vector > ETT; for(int f=0;f v2) std::swap(v1,v2); std::vector r(4); r[0] = v1; r[1] = v2; r[2] = f; r[3] = i; ETT.push_back(r); } std::sort(ETT.begin(),ETT.end()); // count the number of edges (assume manifoldness) int En = 1; // the last is always counted for(int i=0;i& r1 = ETT[i]; EV(En,0) = r1[0]; EV(En,1) = r1[1]; EF(En,0) = r1[2]; FE(r1[2],r1[3]) = En; } else { std::vector& r1 = ETT[i]; std::vector& r2 = ETT[i+1]; EV(En,0) = r1[0]; EV(En,1) = r1[1]; EF(En,0) = r1[2]; EF(En,1) = r2[2]; FE(r1[2],r1[3]) = En; FE(r2[2],r2[3]) = En; ++i; // skip the next one } ++En; } } #endif