9#include <kernel/geometry/mesh_part.hpp>
10#include <kernel/shape.hpp>
11#include <kernel/util/string.hpp>
12#include <kernel/util/tiny_algebra.hpp>
15#if defined(FEAT_HAVE_CGAL) || defined(DOXYGEN)
64 using iterator_category = std::input_iterator_tag;
65 using difference_type =
Index;
66 using value_type = T_;
68 using reference = T_&;
70 using GeneratorType = std::function<std::optional<T_>()>;
73 GeneratorType _generator;
74 std::optional<T_> _current;
83 return _current.value();
88 return _current.value();
93 ASSERT(_current.has_value());
94 _current = _generator();
100 ASSERT(_current.has_value());
106 explicit operator bool()
const
108 return static_cast<bool>(_current);
133 template<
typename DT_>
137 template<
typename DT_>
171 template<
typename DT_>
175 typedef DT_ DataType;
181 bool _expensive_intersection =
false;
252 template<std::
size_t num_verts_>
255 if constexpr(num_verts_ == 2)
259 else if constexpr(num_verts_ == 8)
261 return intersects_hexaedron(
points);
285 const String name(filename +
".off");
286 std::ofstream ofs(name.c_str());
287 if(!(ofs.is_open() && ofs.good()))
289 throw FileError(
"Failed to create '" + name +
"'");
330 template<
typename MeshType_>
333 using MeshType = MeshType_;
334 using DT =
typename MeshType::CoordType;
335 using ShapeType =
typename MeshType::ShapeType;
341 static_assert(ShapeType::dimension == 3);
343 std::vector<PointType> vertices;
347 const auto& vertex_set = mesh.get_vertex_set();
348 const TargetSet& vts = part.template get_target_set<0>();
351 vertices.push_back(vertex_set[vts[i]]);
355 std::vector<std::array<Index, 3>> faces;
357 const auto& v_at_f = mesh.template get_index_set<2, 0>();
358 const TargetSet& fts = part.template get_target_set<2>();
361 if constexpr(std::is_same_v<ShapeType, Shape::Hexahedron>)
364 faces.reserve(2 * num_mesh_faces);
366 if constexpr(std::is_same_v<ShapeType, Shape::Tetrahedron>)
369 faces.reserve(num_mesh_faces);
372 std::array<Index, vertices_per_face> vs;
373 for(
Index i(0); i < num_mesh_faces; i++)
375 for(
int j(0); j < vertices_per_face; j++)
378 Index v = v_at_f(fts[i], j);
385 vs[std::size_t(j)] = k;
391 if constexpr(std::is_same_v<ShapeType, Shape::Hexahedron>)
393 faces.push_back({vs[0], vs[1], vs[2]});
394 faces.push_back({vs[3], vs[2], vs[1]});
396 if constexpr(std::is_same_v<ShapeType, Shape::Tetrahedron>)
398 faces.push_back({vs[0], vs[1], vs[2]});
402 return CGALWrapper<DT>(vertices, faces);
#define ASSERT(expr)
Debug-Assertion macro definition.
#define XABORTM(msg)
Abortion macro definition with custom message.
Base class for file related errors.
Wrapper for arbitrary iterators that produce values.
Adjactor for vertices around a face.
CGALValueIteratorWrapper< Index > image_begin(Index face) const
Adjactor begin.
CGALValueIteratorWrapper< Index > image_end(Index face) const
Adjactor end.
Index get_num_nodes_image() const
Number of vertices.
Index get_num_nodes_domain() const
Number of faces.
CGALVerticesAroundFaceAdjactor(const CGALWrapper< DT_ > *w)
Constructor.
Wrapper for the CGAL Library.
void displace_vertices(const std::vector< PointType > &offsets)
Displace each vertex of the mesh by its given offset.
void _init_wrapper()
initializes tree and inside tester with already initialized polyhedron
std::vector< PointType > points() const
Returns a vector of all points of the surface mesh.
void transform(const TransformMatrix &trafo_mat, const PointType &translation, DataType scale=DataType(1))
Index get_num_entities(int dim) const
Returns the number of entities of dimension dim of the underlying polyhedron.
void write_off(std::ostream &stream) const
Write the surface file to an ostream object.
bool point_inside(DataType x, DataType y, DataType z) const
Check whether a point is inside the Polyhedron defined at objects' construction.
std::vector< PointType > outer_normals_at_faces() const
Returns the outer normals at each surface element.
bool intersects_line(const PointType &a, const PointType &b) const
tests whether the cgal mesh intersects with the line segment a->b
void write_off(const String &filename) const
void _delete_tree()
Delete tree, which also requires to delete the inside tester.
DataType squared_distance(DataType x, DataType y, DataType z) const
Returns the minimun squared distance between the query point and all input primitives defined at obje...
void set_expensive_intersection(bool expensive_test)
Sets whether we do an expensive test for the intersection test or only use boundingboxes.
CGALVerticesAroundFaceAdjactor< DT_ > vertices_around_face() const
Returns an adjactor for vertices around faces of the mesh.
std::size_t bytes() const
Returns the size in bytes.
CGALFeatureNetwork detect_features(DataType critical_angle)
Returns a vector of all feature vertices defined at objects' construction.
Index get_num_vertices() const
Returns the number of vertices of the underlying polyhedron.
CGALWrapper(const CGALWrapper &)=delete
rule of five
PointType closest_point(const PointType &point) const
Returns the nearest point regarding on all input primitives defined at objects' construction.
DataType squared_distance_to_feature(const CGALFeature &f, const PointType &p) const
Returns the minimum squared distance between the query point and the given feature.
bool point_not_outside(DataType x, DataType y, DataType z) const
Check whether a point is inside or on the boundary of the Polyhedron defined at objects' construction...
PointType point(std::uint32_t idx) const
Returns the point of the surface mesh with the given index.
void _parse_mesh(std::istream &file, CGALFileMode file_mode)
read in stream in prescibed file format and preprocess search tree for in/out test
PointType closest_point_on_feature(const CGALFeature &f, const PointType &p) const
Returns the closest point closest to p on the given feature.
Class template for partial meshes.
Index get_num_entities(int dim) const
Returns the number of entities.
Index get_num_entities() const
Returns the number of entities.
String class implementation.
Tiny Matrix class template.
Tiny Vector class template.
std::vector< CGALFeature > CGALFeatureNetwork
A FeatureNetwork is a list of features.
std::vector< std::uint32_t > CGALFeature
A feature is an edge-path on a surface mesh, stored as a list of vertex indices.
@ other
generic/other permutation strategy
std::uint64_t Index
Index data type.
Face traits tag struct template.