insert_into_cdt.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 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_COPYLEFT_CGAL_INSERT_INTO_CDT_H
  9. #define IGL_COPYLEFT_CGAL_INSERT_INTO_CDT_H
  10. #include "../../igl_inline.h"
  11. #include <CGAL/double.h> // Workaround https://github.com/CGAL/cgal/issues/2182 with CGAL 4.10-1
  12. #include <CGAL/Plane_3.h>
  13. #include <CGAL/Constrained_Delaunay_triangulation_2.h>
  14. #include <CGAL/Constrained_triangulation_plus_2.h>
  15. namespace igl
  16. {
  17. namespace copyleft
  18. {
  19. namespace cgal
  20. {
  21. // Given a current 2D constrained Delaunay triangulation (cdt), insert a
  22. // 3D "object" (e.g., resulting from intersecting two triangles) into the
  23. // cdt, by projecting it via the given plane (P) and adding appropriate
  24. // constraints.
  25. //
  26. // Inputs:
  27. // obj CGAL::Object representing a vertex, segment, or (convex)
  28. // polygon. All vertices should lie on the plane P. If not, then this
  29. // adds the _projection_ of this object to the cdt and that might not
  30. // be what you wanted to do.
  31. // P plane obj lies on and upon which the cdt is being performed
  32. // cdt current CDT, see output
  33. // Outputs:
  34. // cdt CDT updated to contain constraints for the given object
  35. //
  36. template <typename Kernel>
  37. IGL_INLINE void insert_into_cdt(
  38. const CGAL::Object & obj,
  39. const CGAL::Plane_3<Kernel> & P,
  40. CGAL::Constrained_triangulation_plus_2<
  41. CGAL::Constrained_Delaunay_triangulation_2<
  42. Kernel,
  43. CGAL::Triangulation_data_structure_2<
  44. CGAL::Triangulation_vertex_base_2<Kernel>,
  45. CGAL::Constrained_triangulation_face_base_2< Kernel>
  46. >,
  47. CGAL::Exact_intersections_tag
  48. >
  49. >
  50. & cdt);
  51. }
  52. }
  53. }
  54. #ifndef IGL_STATIC_LIBRARY
  55. # include "insert_into_cdt.cpp"
  56. #endif
  57. #endif