// 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 "collapse_small_triangles.h" #include "bounding_box_diagonal.h" #include "doublearea.h" #include "edge_lengths.h" #include "colon.h" #include "faces_first.h" #include #include void igl::collapse_small_triangles( const Eigen::MatrixXd & V, const Eigen::MatrixXi & F, const double eps, Eigen::MatrixXi & FF) { using namespace Eigen; using namespace std; // Compute bounding box diagonal length double bbd = bounding_box_diagonal(V); MatrixXd l; edge_lengths(V,F,l); VectorXd dblA; doublearea(l,0.,dblA); // Minimum area tolerance const double min_dblarea = 2.0*eps*bbd*bbd; Eigen::VectorXi FIM = colon(0,V.rows()-1); int num_edge_collapses = 0; // Loop over triangles for(int f = 0;fmaxl) { maxli = e; maxl = l(f,e); } } // Be sure that min and max aren't the same maxli = (minli==maxli?(minli+1)%3:maxli); // Collapse min edge maintaining max edge: i-->j // Q: Why this direction? int i = maxli; int j = ((minli+1)%3 == maxli ? (minli+2)%3: (minli+1)%3); assert(i != minli); assert(j != minli); assert(i != j); FIM(F(f,i)) = FIM(F(f,j)); num_edge_collapses++; } } // Reindex faces MatrixXi rF = F; // Loop over triangles for(int f = 0;f