// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2016 Oded Stein // // 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 "loop.h" #include #include #include #include namespace igl { IGL_INLINE void loop(const int n_verts, const Eigen::MatrixXi& F, Eigen::SparseMatrix& S, Eigen::MatrixXi& newF) { typedef Eigen::SparseMatrix SparseMat; typedef Eigen::Triplet Triplet_t; //Ref. https://graphics.stanford.edu/~mdfisher/subdivision.html //Heavily borrowing from igl::upsample Eigen::MatrixXi FF, FFi; triangle_triangle_adjacency(F, FF, FFi); std::vector> adjacencyList; adjacency_list(F, adjacencyList, true); //Compute the number and positions of the vertices to insert (on edges) Eigen::MatrixXi NI = Eigen::MatrixXi::Constant(FF.rows(), FF.cols(), -1); Eigen::MatrixXi NIdoubles = Eigen::MatrixXi::Zero(FF.rows(), FF.cols()); Eigen::VectorXi vertIsOnBdry = Eigen::VectorXi::Zero(n_verts); int counter = 0; for(int i=0; i tripletList; for(int i=0; i& localAdjList = adjacencyList[i]; if(vertIsOnBdry(i)==1) { //Boundary vertex tripletList.emplace_back(i, localAdjList.front(), 1./8.); tripletList.emplace_back(i, localAdjList.back(), 1./8.); tripletList.emplace_back(i, i, 3./4.); } else { const int n = localAdjList.size(); const double dn = n; double beta; if(n==3) beta = 3./16.; else beta = 3./8./dn; for(int j=0; j SparseMat; typedef Eigen::Triplet Triplet_t; newV = V; newF = F; for(int i=0; i