piecewise_constant_winding_number.cpp 1.3 KB

1234567891011121314151617181920212223242526272829
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #include "piecewise_constant_winding_number.h"
  9. #include "../../piecewise_constant_winding_number.h"
  10. #include "remesh_self_intersections.h"
  11. #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
  12. #include <algorithm>
  13. template < typename DerivedV, typename DerivedF>
  14. IGL_INLINE bool igl::piecewise_constant_winding_number(
  15. const Eigen::PlainObjectBase<DerivedV> & V,
  16. const Eigen::PlainObjectBase<DerivedF> & F)
  17. {
  18. Eigen::Matrix<CGAL::Epeck::FT,Eigen::Dynamic,3> VV;
  19. Eigen::Matrix<typename DerivedF::Scalar,Eigen::Dynamic,3> FF;
  20. Eigen::Matrix<typename DerivedF::Index,Eigen::Dynamic,2> IF;
  21. Eigen::Matrix<typename DerivedF::Index,Eigen::Dynamic,1> J;
  22. Eigen::Matrix<typename DerivedV::Index,Eigen::Dynamic,1> UIM,IM;
  23. // resolve intersections
  24. remesh_self_intersections(V,F,{},VV,FF,IF,J,IM);
  25. // _apply_ duplicate vertex mapping IM to FF
  26. for_each(FF.data(),FF.data()+FF.size(),[&IM](int & a){a=IM(a);});
  27. return piecewise_constant_winding_number(FF);
  28. }