// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2016 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 "subdivide_segments.h" #include "row_to_point.h" #include "assign_scalar.h" #include "../../unique.h" #include "../../list_to_matrix.h" #include #include #include #include #include template < typename DerivedV, typename DerivedE, typename Kernel, typename DerivedVI, typename DerivedEI, typename DerivedJ, typename DerivedIM> IGL_INLINE void igl::copyleft::cgal::subdivide_segments( const Eigen::PlainObjectBase & V, const Eigen::PlainObjectBase & E, const std::vector > > & _steiner, Eigen::PlainObjectBase & VI, Eigen::PlainObjectBase & EI, Eigen::PlainObjectBase & J, Eigen::PlainObjectBase & IM) { using namespace Eigen; using namespace igl; using namespace std; // Exact scalar type typedef Kernel K; typedef typename Kernel::FT EScalar; typedef CGAL::Segment_2 Segment_2; typedef CGAL::Point_2 Point_2; typedef Matrix MatrixXE; // non-const copy std::vector > > steiner = _steiner; // Convert vertex positions to exact kernel MatrixXE VE(V.rows(),V.cols()); for(int i = 0;i S; std::vector > vEI; std::vector vJ; for(int i = 0;i(VE,E(i,0)); std::sort( steiner[i].begin(), steiner[i].end(), [&s](const Point_2 & A, const Point_2 & B)->bool { return (A-s).squared_length() < (B-s).squared_length(); }); } // remove duplicates steiner[i].erase( std::unique(steiner[i].begin(), steiner[i].end()), steiner[i].end()); { int s = E(i,0); // legs to each steiner in order for(int j = 1;j vVES,_1; for(int i = 0;i(VE,i)); } vVES.insert(vVES.end(),S.begin(),S.end()); std::vector vA,vIM; igl::unique(vVES,_1,vA,vIM); // Push indices back into vVES for_each(vIM.data(),vIM.data()+vIM.size(),[&vA](size_t & i){i=vA[i];}); list_to_matrix(vIM,IM); } }