36template <
int D,
class T,
int max_capacity,
int max_depth >
43 while ( not
ntree_->is_leaf() )
45 ntree_ = ntree_->children_[ 0 ];
48 while (
ntree_->nodes_.empty() )
59template <
int D,
class T,
int max_capacity,
int max_depth >
80template <
int D,
class T,
int max_capacity,
int max_depth >
105 while ( not
ntree_->is_leaf() )
115 x = std::fmod( x, p );
123template <
int D,
class T,
int max_capacity,
int max_depth >
136 if (
ntree_->periodic_.any() )
138 Box< D > mask_bb = mask_->get_bbox();
141 for ( int i = 0; i < D; ++i )
143 if ( ntree_->periodic_[ i ] )
145 anchor_[ i ] = mod( anchor_[ i ] + mask_bb.lower_left[ i ] - ntree_->lower_left_[ i ], ntree_->extent_[ i ] )
146 - mask_bb.lower_left[ i ] + ntree_->lower_left_[ i ];
153 for (
int i = 0; i < D; ++i )
155 if (
ntree_->periodic_[ i ] )
158 if ( (
anchor_[ i ] + mask_bb.upper_right[ i ] -
ntree_->lower_left_[ i ] ) >
ntree_->extent_[ i ] )
160 for (
int j = 0; j < n; ++j )
163 p[ i ] -=
ntree_->extent_[ i ];
174template <
int D,
class T,
int max_capacity,
int max_depth >
206template <
int D,
class T,
int max_capacity,
int max_depth >
224template <
int D,
class T,
int max_capacity,
int max_depth >
262 while ( not
ntree_->is_leaf() )
309template <
int D,
class T,
int max_capacity,
int max_depth >
313 while ( not
ntree_->is_leaf() )
331template <
int D,
class T,
int max_capacity,
int max_depth >
338 while ( not
ntree_->is_leaf() )
344template <
int D,
class T,
int max_capacity,
int max_depth >
382template <
int D,
class T,
int max_capacity,
int max_depth >
387 for (
int i = 0; i < D; ++i )
392 const bool in_left_half =
393 ( (
lower_left_[ i ] +
extent_[ i ] / 2 ) - pos[ i ] ) > -std::numeric_limits< double >::epsilon();
394 r += ( 1 << i ) * ( in_left_half ? 0 : 1 );
400template <
int D,
class T,
int max_capacity,
int max_depth >
406 std::copy(
nodes_.begin(),
nodes_.end(), std::back_inserter( v ) );
410 for (
int i = 0; i <
N; ++i )
417template <
int D,
class T,
int max_capacity,
int max_depth >
420 const Mask< D >& mask,
421 const Position< D >& anchor )
434 for (
typename std::vector< std::pair< Position< D >, T > >
::iterator i =
nodes_.begin(); i !=
nodes_.end(); ++i )
436 if (
mask.inside( i->first - anchor ) )
444 for (
int i = 0; i <
N; ++i )
446 children_[ i ]->append_nodes_( v, mask, anchor );
451template <
int D,
class T,
int max_capacity,
int max_depth >
460 for (
int i = 0; i < D; ++i )
480 for (
int i = 0; i < D; ++i )
485 assert( ( pos -
lower_left_ )[ i ] > -std::numeric_limits< double >::epsilon()
486 and (
lower_left_ +
extent_ - pos )[ i ] > -std::numeric_limits< double >::epsilon() );
500template <
int D,
class T,
int max_capacity,
int max_depth >
506 for (
int j = 0; j <
N; ++j )
509 for (
int i = 0; i < D; ++i )
511 if ( j & ( 1 << i ) )
513 lower_left[ i ] +=
extent_[ i ] * 0.5;
Abstract base class for masks with given dimension.
Definition mask.h:101
Iterator iterating the nodes in a Quadtree.
Definition ntree.h:69
iterator & operator++()
Move the iterator to the next node within the tree.
Definition ntree_impl.h:61
Ntree * ntree_
Definition ntree.h:144
Ntree * top_
Definition ntree.h:145
size_t node_
Definition ntree.h:146
iterator()
Initialize an invalid iterator.
Definition ntree.h:74
void next_leaf_()
Move to the next leaf quadrant, or set ntree_ to 0 if there are no more leaves.
Definition ntree_impl.h:82
Iterator iterating the nodes in a Quadtree inside a Mask.
Definition ntree.h:153
Ntree * ntree_
Definition ntree.h:262
std::vector< Position< D > > anchors_
Definition ntree.h:269
void first_leaf_inside_()
Set the allin_top_ to the current quadrant, and find the first leaf below the current quadrant.
Definition ntree_impl.h:333
void init_()
Initialize.
Definition ntree_impl.h:176
masked_iterator & operator++()
Move the iterator to the next node inside the mask within the tree.
Definition ntree_impl.h:346
const Mask< D > * mask_
Definition ntree.h:266
Ntree * allin_top_
Definition ntree.h:264
masked_iterator()
Initialize an invalid iterator.
Definition ntree.h:163
Position< D > anchor_
Definition ntree.h:267
size_t current_anchor_
Definition ntree.h:270
Ntree * top_
Definition ntree.h:263
void next_leaf_()
Find the next leaf which is not outside the mask.
Definition ntree_impl.h:226
void next_anchor_()
Go to the next anchor image.
Definition ntree_impl.h:208
void first_leaf_()
Find the first leaf which is not outside the mask.
Definition ntree_impl.h:311
Position< D > anchored_position_
Definition ntree.h:268
size_t node_
Definition ntree.h:265
bool anchored_position_inside_mask(const Position< D > &position)
Definition ntree.h:254
iterator insert(Position< D > pos, const T &node)
Traverse quadtree structure from current ntree.
Definition ntree_impl.h:453
Position< D > lower_left_
Definition ntree.h:392
Ntree(const Position< D > &lower_left, const Position< D > &extent, std::bitset< D > periodic=0, Ntree *parent=0, int subquad=0)
Create a Ntree that covers the region defined by the two input positions.
Definition ntree.h:410
Position< D > extent_
Definition ntree.h:393
friend class iterator
Definition ntree.h:405
void split_()
Change a leaf ntree to a regular ntree with four children regions.
Definition ntree_impl.h:502
int my_depth_
This Ntree's depth in the tree.
Definition ntree.h:401
int subquad_(const Position< D > &)
Definition ntree_impl.h:384
static const int N
Definition ntree.h:57
Ntree * children_[N]
Definition ntree.h:402
std::vector< value_type > nodes_
Definition ntree.h:397
std::bitset< D > periodic_
periodic b.c.
Definition ntree.h:403
void append_nodes_(std::vector< value_type > &)
Append this ntree's nodes to the vector.
bool leaf_
Definition ntree.h:395
const std::string mask("mask")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
static double mod(double x, double p)
Definition ntree_impl.h:113
A box is defined by the lower left corner (minimum coordinates) and the upper right corner (maximum c...
Definition position.h:321