// 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 "directed_edge_parents.h" #include "colon.h" #include "setdiff.h" #include template IGL_INLINE void igl::directed_edge_parents( const Eigen::MatrixBase & E, Eigen::PlainObjectBase & P) { using namespace Eigen; using namespace std; typedef Eigen::Matrix VectorT; VectorT I = VectorT::Constant(E.maxCoeff()+1,1,-1); //I(E.col(1)) = 0:E.rows()-1 I(E.col(1).eval()) = colon(0, E.rows()-1); VectorT roots,_; setdiff(E.col(0).eval(),E.col(1).eval(),roots,_); std::for_each(roots.data(),roots.data()+roots.size(),[&](typename VectorT::Scalar r){I(r)=-1;}); P = I(E.col(0).eval()); } #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation template void igl::directed_edge_parents, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&); #endif