// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2013 Alec Jacobson // // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #include "edge_topology.h" #include "is_edge_manifold.h" #include template IGL_INLINE void igl::edge_topology( const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F, Eigen::MatrixXi& EV, Eigen::MatrixXi& FE, Eigen::MatrixXi& EF) { // Only needs to be edge-manifold if (V.rows() ==0 || F.rows()==0) { EV = Eigen::MatrixXi::Constant(0,2,-1); FE = Eigen::MatrixXi::Constant(0,3,-1); EF = Eigen::MatrixXi::Constant(0,2,-1); return; } assert(igl::is_edge_manifold(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; } // Sort the relation EF, accordingly to EV // the first one is the face on the left of the edge for(unsigned i=0; i, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::Matrix&, Eigen::Matrix&, Eigen::Matrix&); template void igl::edge_topology, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::Matrix&, Eigen::Matrix&, Eigen::Matrix&); #endif