NEST main@caf0ae8
 
Loading...
Searching...
No Matches
mask.h
Go to the documentation of this file.
1/*
2 * mask.h
3 *
4 * This file is part of NEST.
5 *
6 * Copyright (C) 2004 The NEST Initiative
7 *
8 * NEST is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * NEST is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef MASK_H
24#define MASK_H
25
26// C++ includes:
27#include <memory>
28
29// Includes from libnestutil:
30#include "dictionary.h"
31#include "numerics.h"
32
33// Includes from nestkernel:
34#include "exceptions.h"
35#include "nest_names.h"
36#include "nest_types.h"
37
38// Includes from spatial:
39#include "position.h"
40
41namespace nest
42{
43class AbstractMask;
44using MaskPTR = std::shared_ptr< AbstractMask >;
45
46
51{
52public:
53 virtual ~AbstractMask()
54 {
55 }
56
60 virtual bool inside( const std::vector< double >& ) const = 0;
61
65 virtual Dictionary
66 get_dict() const
67 {
68 throw KernelException( "Can not convert mask to dict" );
69 }
70
77 virtual AbstractMask* intersect_mask( const AbstractMask& other ) const = 0;
78
85 virtual AbstractMask* union_mask( const AbstractMask& other ) const = 0;
86
93 virtual AbstractMask* minus_mask( const AbstractMask& other ) const = 0;
94};
95
99template < int D >
100class Mask : public AbstractMask
101{
102public:
104
105 ~Mask() override
106 {
107 }
108
112 virtual bool inside( const Position< D >& ) const = 0;
113
117 bool inside( const std::vector< double >& pt ) const override;
118
124 virtual bool inside( const Box< D >& ) const = 0;
125
131 virtual bool outside( const Box< D >& b ) const;
132
137 virtual Box< D > get_bbox() const = 0;
138
143 virtual Mask* clone() const = 0;
144
145 AbstractMask* intersect_mask( const AbstractMask& other ) const override;
146 AbstractMask* union_mask( const AbstractMask& other ) const override;
147 AbstractMask* minus_mask( const AbstractMask& other ) const override;
148};
149
153template < int D >
154class AllMask : public Mask< D >
155{
156public:
158 {
159 }
160
161 using Mask< D >::inside;
162
166 bool
167 inside( const Position< D >& ) const
168 {
169 return true;
170 }
171
175 bool
176 inside( const Box< D >& ) const
177 {
178 return true;
179 }
180
184 bool
185 outside( const Box< D >& ) const
186 {
187 return false;
188 }
189
191 get_bbox() const
192 {
193 const double inf = std::numeric_limits< double >::infinity();
194 return Box< D >( Position< D >( -inf, -inf ), Position< D >( inf, inf ) );
195 }
196
197 Mask< D >*
198 clone() const
199 {
200 return new AllMask();
201 }
202};
203
207template < int D >
208class BoxMask : public Mask< D >
209{
210public:
219 BoxMask( const Dictionary& );
220
221 BoxMask( const Position< D >& lower_left,
222 const Position< D >& upper_right,
223 const double azimuth_angle = 0.0,
224 const double polar_angle = 0.0 );
225
226 ~BoxMask() override
227 {
228 }
229
230 using Mask< D >::inside;
231
235 bool inside( const Position< D >& p ) const override;
236
240 bool inside( const Box< D >& b ) const override;
241
245 bool outside( const Box< D >& b ) const override;
246
247 Box< D > get_bbox() const override;
248
249 Dictionary get_dict() const override;
250
251 Mask< D >* clone() const override;
252
256 static std::string get_name();
257
258protected:
263
266
275
282
299
301};
302
306template < int D >
307class BallMask : public Mask< D >
308{
309public:
314 BallMask( Position< D > center, double radius )
315 : center_( center )
316 , radius_( radius )
317 {
318 }
319
325 BallMask( const Dictionary& );
326
327 ~BallMask() override
328 {
329 }
330
331 using Mask< D >::inside;
332
336 bool inside( const Position< D >& p ) const override;
337
341 bool inside( const Box< D >& ) const override;
342
346 bool outside( const Box< D >& b ) const override;
347
348 Box< D > get_bbox() const override;
349
350 Dictionary get_dict() const override;
351
352 Mask< D >* clone() const override;
353
357 static std::string get_name();
358
359protected:
361 double radius_;
362};
363
367template < int D >
368class EllipseMask : public Mask< D >
369{
370public:
382 double major_axis,
383 double minor_axis,
384 double polar_axis,
385 double azimuth_angle,
386 double polar_angle )
387 : center_( center )
388 , major_axis_( major_axis )
389 , minor_axis_( minor_axis )
390 , polar_axis_( polar_axis )
391 , azimuth_angle_( azimuth_angle )
392 , polar_angle_( polar_angle )
393 , x_scale_( 4.0 / ( major_axis_ * major_axis_ ) )
394 , y_scale_( 4.0 / ( minor_axis_ * minor_axis_ ) )
395 , z_scale_( 4.0 / ( polar_axis_ * polar_axis_ ) )
396 , azimuth_cos_( std::cos( azimuth_angle_ * numerics::pi / 180. ) )
397 , azimuth_sin_( std::sin( azimuth_angle_ * numerics::pi / 180. ) )
398 , polar_cos_( std::cos( polar_angle_ * numerics::pi / 180. ) )
399 , polar_sin_( std::sin( polar_angle_ * numerics::pi / 180. ) )
400 {
401 if ( major_axis_ <= 0 or minor_axis_ <= 0 or polar_axis_ <= 0 )
402 {
403 throw BadProperty(
404 "EllipseMask<D>: "
405 "All axis > 0 required." );
406 }
407 if ( major_axis_ < minor_axis_ )
408 {
409 throw BadProperty(
410 "EllipseMask<D>: "
411 "major_axis greater than minor_axis required." );
412 }
413 if ( D == 2 and not( polar_angle_ == 0.0 ) )
414 {
415 throw BadProperty(
416 "EllipseMask<D>: "
417 "polar_angle not defined in 2D." );
418 }
419
420 create_bbox_();
421 }
422
430 EllipseMask( const Dictionary& );
431
432 ~EllipseMask() override
433 {
434 }
435
436 using Mask< D >::inside;
437
441 bool inside( const Position< D >& p ) const override;
442
446 bool inside( const Box< D >& ) const override;
447
451 bool outside( const Box< D >& b ) const override;
452
453 Box< D > get_bbox() const override;
454
455 Dictionary get_dict() const override;
456
457 Mask< D >* clone() const override;
458
462 static std::string get_name();
463
464private:
465 void create_bbox_();
466
473
474 double x_scale_;
475 double y_scale_;
476 double z_scale_;
477
482
484};
485
489template < int D >
490class IntersectionMask : public Mask< D >
491{
492public:
493 using Mask< D >::inside;
494
499 IntersectionMask( const Mask< D >& m1, const Mask< D >& m2 )
500 : mask1_( m1.clone() )
501 , mask2_( m2.clone() )
502 {
503 }
504
509 : Mask< D >( m )
510 , mask1_( m.mask1_->clone() )
511 , mask2_( m.mask2_->clone() )
512 {
513 }
514
516 {
517 delete mask1_;
518 delete mask2_;
519 }
520
521 bool inside( const Position< D >& p ) const;
522
523 bool inside( const Box< D >& b ) const;
524
525 bool outside( const Box< D >& b ) const;
526
527 Box< D > get_bbox() const;
528
529 Mask< D >* clone() const;
530
531protected:
533};
534
538template < int D >
539class UnionMask : public Mask< D >
540{
541public:
542 using Mask< D >::inside;
543
548 UnionMask( const Mask< D >& m1, const Mask< D >& m2 )
549 : mask1_( m1.clone() )
550 , mask2_( m2.clone() )
551 {
552 }
553
555 : Mask< D >( m )
556 , mask1_( m.mask1_->clone() )
557 , mask2_( m.mask2_->clone() )
558 {
559 }
560
562 {
563 delete mask1_;
564 delete mask2_;
565 }
566
567 bool inside( const Position< D >& p ) const;
568
569 bool inside( const Box< D >& b ) const;
570
571 bool outside( const Box< D >& b ) const;
572
573 Box< D > get_bbox() const;
574
575 Mask< D >* clone() const;
576
577protected:
579};
580
584template < int D >
585class DifferenceMask : public Mask< D >
586{
587public:
588 using Mask< D >::inside;
589
594 DifferenceMask( const Mask< D >& m1, const Mask< D >& m2 )
595 : mask1_( m1.clone() )
596 , mask2_( m2.clone() )
597 {
598 }
599
601 : Mask< D >( m )
602 , mask1_( m.mask1_->clone() )
603 , mask2_( m.mask2_->clone() )
604 {
605 }
606
608 {
609 delete mask1_;
610 delete mask2_;
611 }
612
613 bool inside( const Position< D >& p ) const;
614
615 bool inside( const Box< D >& b ) const;
616
617 bool outside( const Box< D >& b ) const;
618
619 Box< D > get_bbox() const;
620
621 Mask< D >* clone() const;
622
623protected:
625};
626
627
631template < int D >
632class ConverseMask : public Mask< D >
633{
634public:
635 using Mask< D >::inside;
636
642 : m_( m.clone() )
643 {
644 }
645
647 : Mask< D >( m )
648 , m_( m.m_->clone() )
649 {
650 }
651
653 {
654 delete m_;
655 }
656
657 bool inside( const Position< D >& p ) const;
658
659 bool inside( const Box< D >& b ) const;
660
661 bool outside( const Box< D >& b ) const;
662
663 Box< D > get_bbox() const;
664
665 Mask< D >* clone() const;
666
667protected:
669};
670
671
675template < int D >
676class AnchoredMask : public Mask< D >
677{
678public:
679 using Mask< D >::inside;
680
686 : m_( m.clone() )
687 , anchor_( anchor )
688 {
689 }
690
692 : Mask< D >( m )
693 , m_( m.m_->clone() )
694 , anchor_( m.anchor_ )
695 {
696 }
697
699 {
700 delete m_;
701 }
702
703 bool inside( const Position< D >& p ) const;
704
705 bool inside( const Box< D >& b ) const;
706
707 bool outside( const Box< D >& b ) const;
708
709 Box< D > get_bbox() const;
710
711 Dictionary get_dict() const;
712
713 Mask< D >* clone() const;
714
715protected:
718};
719
720template <>
721inline std::string
726
727template <>
728inline std::string
730{
731 return names::box;
732}
733
734template < int D >
736{
737 lower_left_ = d.get< std::vector< double > >( names::lower_left );
738 upper_right_ = d.get< std::vector< double > >( names::upper_right );
739
740 if ( not( lower_left_ < upper_right_ ) )
741 {
742 throw BadProperty(
743 "BoxMask<D>: "
744 "Upper right must be strictly to the right and above lower left." );
745 }
746
747 if ( d.known( names::azimuth_angle ) )
748 {
749 azimuth_angle_ = d.get< double >( names::azimuth_angle );
750 }
751 else
752 {
753 azimuth_angle_ = 0.0;
754 }
755
756 if ( d.known( names::polar_angle ) )
757 {
758 if ( D == 2 )
759 {
760 throw BadProperty(
761 "BoxMask<D>: "
762 "polar_angle not defined in 2D." );
763 }
764 polar_angle_ = d.get< double >( names::polar_angle );
765 }
766 else
767 {
768 polar_angle_ = 0.0;
769 }
770
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. );
775
776 cntr_ = ( upper_right_ + lower_left_ ) * 0.5;
777 for ( int i = 0; i != D; ++i )
778 {
779 eps_[ i ] = 1e-12;
780 }
781
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_;
786 if ( D == 3 )
787 {
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_;
798 }
799 else
800 {
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;
811 }
812
813 is_rotated_ = azimuth_angle_ != 0.0 or polar_angle_ != 0.0;
814
815 calculate_min_max_values_();
816}
817
818template < int D >
819inline BoxMask< D >::BoxMask( const Position< D >& lower_left,
820 const Position< D >& upper_right,
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_ )
836{
837 if ( D == 2 and not( polar_angle_ == 0.0 ) )
838 {
839 throw BadProperty(
840 "BoxMask<D>: "
841 "polar_angle not defined in 2D." );
842 }
843
844 for ( int i = 0; i != D; ++i )
845 {
846 eps_[ i ] = 1e-12;
847 }
848
849 if ( D == 3 )
850 {
861 }
862 else
863 {
864 cntr_z_pol_cos_ = 0.0;
865 cntr_z_pol_sin_ = 0.0;
870 az_cos_pol_cos_ = 0.0;
871 az_cos_pol_sin_ = 0.0;
872 az_sin_pol_cos_ = 0.0;
873 az_sin_pol_sin_ = 0.0;
874 }
875
876 is_rotated_ = azimuth_angle_ != 0.0 or polar_angle_ != 0.0;
877
879}
880
881template <>
882inline std::string
887
888template <>
889inline std::string
894
895template < int D >
897{
898 radius_ = d.get< double >( names::radius );
899 if ( radius_ <= 0 )
900 {
901 throw BadProperty( "BallMask<D>: radius > 0 required." );
902 }
903
904 if ( d.known( names::anchor ) )
905 {
906 center_ = d.get< std::vector< double > >( names::anchor );
907 }
908}
909
910template <>
911inline std::string
916
917template <>
918inline std::string
923
924template < int D >
926{
927 major_axis_ = d.get< double >( names::major_axis );
928 minor_axis_ = d.get< double >( names::minor_axis );
929 if ( major_axis_ <= 0 or minor_axis_ <= 0 )
930 {
931 throw BadProperty(
932 "EllipseMask<D>: "
933 "All axis > 0 required." );
934 }
935 if ( major_axis_ < minor_axis_ )
936 {
937 throw BadProperty(
938 "EllipseMask<D>: "
939 "major_axis greater than minor_axis required." );
940 }
941
942 x_scale_ = 4.0 / ( major_axis_ * major_axis_ );
943 y_scale_ = 4.0 / ( minor_axis_ * minor_axis_ );
944
945 if ( d.known( names::polar_axis ) )
946 {
947 if ( D == 2 )
948 {
949 throw BadProperty(
950 "EllipseMask<D>: "
951 "polar_axis not defined in 2D." );
952 }
953 polar_axis_ = d.get< double >( names::polar_axis );
954
955 if ( polar_axis_ <= 0 )
956 {
957 throw BadProperty(
958 "EllipseMask<D>: "
959 "All axis > 0 required." );
960 }
961
962 z_scale_ = 4.0 / ( polar_axis_ * polar_axis_ );
963 }
964 else
965 {
966 polar_axis_ = 0.0;
967 z_scale_ = 0.0;
968 }
969
970 if ( d.known( names::anchor ) )
971 {
972 center_ = d.get< std::vector< double > >( names::anchor );
973 }
974
975 if ( d.known( names::azimuth_angle ) )
976 {
977 azimuth_angle_ = d.get< double >( names::azimuth_angle );
978 }
979 else
980 {
981 azimuth_angle_ = 0.0;
982 }
983
984 if ( d.known( names::polar_angle ) )
985 {
986 if ( D == 2 )
987 {
988 throw BadProperty(
989 "EllipseMask<D>: "
990 "polar_angle not defined in 2D." );
991 }
992 polar_angle_ = d.get< double >( names::polar_angle );
993 }
994 else
995 {
996 polar_angle_ = 0.0;
997 }
998
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. );
1003
1004 create_bbox_();
1005}
1006
1007} // namespace nest
1008
1009#endif
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
Definition position.h:57
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
Definition numerics.h:36
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