21 #ifndef FUB_GEOMETRY_POLYMORPHIC_GEOMETRY_HPP
22 #define FUB_GEOMETRY_POLYMORPHIC_GEOMETRY_HPP
31 template <std::
size_t Rank,
typename G>
36 std::unique_ptr<Geometry<Rank>>
Clone()
const override {
37 return std::make_unique<GeometryWrapper>(
base_);
41 return base_.ComputeDistanceTo(x);
54 std::enable_if_t<!std::is_base_of<Geometry<Rank>, G>::value>* =
nullptr,
55 std::enable_if_t<!std::is_same<G, PolymorphicGeometry>::value>* =
nullptr>
61 std::enable_if_t<std::is_base_of<Geometry<Rank>, G>::value>* =
nullptr,
62 std::enable_if_t<!std::is_same<G, PolymorphicGeometry>::value>* =
nullptr>
64 :
base_{std::make_unique<G>(geometry)} {}
67 return base_->ComputeDistanceTo(x);
70 std::unique_ptr<Geometry<Rank>>
Clone()
const override {
71 return base_->Clone();
78 std::unique_ptr<Geometry<Rank>>
base_;
Definition: PolymorphicGeometry.hpp:47
PolymorphicGeometry(const PolymorphicGeometry &other)
Definition: PolymorphicGeometry.hpp:49
Geometry< Rank > & Base() noexcept
Definition: PolymorphicGeometry.hpp:74
PolymorphicGeometry(const G &geometry)
Definition: PolymorphicGeometry.hpp:56
std::unique_ptr< Geometry< Rank > > base_
Definition: PolymorphicGeometry.hpp:78
double ComputeDistanceTo(const std::array< double, Rank > &x) const override
Computes the minimum distance between geometry and point x.
Definition: PolymorphicGeometry.hpp:66
const Geometry< Rank > & Base() const noexcept
Definition: PolymorphicGeometry.hpp:75
std::unique_ptr< Geometry< Rank > > Clone() const override
Returns a copy of the concrete geometry as a pointer to the base class.
Definition: PolymorphicGeometry.hpp:70
The fub namespace.
Definition: AnyBoundaryCondition.hpp:31
Definition: PolymorphicGeometry.hpp:32
GeometryWrapper(const G &base)
Definition: PolymorphicGeometry.hpp:33
G base_
Definition: PolymorphicGeometry.hpp:44
double ComputeDistanceTo(const std::array< double, Rank > &x) const override
Computes the minimum distance between geometry and point x.
Definition: PolymorphicGeometry.hpp:40
std::unique_ptr< Geometry< Rank > > Clone() const override
Returns a copy of the concrete geometry as a pointer to the base class.
Definition: PolymorphicGeometry.hpp:36
GeometryWrapper(G &&base)
Definition: PolymorphicGeometry.hpp:34
Definition: geometry/Geometry.hpp:29
This file adds basic type traits utilities which are not yet implemented in all standard libraries.