// 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 "outer_hull.h" #include "extract_cells.h" #include "remesh_self_intersections.h" #include "assign.h" #include "../../remove_unreferenced.h" #include #include #include #include #include template < typename DerivedV, typename DerivedF, typename DerivedHV, typename DerivedHF, typename DerivedJ, typename Derivedflip> IGL_INLINE void igl::copyleft::cgal::outer_hull( const Eigen::PlainObjectBase & V, const Eigen::PlainObjectBase & F, Eigen::PlainObjectBase & HV, Eigen::PlainObjectBase & HF, Eigen::PlainObjectBase & J, Eigen::PlainObjectBase & flip) { // Exact types typedef CGAL::Epeck Kernel; typedef Kernel::FT ExactScalar; typedef Eigen::Matrix< ExactScalar, Eigen::Dynamic, Eigen::Dynamic, DerivedHV::IsRowMajor> MatrixXES; // Remesh self-intersections MatrixXES Vr; DerivedHF Fr; DerivedJ Jr; { RemeshSelfIntersectionsParam params; params.stitch_all = true; Eigen::VectorXi I; Eigen::MatrixXi IF; remesh_self_intersections(V, F, params, Vr, Fr, IF, Jr, I); // Merge coinciding vertices into non-manifold vertices. std::for_each(Fr.data(), Fr.data()+Fr.size(), [&I](typename DerivedHF::Scalar& a) { a=I[a]; }); // Remove unreferenced vertices. Eigen::VectorXi UIM; remove_unreferenced(MatrixXES(Vr),DerivedHF(Fr), Vr, Fr, UIM); } // Extract cells for each face Eigen::MatrixXi C; extract_cells(Vr,Fr,C); // Extract faces on ambient cell int num_outer = 0; for(int i = 0;i #include #include #include #include #include #include //#define IGL_OUTER_HULL_DEBUG template < typename DerivedV, typename DerivedF, typename DerivedG, typename DerivedJ, typename Derivedflip> IGL_INLINE void igl::copyleft::cgal::outer_hull_legacy( const Eigen::PlainObjectBase & V, const Eigen::PlainObjectBase & F, Eigen::PlainObjectBase & G, Eigen::PlainObjectBase & J, Eigen::PlainObjectBase & flip) { #ifdef IGL_OUTER_HULL_DEBUG std::cerr << "Extracting outer hull" << std::endl; #endif using namespace Eigen; using namespace std; typedef typename DerivedF::Index Index; Matrix C; typedef Matrix MatrixXV; //typedef Matrix MatrixXF; typedef Matrix MatrixXG; typedef Matrix MatrixXJ; const Index m = F.rows(); // UNUSED: //const auto & duplicate_simplex = [&F](const int f, const int g)->bool //{ // return // (F(f,0) == F(g,0) && F(f,1) == F(g,1) && F(f,2) == F(g,2)) || // (F(f,1) == F(g,0) && F(f,2) == F(g,1) && F(f,0) == F(g,2)) || // (F(f,2) == F(g,0) && F(f,0) == F(g,1) && F(f,1) == F(g,2)) || // (F(f,0) == F(g,2) && F(f,1) == F(g,1) && F(f,2) == F(g,0)) || // (F(f,1) == F(g,2) && F(f,2) == F(g,1) && F(f,0) == F(g,0)) || // (F(f,2) == F(g,2) && F(f,0) == F(g,1) && F(f,1) == F(g,0)); //}; #ifdef IGL_OUTER_HULL_DEBUG cout<<"outer hull..."< MatrixX2I; typedef Matrix VectorXI; //typedef Matrix Vector3F; MatrixX2I E,uE; VectorXI EMAP; vector > uE2E; unique_edge_map(F,E,uE,EMAP,uE2E); #ifdef IGL_OUTER_HULL_DEBUG for (size_t ui=0; ui > uE2oE; std::vector > uE2C; order_facets_around_edges(V, F, uE, uE2E, uE2oE, uE2C); uE2E = uE2oE; VectorXI diIM(3*m); for (auto ue : uE2E) { for (size_t i=0; i > > TT,_1; triangle_triangle_adjacency(E,EMAP,uE2E,false,TT,_1); VectorXI counts; #ifdef IGL_OUTER_HULL_DEBUG cout<<"facet components..."< FH(m,false); vector EH(3*m,false); vector vG(ncc); vector vJ(ncc); vector vIM(ncc); //size_t face_count = 0; for(size_t id = 0;id g(ncc,0); // place order of each face in its respective component for(Index f = 0;f Q; Q.push(f+0*m); Q.push(f+1*m); Q.push(f+2*m); flip(f) = f_flip; //std::cout << "face " << face_count++ << ": " << f << std::endl; //std::cout << "f " << F.row(f).array()+1 << std::endl; //cout<<"flip("< "<<(nf+1)<<", |"<< // di[EMAP(e)][diIM(e)]<<" - "< "<<(nf+1)<= 0) { max_ne = uE2E[EMAP(e)][nfei]; } if(max_ne>=0) { // face of neighbor const int nf = max_ne%m; #ifdef IGL_OUTER_HULL_DEBUG if(!FH[nf]) { // first time seeing face cout<<(f+1)<<" --> "<<(nf+1)< & V, const MatrixXG & A, const MatrixXG & B)->bool { const auto & bounding_box = []( const Eigen::PlainObjectBase & V, const MatrixXG & F)-> DerivedV { DerivedV BB(2,3); BB<< 1e26,1e26,1e26, -1e26,-1e26,-1e26; const size_t m = F.rows(); for(size_t f = 0;f0 || (ABB.row(0)-BBB.row(1)).maxCoeff()>0 ) { // bounding boxes do not overlap return false; } else { return true; } }; // Reject components which are completely inside other components vector keep(ncc,true); size_t nG = 0; // This is O( ncc * ncc * m) for(size_t id = 0;id unresolved; for(size_t oid = 0;oid, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::copyleft::cgal::outer_hull_legacy< Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > &, Eigen::PlainObjectBase > &, Eigen::PlainObjectBase > &); template void igl::copyleft::cgal::outer_hull_legacy< Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::copyleft::cgal::outer_hull_legacy, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::copyleft::cgal::outer_hull_legacy, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif