8#include <kernel/geometry/atlas/chart.hpp>
9#include <kernel/util/math.hpp>
10#include <kernel/util/string.hpp>
11#include <kernel/geometry/cgal.hpp>
12#include <kernel/runtime.hpp>
45 template<
typename Mesh_>
48 public ChartCRTP<CGALSurfaceMesh<Mesh_>, Mesh_, CGALSurfaceMeshTraits>
79 cgal{filename, file_mode}
86 static std::unique_ptr<CGALSurfaceMesh<Mesh_>> create_cgal_surface_mesh(std::istream& file,
Geometry::CGALFileMode file_mode)
88 return std::make_unique<CGALSurfaceMesh<Mesh_>>(file, file_mode);
95 std::size_t
bytes()
const override
103 return "CGALSurfaceMesh";
117 void write(std::ostream& ,
const String& )
const override
119 XABORTM(
"Not implemented yet");
165 void project_meshpart(Mesh_& mesh,
const MeshPart<Mesh_>& meshpart)
const
171 if(num_facets ==
Index(0))
177 const auto& ts_verts(meshpart.template get_target_set<0>());
180 auto& vtx(mesh.get_vertex_set());
184 for(
Index i = 0; i < num_verts; ++i)
186 project_point(vtx[ts_verts[i]]);
204 project_point(projected_point);
207 grad_distance = (projected_point - point);
211 if(grad_distance.norm_euclid() < Math::eps<CoordType>())
217 grad_distance.normalize();
226 return cgal.
point_inside(point[0], point[1], point[2]) ? -compute_dist(point) : compute_dist(point);
232 return cgal.
point_inside(point[0], point[1], point[2]) ? -compute_dist(point, grad_distance) : compute_dist(point, grad_distance);
253 XABORTM(
"ERROR: Can not create a CGALSurfaceMesh without CGAL enabled");
268 XABORTM(
"Thou shalt not arrive here!");
273 XABORTM(
"Thou shalt not arrive here!");
278 XABORTM(
"Thou shalt not arrive here!");
283 XABORTM(
"Thou shalt not arrive here!");
289 XABORTM(
"Thou shalt not arrive here!");
295 XABORTM(
"Thou shalt not arrive here!");
301 XABORTM(
"Thou shalt not arrive here!");
307 XABORTM(
"Thou shalt not arrive here!");
313 XABORTM(
"Thou shalt not arrive here!");
319 return "CGALSurfaceMeshDummy";
#define XABORTM(msg)
Abortion macro definition with custom message.
Boundary description by a cgal based surface in 3d.
ChartBase< Mesh_ > BaseClass
The CRTP base class.
BaseClass::PartType PartType
Parttype of Baseclass.
void transform(const WorldPoint &, const WorldPoint &, const WorldPoint &) override
Applies a "proper rigid" transformation onto the chart.
BaseClass::WorldPoint WorldPoint
Vector type for world points.
BaseClass::CoordType CoordType
Floating point type for coordinates.
CoordType signed_dist(const WorldPoint &) const override
Computes the signed distance of a point to this chart.
void adapt(PartType &, const PartType &) const override
Adapts a mesh part using this chart.
WorldPoint project(const WorldPoint &) const override
Projects a point onto the chart.
static constexpr int shape_dim
Dimension of the CGAL mesh.
String get_type() const override
Writes the type as String.
BaseClass::MeshType MeshType
Meshtype of Baseclass.
WorldPoint map(const WorldPoint &) const override
Maps a parameter to a world point.
void write(std::ostream &, const String &) const override
Writes the Chart into a stream in XML format.
void adapt(MeshType &, const PartType &) const override
Adapts a mesh using this chart.
bool can_implicit() const override
Specifies whether the chart can perform implicit projection.
bool can_explicit() const override
Specifies whether the chart can perform explicit projection.
CoordType dist(const WorldPoint &) const override
Computes the distance of a point to this chart.
CoordType dist(const WorldPoint &, WorldPoint &) const override
Computes the distance of a point to this chart.
CoordType signed_dist(const WorldPoint &, WorldPoint &) const override
Computes the signed distance of a point to this chart.
virtual std::size_t bytes() const
VertexSetType::CoordType CoordType
out coordinate type
Mesh_ MeshType
our mesh type
VertexSetType::VertexType WorldPoint
Type of a single vertex.
Chart CRTP base-class template.
Wrapper for the CGAL Library.
void transform(const TransformMatrix &trafo_mat, const PointType &translation, DataType scale=DataType(1))
bool point_inside(DataType x, DataType y, DataType z) const
Check whether a point is inside the Polyhedron defined at objects' construction.
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...
std::size_t bytes() const
Returns the size in bytes.
PointType closest_point(const PointType &point) const
Returns the nearest point regarding on all input primitives defined at objects' construction.
Class template for partial meshes.
Index get_num_entities(int dim) const
Returns the number of entities.
String class implementation.
Tiny Matrix class template.
CUDA_HOST_DEVICE Matrix & set_rotation_3d(T_ yaw, T_ pitch, T_ roll)
Sets this matrix to a 3D yaw-pitch-roll rotation matrix.
Tiny Vector class template.
T_ sqrt(T_ x)
Returns the square-root of a value.
std::uint64_t Index
Index data type.
static constexpr int world_dim
This is a world_dim dimensional object.
static constexpr bool is_implicit
We support implicit projection.
static constexpr int param_dim
If there was a parametrization, it would be the object's shape dim.
static constexpr bool is_explicit
No explicit map is available in general.