// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2015 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 "facet_components.h" #include #include #include template IGL_INLINE void igl::facet_components( const Eigen::PlainObjectBase & F, Eigen::PlainObjectBase & C) { using namespace std; typedef typename DerivedF::Index Index; vector > > TT; vector > > TTi; triangle_triangle_adjacency(F,TT,TTi); Eigen::VectorXi counts; return facet_components(TT,C,counts); } template < typename TTIndex, typename DerivedC, typename Derivedcounts> IGL_INLINE void igl::facet_components( const std::vector > > & TT, Eigen::PlainObjectBase & C, Eigen::PlainObjectBase & counts) { using namespace std; typedef TTIndex Index; const Index m = TT.size(); C.resize(m,1); vector seen(m,false); Index id = 0; vector vcounts; for(Index g = 0;g Q; Q.push(g); while(!Q.empty()) { const Index f = Q.front(); Q.pop(); if(seen[f]) { continue; } seen[f] = true; vcounts[id]++; C(f,0) = id; // Face f's neighbor lists opposite opposite each corner for(const auto & c : TT[f]) { // Each neighbor for(const auto & n : c) { if(!seen[n]) { Q.push(n); } } } } id++; } assert((size_t) id == vcounts.size()); const size_t ncc = vcounts.size(); assert((size_t)C.maxCoeff()+1 == ncc); counts.resize(ncc,1); for(size_t i = 0;i, Eigen::Matrix >(std::vector >, std::allocator > > >, std::allocator >, std::allocator > > > > > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::facet_components, Eigen::Matrix >(std::vector >, std::allocator > > >, std::allocator >, std::allocator > > > > > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::facet_components, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); #ifdef WIN32 template void igl::facet_components<__int64,class Eigen::Matrix<__int64,-1,1,0,-1,1>,class Eigen::Matrix<__int64,-1,1,0,-1,1> >(class std::vector >,class std::allocator > > >,class std::allocator >,class std::allocator > > > > > const &,class Eigen::PlainObjectBase > &,class Eigen::PlainObjectBase > &); #endif #endif