// 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 "in_element.h" #include "parallel_for.h" template < typename DerivedV, typename DerivedEle, typename DerivedQ, int DIM, typename DerivedI > IGL_INLINE void igl::in_element( const Eigen::MatrixBase & V, const Eigen::MatrixBase & Ele, const Eigen::MatrixBase & Q, const AABB & aabb, Eigen::PlainObjectBase & I) { const int Qr = Q.rows(); I.setConstant(Qr,1,-1); parallel_for(Qr,[&](const int e) { // find all const auto R = aabb.find(V,Ele,Q.row(e).eval(),true); if(!R.empty()) { I(e) = R[0]; } },10000); } template IGL_INLINE void igl::in_element( const Eigen::MatrixBase & V, const Eigen::MatrixBase & Ele, const Eigen::MatrixBase & Q, const AABB & aabb, Eigen::SparseMatrix & I) { const int Qr = Q.rows(); std::vector > IJV; IJV.reserve(Qr); // #pragma omp parallel for if (Qr>10000) for(int e = 0;e(e,r,1)); } } I.resize(Qr,Ele.rows()); I.setFromTriplets(IJV.begin(),IJV.end()); } #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation template void igl::in_element < Eigen::MatrixXd, Eigen::MatrixXi, Eigen::MatrixXd, 3, Eigen::VectorXi> ( const Eigen::MatrixBase & V, const Eigen::MatrixBase & Ele, const Eigen::MatrixBase & Q, const AABB & aabb, Eigen::PlainObjectBase & I); #endif