// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2015 Qingnan Zhou // // 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 "component_inside_component.h" #include "order_facets_around_edge.h" #include "../../LinSpaced.h" #include "points_inside_component.h" #include #include #include #include #include #include #include #include template IGL_INLINE bool igl::copyleft::cgal::component_inside_component( const Eigen::PlainObjectBase& V1, const Eigen::PlainObjectBase& F1, const Eigen::PlainObjectBase& I1, const Eigen::PlainObjectBase& V2, const Eigen::PlainObjectBase& F2, const Eigen::PlainObjectBase& I2) { if (F1.rows() <= 0 || I1.rows() <= 0 || F2.rows() <= 0 || I2.rows() <= 0) { throw "Component inside test cannot be done on empty component!"; } const Eigen::Vector3i& f = F1.row(I1(0, 0)); const Eigen::Matrix query( (V1(f[0],0) + V1(f[1],0) + V1(f[2],0))/3.0, (V1(f[0],1) + V1(f[1],1) + V1(f[2],1))/3.0, (V1(f[0],2) + V1(f[1],2) + V1(f[2],2))/3.0); Eigen::VectorXi inside; igl::copyleft::cgal::points_inside_component(V2, F2, I2, query, inside); assert(inside.size() == 1); return inside[0]; } template IGL_INLINE bool igl::copyleft::cgal::component_inside_component( const Eigen::PlainObjectBase& V1, const Eigen::PlainObjectBase& F1, const Eigen::PlainObjectBase& V2, const Eigen::PlainObjectBase& F2) { if (F1.rows() <= 0 || F2.rows() <= 0) { throw "Component inside test cannot be done on empty component!"; } Eigen::VectorXi I1(F1.rows()), I2(F2.rows()); I1 = igl::LinSpaced(F1.rows(), 0, F1.rows()-1); I2 = igl::LinSpaced(F2.rows(), 0, F2.rows()-1); return igl::copyleft::cgal::component_inside_component(V1, F1, I1, V2, F2, I2); } #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation template bool igl::copyleft::cgal::component_inside_component< Eigen::Matrix, Eigen::Matrix< int, -1, -1, 0, -1, -1>, Eigen::Matrix< int, -1, -1, 0, -1, -1> > ( Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); template bool igl::copyleft::cgal::component_inside_component< Eigen::Matrix, Eigen::Matrix< int, -1, -1, 0, -1, -1> > ( Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); #endif