// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2022 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 "split_nonmanifold.h" #include "connected_components.h" #include "remove_unreferenced.h" #include "find.h" #include "ismember_rows.h" template < typename DerivedF, typename DerivedSF, typename DerivedSVI > IGL_INLINE void igl::split_nonmanifold( const Eigen::MatrixBase & F, Eigen::PlainObjectBase & SF, Eigen::PlainObjectBase & SVI) { // Number of faces const int m = F.rows(); // For moment aact like everything will be split SF.resize(m,3); { int k =0; for(int j = 0;j<3;j++) { for(int i = 0;i I; Eigen::VectorXi J; igl::ismember_rows(FE,FE_flip,I,J); // Just keep those find const auto II = igl::find(I); Eigen::MatrixXi EI = E(II,Eigen::all); Eigen::VectorXi JI = J(II); Eigen::MatrixXi EJI = E(JI,Eigen::all); Eigen::MatrixXi EJI_flip = EJI.rowwise().reverse(); // Build adjacency matrix std::vector > Aijv; Aijv.reserve(EI.size()); for(int i = 0;i A1(m*3,m*3); A1.setFromTriplets(Aijv.begin(),Aijv.end()); // For some reason I can't write `A = A1 && A1.transpose();` Eigen::SparseMatrix A1T = A1.transpose(); Eigen::SparseMatrix A = A1 && A1T; Eigen::VectorXi K; { Eigen::VectorXi _; igl::connected_components(A,K,_); } // Remap by components for(int j = 0;j<3;j++) { for(int i = 0;i IGL_INLINE void igl::split_nonmanifold( const Eigen::MatrixBase & V, const Eigen::MatrixBase & F, Eigen::PlainObjectBase & SV, Eigen::PlainObjectBase & SF, Eigen::PlainObjectBase & SVI) { igl::split_nonmanifold(F,SF,SVI); SV = V(SVI.derived(),Eigen::all); } #ifdef IGL_STATIC_LIBRARY template void igl::split_nonmanifold, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif