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