projected_cdt.h 2.3 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 <CGAL/Object.h>
  15. #include <vector>
  16. namespace igl
  17. {
  18. namespace copyleft
  19. {
  20. namespace cgal
  21. {
  22. /// Given a list of objects (e.g., resulting from intersecting a triangle
  23. /// with many other triangles), construct a constrained Delaunay
  24. /// triangulation on a given plane (P), by inersting constraints for each
  25. /// object projected onto that plane.
  26. ///
  27. /// @param[in] 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. /// @param[in] P plane upon which all objects lie and upon which the CDT is
  31. /// conducted
  32. /// @param[out] vertices list of vertices of the CDT mesh _back on the 3D plane_
  33. /// @param[out] faces list of list of triangle indices into vertices
  34. ///
  35. template <typename Kernel, typename Index>
  36. IGL_INLINE void projected_cdt(
  37. const std::vector<CGAL::Object> & objects,
  38. const CGAL::Plane_3<Kernel> & P,
  39. std::vector<CGAL::Point_3<Kernel> >& vertices,
  40. std::vector<std::vector<Index> >& faces);
  41. /// \overload
  42. ///
  43. /// @param[out] 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. /// @param[out] 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