// 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 "triangulate.h" template IGL_INLINE void igl::triangulate( 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); } } #ifndef IGL_HEADER_ONLY // Explicit template instanciation template void igl::triangulate >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); #endif