96 const size_t to )
const = 0;
98 const std::vector< double >& to_pos,
99 const unsigned int dimension )
const = 0;
109 virtual double compute_distance(
const std::vector< double >& from_pos,
const size_t lid )
const = 0;
111 const std::vector< double >& to_pos )
const = 0;
146 const std::vector< double >& anchor,
147 bool allow_oversized,
173 const std::string& syn_model ) = 0;
306 const std::vector< double >& to_pos,
307 const unsigned int dimension )
const override;
319 std::vector< double >
compute_displacement(
const std::vector< double >& from_pos,
const size_t to )
const override;
331 double compute_distance(
const std::vector< double >& from_pos,
const size_t lid )
const override;
333 double compute_distance(
const std::vector< double >& from_pos,
const std::vector< double >& to_pos )
const override;
362 bool allow_oversized,
369 const std::vector< double >& anchor,
370 bool allow_oversized,
395 void dump_nodes( std::ostream& os )
const override;
412 const std::string& syn_model )
override;
485 bool allow_oversized,
519 std::shared_ptr< Ntree< D, size_t > >
ntree_;
539 bool allow_oversized,
551 bool allow_oversized,
557 target.get_periodic_mask(), target.get_lower_left(), target.get_extent(), node_collection );
574 return ntree_->masked_begin(
dynamic_cast< const Mask< D >&
>( *mask_ ), anchor );
576 catch ( std::bad_cast& e )
578 throw BadProperty(
"Mask is incompatible with layer." );
586 return ntree_->masked_end();
593 for (
int i = 0; i < D; ++i )
595 lower_left_[ i ] = -0.5;
603 , lower_left_( other_layer.lower_left_ )
604 , extent_( other_layer.extent_ )
605 , periodic_( other_layer.periodic_ )
614 clear_ntree_cache_();
619 clear_vector_cache_();
627 return compute_displacement( from_pos,
get_position( to_lid ) );
631inline std::vector< double >
634 return std::vector< double >( compute_displacement(
Position< D >( from_pos ), to_lid ).get_vector() );
641 return compute_displacement( from_pos, lid ).length();
648 return compute_displacement(
Position< D >( from_pos ), lid ).length();
655 double squared_displacement = 0;
656 for (
unsigned int i = 0; i < D; ++i )
658 const double displacement = compute_displacement( from_pos, to_pos, i );
661 return std::sqrt( squared_displacement );
665inline std::vector< double >
675 cached_ntree_ = std::shared_ptr< Ntree< D, size_t > >();
683 if ( cached_vector_ != 0 )
685 delete cached_vector_;
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Abstract base class for Layers of unspecified dimension.
Definition layer.h:52
AbstractLayer()
Definition layer.h:54
virtual double compute_distance(const std::vector< double > &from_pos, const size_t lid) const =0
Returns distance to node from given position.
virtual void set_status(const Dictionary &)=0
Change properties of the layer according to the entries in the dictionary.
virtual void clear_vector_cache_() const =0
Clear the cache for global position information.
static NodeCollectionMetadataPTR cached_ntree_md_
Metadata for the layer for which we cache global position information.
Definition layer.h:187
virtual std::vector< double > compute_displacement(const std::vector< double > &from_pos, const size_t to) const =0
Returns displacement of node from given position.
NodeCollectionPTR node_collection_
The NodeCollection to which the layer belongs.
Definition layer.h:182
void set_node_collection(NodeCollectionPTR)
Definition layer.h:524
NodeCollectionMetadataPTR get_metadata() const
Gets metadata of the NodeCollection to which this layer belongs.
Definition layer.cpp:159
virtual std::vector< double > get_position_vector(const size_t lid) const =0
Get position of node.
virtual ~AbstractLayer()
Definition layer.cpp:47
virtual std::vector< size_t > get_global_nodes(const MaskPTR mask, const std::vector< double > &anchor, bool allow_oversized, NodeCollectionPTR node_collection)=0
Return a vector with the node IDs of the nodes inside the mask.
virtual void get_status(Dictionary &, NodeCollection const *const) const =0
Export properties of the layer by setting entries in the status dictionary, respects slicing of given...
virtual double compute_distance(const std::vector< double > &from_pos, const std::vector< double > &to_pos) const =0
virtual void connect(NodeCollectionPTR source_nc, AbstractLayerPTR target, NodeCollectionPTR target_nc, ConnectionCreator &connector)=0
Connect this layer to the given target layer.
static NodeCollectionPTR create_layer(const Dictionary &)
Factory function for layers.
Definition layer.cpp:52
NodeCollectionPTR get_node_collection()
Definition layer.h:531
virtual unsigned int get_num_dimensions() const =0
virtual void dump_nodes(std::ostream &os) const =0
Write layer data to stream.
virtual double compute_displacement(const std::vector< double > &from_pos, const std::vector< double > &to_pos, const unsigned int dimension) const =0
static NodeCollectionMetadataPTR cached_vector_md_
Metadata for the layer for which we cache global position information.
Definition layer.h:192
virtual void dump_connections(std::ostream &out, NodeCollectionPTR node_collection, AbstractLayerPTR target_layer, const std::string &syn_model)=0
Dumps information about all connections of the given type having their source in the given layer to t...
virtual void clear_ntree_cache_() const =0
Clear the cache for global position information.
Exception to be thrown if a status parameter is incomplete or inconsistent.
Definition exceptions.h:680
This class is a representation of the dictionary of connection properties given as an argument to the...
Definition connection_creator.h:63
Mask oriented in the opposite direction.
Definition mask.h:633
Abstract base class for Layer of given dimension (D=2 or 3).
Definition layer.h:218
void clear_vector_cache_() const override
Clear the cache for global position information.
Definition layer.h:681
std::vector< double > get_position_vector(const size_t sind) const override
Definition layer.h:666
double compute_distance(const Position< D > &from_pos, const size_t lid) const
Returns distance to node from given position.
Definition layer.h:639
virtual void insert_global_positions_ntree_(Ntree< D, size_t > &tree, NodeCollectionPTR node_collection)=0
Insert global position info into ntree.
virtual Position< D > get_position(size_t sind) const =0
Get position of node.
std::shared_ptr< Ntree< D, size_t > > get_global_positions_ntree(NodeCollectionPTR node_collection)
Get positions for all nodes in layer, including nodes on other MPI processes.
Definition layer_impl.h:140
void clear_ntree_cache_() const override
Clear the cache for global position information.
Definition layer.h:673
Position< D > extent_
size of layer
Definition layer.h:440
Layer()
Creates an empty layer.
Definition layer.h:590
Position< D > get_center() const
Definition layer.h:268
Position< D > compute_displacement(const Position< D > &from_pos, const Position< D > &to_pos) const
Returns displacement of a position from another position.
Definition layer_impl.h:46
~Layer() override
Definition layer.h:610
static std::vector< std::pair< Position< D >, size_t > > * cached_vector_
Definition layer.h:447
std::shared_ptr< Ntree< D, size_t > > do_get_global_positions_ntree_(NodeCollectionPTR node_collection)
Definition layer_impl.h:189
unsigned int get_num_dimensions() const override
Definition layer.h:241
void set_status(const Dictionary &) override
Change properties of the layer according to the entries in the dictionary.
Definition layer_impl.h:80
void connect(NodeCollectionPTR source_nc, AbstractLayerPTR target, NodeCollectionPTR target_nc, ConnectionCreator &connector) override
Connect this layer to the given target layer.
Definition layer_impl.h:117
void dump_nodes(std::ostream &os) const override
Write layer data to stream.
Definition layer_impl.h:283
std::bitset< D > get_periodic_mask() const
Definition layer.h:277
std::vector< size_t > get_global_nodes(const MaskPTR mask, const std::vector< double > &anchor, bool allow_oversized, NodeCollectionPTR node_collection) override
Return a vector with the node IDs of the nodes inside the mask.
Definition layer_impl.h:267
const Position< D > & get_extent() const
Definition layer.h:259
void get_status(Dictionary &, NodeCollection const *const) const override
Retrieve status, slice according to node collection if given.
Definition layer_impl.h:93
std::bitset< D > periodic_
periodic b.c.
Definition layer.h:441
static std::shared_ptr< Ntree< D, size_t > > cached_ntree_
Global position information for a single layer.
Definition layer.h:446
void dump_connections(std::ostream &out, NodeCollectionPTR node_collection, AbstractLayerPTR target_layer, const std::string &syn_model) override
Dumps information about all connections of the given type having their source in the given layer to t...
Definition layer_impl.h:297
std::vector< std::pair< Position< D >, size_t > > * get_global_positions_vector(NodeCollectionPTR node_collection)
Definition layer_impl.h:210
const Position< D > & get_lower_left() const
Definition layer.h:250
virtual void insert_global_positions_vector_(std::vector< std::pair< Position< D >, size_t > > &, NodeCollectionPTR)=0
Insert global position info into vector.
Position< D > lower_left_
lower left corner (minimum coordinates) of layer
Definition layer.h:439
Abstract base class for masks with given dimension.
Definition mask.h:101
Class for applying masks to layers.
Definition layer.h:458
void check_mask_(Layer< D > &layer, bool allow_oversized)
Will check that the mask can be applied to the layer.
Definition layer_impl.h:355
~MaskedLayer()
Definition layer.h:564
Ntree< D, size_t >::masked_iterator begin(const Position< D > &anchor)
Iterate over nodes inside mask.
Definition layer.h:570
Ntree< D, size_t >::masked_iterator end()
Definition layer.h:584
MaskedLayer(Layer< D > &layer, const MaskPTR mask, bool allow_oversized, NodeCollectionPTR node_collection)
Regular constructor.
Definition layer.h:537
std::shared_ptr< Ntree< D, size_t > > ntree_
Definition layer.h:519
MaskPTR mask_
Definition layer.h:520
Superclass for NodeCollections.
Definition node_collection.h:565
Iterator iterating the nodes in a Quadtree inside a Mask.
Definition ntree.h:153
A Ntree object represents a subtree or leaf in a Ntree structure.
Definition ntree.h:55
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
std::shared_ptr< AbstractMask > MaskPTR
Definition mask.h:44
std::shared_ptr< AbstractLayer > AbstractLayerPTR
Definition layer.h:46
std::shared_ptr< NodeCollectionMetadata > NodeCollectionMetadataPTR
Definition node_collection.h:51
std::vector< std::vector< double > > displacement(NodeCollectionPTR layer_to_nc, NodeCollectionPTR layer_from_nc)
Definition spatial.cpp:137
Dictionary get_metadata(const NodeCollectionPTR nc)
Definition nest.cpp:410
std::shared_ptr< NodeCollection > NodeCollectionPTR
Definition node_collection.h:50
std::vector< std::vector< double > > get_position(NodeCollectionPTR layer_nc)
Definition spatial.cpp:83