17#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
18#include <CGAL/Simple_cartesian.h>
19#include <CGAL/Surface_mesh/Surface_mesh.h>
26 template <
typename dealiiFace,
typename CGAL_Mesh>
29 const dealiiFace &face,
30 const std::map<unsigned int, typename CGAL_Mesh::Vertex_index> &deal2cgal,
32 const bool clockwise_ordering =
true)
34 const auto reference_cell_type = face->reference_cell();
35 std::vector<typename CGAL_Mesh::Vertex_index> indices;
39 mesh.add_edge(deal2cgal.at(face->vertex_index(0)),
40 deal2cgal.at(face->vertex_index(1)));
42 if (clockwise_ordering)
43 std::reverse(indices.begin(), indices.end());
47 indices = {deal2cgal.at(face->vertex_index(0)),
48 deal2cgal.at(face->vertex_index(1)),
49 deal2cgal.at(face->vertex_index(2))};
51 if (clockwise_ordering)
52 std::reverse(indices.begin(), indices.end());
57 if (clockwise_ordering)
59 indices = {deal2cgal.at(face->vertex_index(0)),
60 deal2cgal.at(face->vertex_index(2)),
61 deal2cgal.at(face->vertex_index(3)),
62 deal2cgal.at(face->vertex_index(1))};
66 indices = {deal2cgal.at(face->vertex_index(0)),
67 deal2cgal.at(face->vertex_index(1)),
68 deal2cgal.at(face->vertex_index(3)),
69 deal2cgal.at(face->vertex_index(2))};
75 const auto new_face = mesh.add_face(indices);
76 Assert(new_face != mesh.null_face(),
78 "CGAL encountered a orientation problem that it "
79 "was not able to solve."));
84 template <
typename dealiiFace,
typename CGAL_Mesh>
87 const dealiiFace &cell,
88 std::map<unsigned int, typename CGAL_Mesh::Vertex_index> &deal2cgal,
91 for (
const auto i : cell->vertex_indices())
93 if (deal2cgal.find(cell->vertex_index(i)) == deal2cgal.end())
95 deal2cgal[cell->vertex_index(i)] =
96 mesh.add_vertex(CGALWrappers::dealii_point_to_cgal_point<
97 typename CGAL_Mesh::Point>(cell->vertex(i)));
109 template <
typename CGALPo
intType,
int dim,
int spacedim>
113 const Mapping<dim, spacedim> &
mapping,
114 CGAL::Surface_mesh<CGALPointType> &mesh)
117 using Mesh = CGAL::Surface_mesh<CGALPointType>;
119 std::map<unsigned int, typename Mesh::Vertex_index> deal2cgal;
125 CGALWrappers::dealii_point_to_cgal_point<CGALPointType>(vertices[i]));
130 add_facet(cell, deal2cgal, mesh);
150 bool face_is_clockwise_oriented =
155 face_is_clockwise_oriented = !face_is_clockwise_oriented;
156 add_facet(cell->
face(f), deal2cgal, mesh, face_is_clockwise_oriented);
162 template <
typename CGALPo
intType,
int dim,
int spacedim>
165 const ::Triangulation<dim, spacedim> &tria,
166 CGAL::Surface_mesh<CGALPointType> &mesh)
168 Assert(tria.n_cells() > 0,
170 "Triangulation cannot be empty upon calling this function."));
173 "The surface mesh must be empty upon calling this function."));
176 using Mesh = CGAL::Surface_mesh<CGALPointType>;
177 using Vertex_index =
typename Mesh::Vertex_index;
179 std::map<unsigned int, Vertex_index> deal2cgal;
180 if constexpr (dim == 2)
182 for (
const auto &cell : tria.active_cell_iterators())
184 map_vertices(cell, deal2cgal, mesh);
185 add_facet(cell, deal2cgal, mesh);
188 else if constexpr (dim == 3 && spacedim == 3)
190 for (
const auto &cell : tria.active_cell_iterators())
194 if (cell->
face(f)->at_boundary())
196 map_vertices(cell->
face(f), deal2cgal, mesh);
197 add_facet(cell->
face(f),
218# include "cgal/surface_mesh.inst"
TriaIterator< TriaAccessor< dim - 1, dim, spacedim > > face(const unsigned int i) const
virtual boost::container::small_vector< Point< spacedim >, ReferenceCells::max_n_vertices< dim >() > get_vertices(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const
std_cxx20::ranges::iota_view< unsigned int, unsigned int > vertex_indices() const
unsigned int n_vertices() const
std_cxx20::ranges::iota_view< unsigned int, unsigned int > face_indices() const
unsigned int vertex_index(const unsigned int i) const
ReferenceCell< structdim > reference_cell() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_ASSERT_UNREACHABLE()
static ::ExceptionBase & ExcImpossibleInDimSpacedim(int arg1, int arg2)
#define Assert(cond, exc)
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
TriaIterator< CellAccessor< dim, spacedim > > cell_iterator
bool face_orientation(const unsigned int face) const
MappingQ< dim, spacedim > StaticMappingQ1< dim, spacedim >::mapping
void dealii_tria_to_cgal_surface_mesh(const ::Triangulation< dim, spacedim > &triangulation, CGAL::Surface_mesh< CGALPointType > &mesh)
void dealii_cell_to_cgal_surface_mesh(const typename ::Triangulation< dim, spacedim >::cell_iterator &cell, const ::Mapping< dim, spacedim > &mapping, CGAL::Surface_mesh< CGALPointType > &mesh)
constexpr ReferenceCell< 3 > Hexahedron
constexpr ReferenceCell< 2 > Quadrilateral
constexpr ReferenceCell< 1 > Line
constexpr ReferenceCell< 2 > Triangle