44using MaskPTR = std::shared_ptr< AbstractMask >;
60 virtual bool inside(
const std::vector< double >& )
const = 0;
117 bool inside(
const std::vector< double >& pt )
const override;
193 const double inf = std::numeric_limits< double >::infinity();
223 const double azimuth_angle = 0.0,
224 const double polar_angle = 0.0 );
385 double azimuth_angle,
405 "All axis > 0 required." );
411 "major_axis greater than minor_axis required." );
417 "polar_angle not defined in 2D." );
740 if ( not( lower_left_ < upper_right_ ) )
744 "Upper right must be strictly to the right and above lower left." );
753 azimuth_angle_ = 0.0;
762 "polar_angle not defined in 2D." );
771 azimuth_cos_ = std::cos( azimuth_angle_ *
numerics::pi / 180. );
772 azimuth_sin_ = std::sin( azimuth_angle_ *
numerics::pi / 180. );
773 polar_cos_ = std::cos( polar_angle_ *
numerics::pi / 180. );
774 polar_sin_ = std::sin( polar_angle_ *
numerics::pi / 180. );
776 cntr_ = ( upper_right_ + lower_left_ ) * 0.5;
777 for (
int i = 0; i != D; ++i )
782 cntr_x_az_cos_ = cntr_[ 0 ] * azimuth_cos_;
783 cntr_x_az_sin_ = cntr_[ 0 ] * azimuth_sin_;
784 cntr_y_az_cos_ = cntr_[ 1 ] * azimuth_cos_;
785 cntr_y_az_sin_ = cntr_[ 1 ] * azimuth_sin_;
788 cntr_z_pol_cos_ = cntr_[ 2 ] * polar_cos_;
789 cntr_z_pol_sin_ = cntr_[ 2 ] * polar_sin_;
790 cntr_x_az_cos_pol_cos_ = cntr_x_az_cos_ * polar_cos_;
791 cntr_x_az_cos_pol_sin_ = cntr_x_az_cos_ * polar_sin_;
792 cntr_y_az_sin_pol_cos_ = cntr_y_az_sin_ * polar_cos_;
793 cntr_y_az_sin_pol_sin_ = cntr_y_az_sin_ * polar_sin_;
794 az_cos_pol_cos_ = azimuth_cos_ * polar_cos_;
795 az_cos_pol_sin_ = azimuth_cos_ * polar_sin_;
796 az_sin_pol_cos_ = azimuth_sin_ * polar_cos_;
797 az_sin_pol_sin_ = azimuth_sin_ * polar_sin_;
801 cntr_z_pol_cos_ = 0.0;
802 cntr_z_pol_sin_ = 0.0;
803 cntr_x_az_cos_pol_cos_ = 0.0;
804 cntr_x_az_cos_pol_sin_ = 0.0;
805 cntr_y_az_sin_pol_cos_ = 0.0;
806 cntr_y_az_sin_pol_sin_ = 0.0;
807 az_cos_pol_cos_ = 0.0;
808 az_cos_pol_sin_ = 0.0;
809 az_sin_pol_cos_ = 0.0;
810 az_sin_pol_sin_ = 0.0;
813 is_rotated_ = azimuth_angle_ != 0.0 or polar_angle_ != 0.0;
815 calculate_min_max_values_();
821 const double azimuth_angle,
822 const double polar_angle )
823 : lower_left_( lower_left )
824 , upper_right_( upper_right )
825 , azimuth_angle_( azimuth_angle )
826 , polar_angle_( polar_angle )
827 , azimuth_cos_( std::cos( azimuth_angle_ *
numerics::pi / 180. ) )
828 , azimuth_sin_( std::sin( azimuth_angle_ *
numerics::pi / 180. ) )
829 , polar_cos_( std::cos( polar_angle_ *
numerics::pi / 180. ) )
830 , polar_sin_( std::sin( polar_angle_ *
numerics::pi / 180. ) )
831 , cntr_( ( upper_right_ + lower_left_ ) * 0.5 )
832 , cntr_x_az_cos_( cntr_[ 0 ] * azimuth_cos_ )
833 , cntr_x_az_sin_( cntr_[ 0 ] * azimuth_sin_ )
834 , cntr_y_az_cos_( cntr_[ 1 ] * azimuth_cos_ )
835 , cntr_y_az_sin_( cntr_[ 1 ] * azimuth_sin_ )
841 "polar_angle not defined in 2D." );
844 for (
int i = 0; i != D; ++i )
901 throw BadProperty(
"BallMask<D>: radius > 0 required." );
929 if ( major_axis_ <= 0 or minor_axis_ <= 0 )
933 "All axis > 0 required." );
935 if ( major_axis_ < minor_axis_ )
939 "major_axis greater than minor_axis required." );
942 x_scale_ = 4.0 / ( major_axis_ * major_axis_ );
943 y_scale_ = 4.0 / ( minor_axis_ * minor_axis_ );
951 "polar_axis not defined in 2D." );
955 if ( polar_axis_ <= 0 )
959 "All axis > 0 required." );
962 z_scale_ = 4.0 / ( polar_axis_ * polar_axis_ );
981 azimuth_angle_ = 0.0;
990 "polar_angle not defined in 2D." );
999 azimuth_cos_ = std::cos( azimuth_angle_ *
numerics::pi / 180. );
1000 azimuth_sin_ = std::sin( azimuth_angle_ *
numerics::pi / 180. );
1001 polar_cos_ = std::cos( polar_angle_ *
numerics::pi / 180. );
1002 polar_sin_ = std::sin( polar_angle_ *
numerics::pi / 180. );
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Abstract base class for masks with unspecified dimension.
Definition mask.h:51
virtual AbstractMask * union_mask(const AbstractMask &other) const =0
Create the union of this mask with another.
virtual ~AbstractMask()
Definition mask.h:53
virtual bool inside(const std::vector< double > &) const =0
virtual Dictionary get_dict() const
Definition mask.h:66
virtual AbstractMask * minus_mask(const AbstractMask &other) const =0
Create the difference of this mask and another.
virtual AbstractMask * intersect_mask(const AbstractMask &other) const =0
Create the intersection of this mask with another.
Mask which covers all of space.
Definition mask.h:155
~AllMask()
Definition mask.h:157
Mask< D > * clone() const
Clone method.
Definition mask.h:198
bool outside(const Box< D > &) const
Definition mask.h:185
bool inside(const Position< D > &) const
Definition mask.h:167
bool inside(const Box< D > &) const
Definition mask.h:176
Box< D > get_bbox() const
The whole mask is inside (i.e., false everywhere outside) the bounding box.
Definition mask.h:191
Mask shifted by an anchor.
Definition mask.h:677
AnchoredMask(const Mask< D > &m, Position< D > anchor)
Construct the converse of the two given mask.
Definition mask.h:685
bool outside(const Box< D > &b) const
Definition mask_impl.h:484
Box< D > get_bbox() const
The whole mask is inside (i.e., false everywhere outside) the bounding box.
Definition mask_impl.h:491
bool inside(const Position< D > &p) const
Definition mask_impl.h:470
Mask< D > * m_
Definition mask.h:716
~AnchoredMask()
Definition mask.h:698
Position< D > anchor_
Definition mask.h:717
Mask< D > * clone() const
Clone method.
Definition mask_impl.h:499
AnchoredMask(const AnchoredMask &m)
Definition mask.h:691
Dictionary get_dict() const
Definition mask_impl.h:506
Exception to be thrown if a status parameter is incomplete or inconsistent.
Definition exceptions.h:680
Mask defining a circular or spherical region.
Definition mask.h:308
bool inside(const Box< D > &) const override
static std::string get_name()
Dictionary get_dict() const override
Definition mask_impl.h:208
BallMask(Position< D > center, double radius)
Definition mask.h:314
~BallMask() override
Definition mask.h:327
bool outside(const Box< D > &b) const override
Definition mask_impl.h:172
bool inside(const Position< D > &p) const override
Definition mask_impl.h:146
Mask< D > * clone() const override
Clone method.
Definition mask_impl.h:201
double radius_
Definition mask.h:361
Position< D > center_
Definition mask.h:360
Box< D > get_bbox() const override
The whole mask is inside (i.e., false everywhere outside) the bounding box.
Definition mask_impl.h:188
Mask defining a box region.
Definition mask.h:209
double cntr_z_pol_cos_
Definition mask.h:289
double cntr_x_az_cos_pol_cos_
Definition mask.h:291
double cntr_z_pol_sin_
Definition mask.h:290
double cntr_y_az_sin_pol_sin_
Definition mask.h:294
double polar_sin_
Definition mask.h:281
Position< D > max_values_
Definition mask.h:274
~BoxMask() override
Definition mask.h:226
bool outside(const Box< D > &b) const override
Definition mask_impl.h:98
double cntr_x_az_cos_pol_sin_
Definition mask.h:292
Position< D > lower_left_
Definition mask.h:264
double cntr_y_az_sin_
Definition mask.h:288
double az_cos_pol_cos_
Definition mask.h:295
double az_sin_pol_sin_
Definition mask.h:298
Position< D > upper_right_
Definition mask.h:265
Box< D > get_bbox() const override
The whole mask is inside (i.e., false everywhere outside) the bounding box.
Definition mask_impl.h:118
double polar_angle_
Definition mask.h:277
bool inside(const Position< D > &p) const override
Dictionary get_dict() const override
Definition mask_impl.h:132
BoxMask(const Dictionary &)
Parameters that should be in the dictionary: lower_left - Position of lower left corner (array of dou...
Definition mask.h:735
void calculate_min_max_values_()
Calculate the min/max x, y, z values in case of a rotated box.
static std::string get_name()
double cntr_y_az_sin_pol_cos_
Definition mask.h:293
bool is_rotated_
Definition mask.h:300
double az_cos_pol_sin_
Definition mask.h:296
double cntr_y_az_cos_
Definition mask.h:287
Position< D > eps_
Definition mask.h:284
Position< D > cntr_
Definition mask.h:283
Position< D > min_values_
The {min,max}_values_ correspond to the minimum and maximum x, y, z values after the box has been rot...
Definition mask.h:273
double azimuth_sin_
Definition mask.h:279
double az_sin_pol_cos_
Definition mask.h:297
double polar_cos_
Definition mask.h:280
Mask< D > * clone() const override
Clone method.
Definition mask_impl.h:125
double cntr_x_az_sin_
Definition mask.h:286
double cntr_x_az_cos_
Definition mask.h:285
double azimuth_angle_
Definition mask.h:276
double azimuth_cos_
Definition mask.h:278
Mask oriented in the opposite direction.
Definition mask.h:633
Mask< D > * m_
Definition mask.h:668
Box< D > get_bbox() const
The whole mask is inside (i.e., false everywhere outside) the bounding box.
Definition mask_impl.h:455
~ConverseMask()
Definition mask.h:652
bool inside(const Position< D > &p) const
Definition mask_impl.h:434
ConverseMask(const Mask< D > &m)
Construct the converse of the two given mask.
Definition mask.h:641
Mask< D > * clone() const
Clone method.
Definition mask_impl.h:463
bool outside(const Box< D > &b) const
Definition mask_impl.h:448
ConverseMask(const ConverseMask &m)
Definition mask.h:646
Mask combining two masks with a minus operation, the difference.
Definition mask.h:586
Box< D > get_bbox() const
The whole mask is inside (i.e., false everywhere outside) the bounding box.
Definition mask_impl.h:420
DifferenceMask(const DifferenceMask &m)
Definition mask.h:600
Mask< D > * clone() const
Clone method.
Definition mask_impl.h:427
bool outside(const Box< D > &b) const
Definition mask_impl.h:413
DifferenceMask(const Mask< D > &m1, const Mask< D > &m2)
Construct the difference of the two given masks.
Definition mask.h:594
bool inside(const Position< D > &p) const
Definition mask_impl.h:399
~DifferenceMask()
Definition mask.h:607
Mask< D > * mask1_
Definition mask.h:624
Mask< D > * mask2_
Definition mask.h:624
Mask defining an elliptical or ellipsoidal region.
Definition mask.h:369
double azimuth_cos_
Definition mask.h:478
double azimuth_angle_
Definition mask.h:471
bool inside(const Position< D > &p) const override
double polar_axis_
Definition mask.h:470
void create_bbox_()
Definition mask_impl.h:220
Mask< D > * clone() const override
Clone method.
Definition mask_impl.h:279
double z_scale_
Definition mask.h:476
EllipseMask(Position< D > center, double major_axis, double minor_axis, double polar_axis, double azimuth_angle, double polar_angle)
Definition mask.h:381
Dictionary get_dict() const override
Definition mask_impl.h:286
double major_axis_
Definition mask.h:468
~EllipseMask() override
Definition mask.h:432
static std::string get_name()
double x_scale_
Definition mask.h:474
double y_scale_
Definition mask.h:475
double polar_angle_
Definition mask.h:472
Position< D > center_
Definition mask.h:467
Box< D > bbox_
Definition mask.h:483
double polar_cos_
Definition mask.h:480
bool inside(const Box< D > &) const override
double minor_axis_
Definition mask.h:469
Box< D > get_bbox() const override
The whole mask is inside (i.e., false everywhere outside) the bounding box.
Definition mask_impl.h:272
double polar_sin_
Definition mask.h:481
bool outside(const Box< D > &b) const override
Definition mask_impl.h:253
double azimuth_sin_
Definition mask.h:479
Mask combining two masks with a Boolean AND, the intersection.
Definition mask.h:491
IntersectionMask(const IntersectionMask &m)
Copy constructor.
Definition mask.h:508
Box< D > get_bbox() const
The whole mask is inside (i.e., false everywhere outside) the bounding box.
Definition mask_impl.h:324
Mask< D > * mask1_
Definition mask.h:532
Mask< D > * clone() const
Clone method.
Definition mask_impl.h:344
~IntersectionMask()
Definition mask.h:515
Mask< D > * mask2_
Definition mask.h:532
bool outside(const Box< D > &b) const
Definition mask_impl.h:317
IntersectionMask(const Mask< D > &m1, const Mask< D > &m2)
Construct the intersection of the two given masks.
Definition mask.h:499
bool inside(const Position< D > &p) const
Definition mask_impl.h:303
Base class for all Kernel exceptions.
Definition exceptions.h:65
Abstract base class for masks with given dimension.
Definition mask.h:101
AbstractMask * intersect_mask(const AbstractMask &other) const override
Create the intersection of this mask with another.
Definition mask_impl.h:33
~Mask() override
Definition mask.h:105
virtual bool inside(const Position< D > &) const =0
virtual Mask * clone() const =0
Clone method.
virtual bool inside(const Box< D > &) const =0
virtual Box< D > get_bbox() const =0
The whole mask is inside (i.e., false everywhere outside) the bounding box.
virtual bool outside(const Box< D > &b) const
Definition mask_impl.h:76
AbstractMask * minus_mask(const AbstractMask &other) const override
Create the difference of this mask and another.
Definition mask_impl.h:57
AbstractMask * union_mask(const AbstractMask &other) const override
Create the union of this mask with another.
Definition mask_impl.h:45
Mask combining two masks with a Boolean OR, the sum.
Definition mask.h:540
Mask< D > * mask2_
Definition mask.h:578
bool inside(const Position< D > &p) const
Definition mask_impl.h:351
~UnionMask()
Definition mask.h:561
Box< D > get_bbox() const
The whole mask is inside (i.e., false everywhere outside) the bounding box.
Definition mask_impl.h:372
Mask< D > * mask1_
Definition mask.h:578
UnionMask(const Mask< D > &m1, const Mask< D > &m2)
Construct the union of the two given masks.
Definition mask.h:548
bool outside(const Box< D > &b) const
Definition mask_impl.h:365
Mask< D > * clone() const
Clone method.
Definition mask_impl.h:392
UnionMask(const UnionMask &m)
Definition mask.h:554
const std::string circular("circular")
const std::string polar_axis("polar_axis")
const std::string ellipsoidal("ellipsoidal")
const std::string box("box")
const std::string polar_angle("polar_angle")
const std::string anchor("anchor")
const std::string azimuth_angle("azimuth_angle")
const std::string spherical("spherical")
const std::string elliptical("elliptical")
const std::string minor_axis("minor_axis")
const std::string radius("radius")
const std::string rectangular("rectangular")
const std::string major_axis("major_axis")
const std::string lower_left("lower_left")
const std::string upper_right("upper_right")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
std::shared_ptr< AbstractMask > MaskPTR
Definition mask.h:44
const double pi
Definition numerics.cpp:33
A box is defined by the lower left corner (minimum coordinates) and the upper right corner (maximum c...
Definition position.h:321