9#include <kernel/geometry/mesh_part.hpp>
10#include <kernel/util/tiny_algebra.hpp>
11#include <kernel/util/xml_scanner.hpp>
30 template<
typename Mesh_>
43 typedef typename VertexSetType::CoordType
CoordType;
52 virtual std::size_t
bytes()
const
54 return std::size_t(0);
209 virtual void write(std::ostream& os,
const String& sindent)
const = 0;
215 template<
bool enable_>
216 struct ImplicitChartHelper
218 template<
typename CT_,
typename MT_,
typename PT_>
219 static bool adapt(
const CT_&, MT_&,
const PT_&)
224 template<
typename CT_,
typename WP_>
225 static bool project(
const CT_&, WP_&)
232 struct ImplicitChartHelper<true>
234 template<
typename CT_,
typename MT_,
typename PT_>
235 static bool adapt(
const CT_& chart, MT_& mesh,
const PT_& part)
239 if(!chart.can_implicit())
243 chart.project_meshpart(mesh, part);
249 template<
typename CT_,
typename WP_>
250 static bool project(
const CT_& chart, WP_& wp)
252 chart.project_point(wp);
257 template<
bool enable_>
258 struct ExplicitChartHelper
260 template<
typename CT_,
typename MT_,
typename PT_>
261 static bool adapt(
const CT_&, MT_&,
const PT_&)
266 template<
typename CT_,
typename WP_,
typename PP_>
267 static bool map(
const CT_&, WP_&,
const PP_&)
274 struct ExplicitChartHelper<true>
276 template<
typename CT_,
typename MT_,
typename PT_>
277 static bool adapt(
const CT_& chart, MT_& mesh,
const PT_& part)
280 typedef typename CT_::WorldPoint WorldPoint;
282 typedef typename CT_::ParamPoint ParamPoint;
285 typedef typename MT_::VertexSetType VertexSetType;
288 typedef typename PT_::AttributeSetType AttributeSetType;
292 if(!chart.can_explicit())
296 const AttributeSetType* attrib = part.find_attribute(
"param");
297 if(attrib ==
nullptr)
301 int attrib_dim = attrib->get_dimension();
302 XASSERTM(attrib_dim == CT_::param_dim,
"Invalid chart attribute dimension");
305 VertexSetType& vtx = mesh.get_vertex_set();
308 const TargetSet& vidx = part.template get_target_set<0>();
311 Index num_vtx = vidx.get_num_entities();
312 for(Index i(0); i < num_vtx; ++i)
316 reinterpret_cast< WorldPoint&
>(vtx[vidx[i]]),
317 *
reinterpret_cast<const ParamPoint*
>(attrib->raw_at(i))
325 template<
typename CT_,
typename WP_,
typename PP_>
326 static bool map(
const CT_& chart, WP_& wp,
const PP_& pp)
328 chart.map_param(wp, pp);
351 template<
typename Derived_,
typename Mesh_,
typename Traits_>
393 Derived_&
cast() {
return static_cast<Derived_&
>(*this);}
396 const Derived_&
cast()
const {
return static_cast<const Derived_&
>(*this);}
423 XASSERTM(MeshType::world_dim ==
world_dim,
"Mesh/Chart world dimension mismatch");
426 if(Intern::ExplicitChartHelper<is_explicit>::adapt(
cast(), mesh, part))
430 if(Intern::ImplicitChartHelper<is_implicit>::adapt(
cast(), mesh, part))
434 XABORTM(
"No mesh adaption possible!");
452 XABORTM(
"Adaption of MeshPart not possible yet");
463 pp.template copy_n<param_dim>(param);
464 Intern::ExplicitChartHelper<is_explicit>::map(
cast(), wp, pp);
475 Intern::ImplicitChartHelper<is_implicit>::project(
cast(), wp);
482 return (this->
cast()).compute_dist(point);
488 return (this->
cast()).compute_dist(point, grad_dist);
494 return (this->
cast()).compute_signed_dist(point);
500 return (this->
cast()).compute_signed_dist(point, grad_dist);
#define XABORTM(msg)
Abortion macro definition with custom message.
#define ASSERTM(expr, msg)
Debug-Assertion macro definition with custom message.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
virtual void adapt(MeshType &mesh, const PartType &meshpart) const =0
Adapts a mesh using this chart.
virtual void adapt(PartType &mesh, const PartType &meshpart) const =0
Adapts a mesh part using this chart.
virtual String get_type() const =0
Writes the type as String.
virtual CoordType signed_dist(const WorldPoint &point) const =0
Computes the signed distance of a point to this chart.
virtual CoordType signed_dist(const WorldPoint &point, WorldPoint &grad_dist) const =0
Computes the signed distance of a point to this chart.
virtual WorldPoint project(const WorldPoint &point) const =0
Projects a point onto the chart.
virtual bool can_explicit() const =0
Specifies whether the chart can perform explicit projection.
MeshType::VertexSetType VertexSetType
our vertex set type
virtual bool can_implicit() const =0
Specifies whether the chart can perform implicit projection.
virtual CoordType dist(const WorldPoint &point) const =0
Computes the distance of a point to this chart.
virtual std::size_t bytes() const
MeshPart< Mesh_ > PartType
our mesh part type
VertexSetType::CoordType CoordType
out coordinate type
Mesh_ MeshType
our mesh type
virtual void write(std::ostream &os, const String &sindent) const =0
Writes the Chart into a stream in XML format.
virtual WorldPoint map(const WorldPoint ¶m) const =0
Maps a parameter to a world point.
virtual CoordType dist(const WorldPoint &point, WorldPoint &grad_dist) const =0
Computes the distance of a point to this chart.
VertexSetType::VertexType WorldPoint
Type of a single vertex.
virtual void transform(const WorldPoint &origin, const WorldPoint &angles, const WorldPoint &offset)=0
Applies a "proper rigid" transformation onto the chart.
Chart CRTP base-class template.
const Derived_ & cast() const
Casts this to its true type.
Derived_ & cast()
Casts this to its true type.
static constexpr int world_dim
the world dimension of this chart
virtual WorldPoint project(const WorldPoint &point) const override
Projects a point onto the chart.
BaseClass::PartType PartType
mesh-part type
static constexpr int param_dim
the parameter dimension of this chart
virtual CoordType dist(const WorldPoint &point) const override
Computes the distance of a point to this chart.
ChartBase< Mesh_ > BaseClass
base-class type
virtual bool can_explicit() const override
Specifies whether the chart can perform explicit projection.
virtual WorldPoint map(const WorldPoint ¶m) const override
Maps a parameter to a world point.
Tiny::Vector< CoordType, param_dim > ParamPoint
out parameter type
static constexpr bool is_implicit
specifies whether this chart is implicit
virtual void adapt(PartType &parent_meshpart, const PartType &meshpart) const override
Adapts a whole MeshPart referring to another MeshPart.
static constexpr bool is_explicit
specifies whether this chart is explicit
virtual CoordType dist(const WorldPoint &point, WorldPoint &grad_dist) const override
virtual bool can_implicit() const override
Specifies whether the chart can perform implicit projection.
PartType::AttributeSetType AttributeSetType
attribute type of our mesh-part
virtual CoordType signed_dist(const WorldPoint &point) const override
Computes the signed distance of a point to this chart.
BaseClass::WorldPoint WorldPoint
our world point type
virtual CoordType signed_dist(const WorldPoint &point, WorldPoint &grad_dist) const override
VertexSetType::CoordType CoordType
coordinate type
Traits_ TraitsType
traits type
MeshType::VertexSetType VertexSetType
vertex set type of our mesh
virtual void adapt(MeshType &mesh, const PartType &part) const override
Adapts a whole MeshPart.
BaseClass::MeshType MeshType
mesh type
Container for saving data related to mesh entities.
Class template for partial meshes.
String class implementation.
Tiny Vector class template.
std::uint64_t Index
Index data type.