piecewise_constant_winding_number.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #ifndef IGL_PIECEWISE_CONSTANT_WINDING_NUMBER_H
  9. #define IGL_PIECEWISE_CONSTANT_WINDING_NUMBER_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <vector>
  13. namespace igl
  14. {
  15. // PIECEWISE_CONSTANT_WINDING_NUMBER Determine if a given mesh induces a
  16. // piecewise constant winding number field: Is this mesh valid input to solid
  17. // set operations. **Assumes** that `(V,F)` contains no self-intersections
  18. // (including degeneracies and co-incidences). If there are co-planar and
  19. // co-incident vertex placements, a mesh could _fail_ this combinatorial test
  20. // but still induce a piecewise-constant winding number _geometrically_. For
  21. // example, consider a hemisphere with boundary and then pinch the boundary
  22. // "shut" along a line segment. The **_bullet-proof_** check is to first
  23. // resolve all self-intersections in `(V,F) -> (SV,SF)` (i.e. what the
  24. // `igl::copyleft::cgal::piecewise_constant_winding_number` overload does).
  25. //
  26. // Inputs:
  27. // F #F by 3 list of triangle indices into some (abstract) list of
  28. // vertices V
  29. // uE #uE by 2 list of unique edges indices into V
  30. // uE2E #uE list of lists of indices into directed edges (#F * 3)
  31. // Returns true if the mesh _combinatorially_ induces a piecewise constant
  32. // winding number field.
  33. //
  34. template <
  35. typename DerivedF,
  36. typename DeriveduE,
  37. typename uE2EType>
  38. IGL_INLINE bool piecewise_constant_winding_number(
  39. const Eigen::PlainObjectBase<DerivedF>& F,
  40. const Eigen::PlainObjectBase<DeriveduE>& uE,
  41. const std::vector<std::vector<uE2EType> >& uE2E);
  42. template <typename DerivedF>
  43. IGL_INLINE bool piecewise_constant_winding_number(
  44. const Eigen::PlainObjectBase<DerivedF>& F);
  45. }
  46. #ifndef IGL_STATIC_LIBRARY
  47. # include "piecewise_constant_winding_number.cpp"
  48. #endif
  49. #endif