#ifndef MEDUSA_BITS_DOMAINS_SHAPEUNION_FWD_HPP_ #define MEDUSA_BITS_DOMAINS_SHAPEUNION_FWD_HPP_ #include #include "DomainShape_fwd.hpp" #include /** * @file * Declaration of ShapeUnion class. * * @example test/domains/ShapeUnion_test.cpp */ namespace mm { /** * Class representing a union of two shapes. Used when constructing shapes * for later discretization or obtained implicitly with * DomainShape::operator+(), DomainShape::add() and DomainDiscretization::add(). * * Usage example: * @snippet domains/ShapeUnion_test.cpp ShapeUnion usage example * @sa ShapeUnion, DomainShape, DomainDiscretization * @ingroup domains */ template class ShapeUnion : public DomainShape { deep_copy_unique_ptr> sh1, ///< First shape in the union. sh2; ///< Second shape in the union. public: using typename DomainShape::scalar_t; using DomainShape::dim; using DomainShape::discretizeBoundaryWithDensity; using DomainShape::discretizeWithDensity; using DomainShape::discretizeBoundaryWithStep; using DomainShape::discretizeWithStep; /// Construct a union of two shapes. ShapeUnion(const DomainShape& sh1, const DomainShape& sh2) : sh1(sh1), sh2(sh2) {} /// Access the first shape. const DomainShape& first() const { return *sh1; } /// Access the second shape. const DomainShape& second() const { return *sh2; } bool contains(const vec_t& point) const override { return sh1->contains(point) || sh2->contains(point); } bool hasContains() const override { return sh1->hasContains() && sh2->hasContains(); } std::pair bbox() const override; DomainDiscretization discretizeBoundaryWithStep(scalar_t step, int type) const override; DomainDiscretization discretizeWithStep( scalar_t step, int internal_type, int boundary_type) const override; DomainDiscretization discretizeBoundaryWithDensity( const std::function& dr, int type) const override; DomainDiscretization discretizeWithDensity( const std::function& dr, int internal_type, int boundary_type) const override; ShapeUnion* clone() const override { return new ShapeUnion(*this); } std::ostream& print(std::ostream& os) const override; }; } // namespace mm #endif // MEDUSA_BITS_DOMAINS_SHAPEUNION_FWD_HPP_