#ifndef MEDUSA_BITS_DOMAINS_BALLSHAPE_FWD_HPP_ #define MEDUSA_BITS_DOMAINS_BALLSHAPE_FWD_HPP_ /** * @file * Declaration of class for ball shaped domains. * * @example test/domains/BallShape_test.cpp */ #include #include #include "DomainShape_fwd.hpp" namespace mm { /** * Class for working with ball shaped domains. * * Usage example: * @snippet domains/BallShape_test.cpp BallShape usage example * @ingroup domains */ template class BallShape : public DomainShape { vec_t center_; ///< Center of the ball. double radius_; ///< Radius of the ball. using DomainShape::margin_; public: using typename DomainShape::scalar_t; using DomainShape::dim; using DomainShape::discretizeBoundaryWithDensity; using DomainShape::discretizeWithDensity; using DomainShape::discretizeBoundaryWithStep; using DomainShape::discretizeWithStep; /** * Constructs a `d`-dimensional ball defined by its center and radius. * @param center Position of the centre of the ball. * @param radius Radius of the ball. */ BallShape(const vec_t& center, double radius) : center_(center), radius_(radius) {} /// Returns the position of the centre of the ball. const vec_t& center() const { return center_; } /// Returns the radius of the ball. scalar_t radius() const { return radius_; } bool contains(const vec_t& point) const override { return (center_ - point).squaredNorm() < (radius_ + margin_)*(radius_ + margin_); } std::pair bbox() const override { return {center_ - vec_t(radius_), center_ + vec_t(radius_)}; } 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; BallShape* clone() const override { return new BallShape(*this); } std::ostream& print(std::ostream& os) const override; }; } // namespace mm #endif // MEDUSA_BITS_DOMAINS_BALLSHAPE_FWD_HPP_