// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2013 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 "project_to_line_segment.h" #include "project_to_line.h" #include template < typename DerivedP, typename DerivedS, typename DerivedD, typename Derivedt, typename DerivedsqrD> IGL_INLINE void igl::project_to_line_segment( const Eigen::PlainObjectBase & P, const Eigen::PlainObjectBase & S, const Eigen::PlainObjectBase & D, Eigen::PlainObjectBase & t, Eigen::PlainObjectBase & sqrD) { project_to_line(P,S,D,t,sqrD); const int np = P.rows(); // loop over points and fix those that projected beyond endpoints #pragma omp parallel for if (np>10000) for(int p = 0;p Pp = P.row(p); if(t(p)<0) { sqrD(p) = (Pp-S).squaredNorm(); t(p) = 0; }else if(t(p)>1) { sqrD(p) = (Pp-D).squaredNorm(); t(p) = 1; } } } #ifdef IGL_STATIC_LIBRARY // Explicit template specialization template void igl::project_to_line_segment, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::project_to_line_segment, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::project_to_line_segment, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif