subdivide_segments.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 Alec Jacobson <alecjacobson@gmail.com>
  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_COPYLEFT_CGAL_SUBDIVIDE_SEGMENTS_H
  9. #define IGL_COPYLEFT_CGAL_SUBDIVIDE_SEGMENTS_H
  10. #include "../../igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <CGAL/Segment_2.h>
  13. #include <CGAL/Point_2.h>
  14. #include <vector>
  15. namespace igl
  16. {
  17. namespace copyleft
  18. {
  19. namespace cgal
  20. {
  21. // Insert steiner points to subdivide a given set of line segments
  22. //
  23. // Inputs:
  24. // V #V by 2 list of vertex positions
  25. // E #E by 2 list of segment indices into V
  26. // steiner #E list of lists of unsorted steiner points (including
  27. // endpoints) along the #E original segments
  28. // Outputs:
  29. // VI #VI by 2 list of output vertex positions, copies of V are always
  30. // the first #V vertices
  31. // EI #EI by 2 list of segment indices into V, #EI ≥ #E
  32. // J #EI list of indices into E revealing "parent segments"
  33. // IM #VI list of indices into VV of unique vertices.
  34. template <
  35. typename DerivedV,
  36. typename DerivedE,
  37. typename Kernel,
  38. typename DerivedVI,
  39. typename DerivedEI,
  40. typename DerivedJ,
  41. typename DerivedIM>
  42. IGL_INLINE void subdivide_segments(
  43. const Eigen::PlainObjectBase<DerivedV> & V,
  44. const Eigen::PlainObjectBase<DerivedE> & E,
  45. const std::vector<std::vector<CGAL::Point_2<Kernel> > > & steiner,
  46. Eigen::PlainObjectBase<DerivedVI> & VI,
  47. Eigen::PlainObjectBase<DerivedEI> & EI,
  48. Eigen::PlainObjectBase<DerivedJ> & J,
  49. Eigen::PlainObjectBase<DerivedIM> & IM);
  50. }
  51. }
  52. }
  53. #ifndef IGL_STATIC_LIBRARY
  54. # include "subdivide_segments.cpp"
  55. #endif
  56. #endif