projected_cdt.h 2.2 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_PROJECTED_CDT_H
  9. #define IGL_COPYLEFT_CGAL_PROJECTED_CDT_H
  10. #include "../../igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <CGAL/Plane_3.h>
  13. #include <CGAL/Point_3.h>
  14. #include <vector>
  15. namespace igl
  16. {
  17. namespace copyleft
  18. {
  19. namespace cgal
  20. {
  21. // Given a list of objects (e.g., resulting from intersecting a triangle
  22. // with many other triangles), construct a constrained Delaunay
  23. // triangulation on a given plane (P), by inersting constraints for each
  24. // object projected onto that plane.
  25. //
  26. // Inputs:
  27. // objects list of objects. This should lie on the given plane (P),
  28. // otherwise they are added to the cdt _after_ their non-trivial
  29. // projection
  30. // P plane upon which all objects lie and upon which the CDT is
  31. // conducted
  32. // Outputs:
  33. // vertices list of vertices of the CDT mesh _back on the 3D plane_
  34. // faces list of list of triangle indices into vertices
  35. //
  36. template <typename Kernel, typename Index>
  37. IGL_INLINE void projected_cdt(
  38. const std::vector<CGAL::Object> & objects,
  39. const CGAL::Plane_3<Kernel> & P,
  40. std::vector<CGAL::Point_3<Kernel> >& vertices,
  41. std::vector<std::vector<Index> >& faces);
  42. // Outputs:
  43. // V #V by 3 list of vertices of the CDT mesh _back on the 3D plane_,
  44. // **cast** from the number type of Kernel to the number type of
  45. // DerivedV
  46. // F #F by 3 list of triangle indices into V
  47. template < typename Kernel, typename DerivedV, typename DerivedF>
  48. IGL_INLINE void projected_cdt(
  49. const std::vector<CGAL::Object> & objects,
  50. const CGAL::Plane_3<Kernel> & P,
  51. Eigen::PlainObjectBase<DerivedV> & V,
  52. Eigen::PlainObjectBase<DerivedF> & F);
  53. }
  54. }
  55. }
  56. #ifndef IGL_STATIC_LIBRARY
  57. # include "projected_cdt.cpp"
  58. #endif
  59. #endif