projected_cdt.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. // Inputs:
  28. // objects list of objects. This should lie on the given plane (P),
  29. // otherwise they are added to the cdt _after_ their non-trivial
  30. // projection
  31. // P plane upon which all objects lie and upon which the CDT is
  32. // conducted
  33. // Outputs:
  34. // vertices list of vertices of the CDT mesh _back on the 3D plane_
  35. // faces list of list of triangle indices into vertices
  36. //
  37. template <typename Kernel, typename Index>
  38. IGL_INLINE void projected_cdt(
  39. const std::vector<CGAL::Object> & objects,
  40. const CGAL::Plane_3<Kernel> & P,
  41. std::vector<CGAL::Point_3<Kernel> >& vertices,
  42. std::vector<std::vector<Index> >& faces);
  43. // Outputs:
  44. // V #V by 3 list of vertices of the CDT mesh _back on the 3D plane_,
  45. // **cast** from the number type of Kernel to the number type of
  46. // DerivedV
  47. // F #F by 3 list of triangle indices into V
  48. template < typename Kernel, typename DerivedV, typename DerivedF>
  49. IGL_INLINE void projected_cdt(
  50. const std::vector<CGAL::Object> & objects,
  51. const CGAL::Plane_3<Kernel> & P,
  52. Eigen::PlainObjectBase<DerivedV> & V,
  53. Eigen::PlainObjectBase<DerivedF> & F);
  54. }
  55. }
  56. }
  57. #ifndef IGL_STATIC_LIBRARY
  58. # include "projected_cdt.cpp"
  59. #endif
  60. #endif