// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2014 Daniele Panozzo // // 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 "polygon_mesh_to_triangle_mesh.h" #include "matrix_to_list.h" template IGL_INLINE void igl::polygon_mesh_to_triangle_mesh( const std::vector > & vF, Eigen::PlainObjectBase& F) { using namespace std; using namespace Eigen; int m = 0; // estimate of size for(typename vector >::const_iterator fit = vF.begin(); fit!=vF.end(); fit++) { if(fit->size() >= 3) { m += fit->size() - 2; } } // Resize output F.resize(m,3); { int k = 0; for(typename vector >::const_iterator fit = vF.begin(); fit!=vF.end(); fit++) { if(fit->size() >= 3) { typename vector::const_iterator cit = fit->begin(); cit++; typename vector::const_iterator pit = cit++; for(; cit!=fit->end(); cit++,pit++) { F(k,0) = *(fit->begin()); F(k,1) = *pit; F(k,2) = *cit; k++; } } } assert(k==m); } } template IGL_INLINE void igl::polygon_mesh_to_triangle_mesh( const Eigen::PlainObjectBase& P, Eigen::PlainObjectBase& F) { std::vector > vP; matrix_to_list(P,vP); return polygon_mesh_to_triangle_mesh(vP,F); } #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation // generated by autoexplicit.sh template void igl::polygon_mesh_to_triangle_mesh >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); // generated by autoexplicit.sh template void igl::polygon_mesh_to_triangle_mesh >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); template void igl::polygon_mesh_to_triangle_mesh >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); template void igl::polygon_mesh_to_triangle_mesh >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); #endif