// 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 "upsample.h" #include "tt.h" //// Bug in unsupported/Eigen/SparseExtra needs iostream first //#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET //#include //#include #include template < typename DerivedV, typename DerivedF, typename DerivedNV, typename DerivedNF> IGL_INLINE void igl::upsample( const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F, Eigen::PlainObjectBase& NV, Eigen::PlainObjectBase& NF) { // Use "in place" wrapper instead assert(&V != &NV); assert(&F != &NF); using namespace igl; using namespace std; using namespace Eigen; ////typedef Eigen::PlainObjectBase MatF; ////typedef Eigen::PlainObjectBase MatNF; ////typedef Eigen::PlainObjectBase MatNV; ////MatF FF, FFi; Eigen::MatrixXi FF,FFi; tt(V,F,FF,FFi); // TODO: Cache optimization missing from here, it is a mess // Compute the number and positions of the vertices to insert (on edges) Eigen::MatrixXi NI = Eigen::MatrixXi::Constant(FF.rows(),FF.cols(),-1); int counter = 0; for(int i=0;i SUBD(V.rows()+n_even,V.rows()); //SUBD.reserve(15 * (V.rows()+n_even)); // Preallocate NV and NF NV.resize(V.rows()+n_even,V.cols()); NF.resize(F.rows()*4,3); // Fill the odd vertices position NV.block(0,0,V.rows(),V.cols()) = V; // Fill the even vertices position for(int i=0;i IGL_INLINE void igl::upsample( MatV& V, MatF& F) { const MatV V_copy = V; const MatF F_copy = F; return upsample(V_copy,F_copy,V,F); } #ifndef IGL_HEADER_ONLY // Explicit template specialization template void igl::upsample, Eigen::Matrix >(Eigen::Matrix&, Eigen::Matrix&); #endif