NEST main@caf0ae8
 
Loading...
Searching...
No Matches
spatial.h
Go to the documentation of this file.
1/*
2 * spatial.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 SPATIAL_H
24#define SPATIAL_H
25
26// C++ includes:
27#include <vector>
28
29// Includes from nestkernel:
30#include "nest_types.h"
31#include "node_collection.h"
32
33// Includes from spatial:
34#include "free_layer.h"
35#include "layer.h"
36#include "mask.h"
37
38
39namespace nest
40{
41
46{
47public:
49 ~LayerMetadata() override
50 {
51 }
52
53 void set_status( const Dictionary&, bool ) override {};
54
55 void
56 get_status( Dictionary& d, NodeCollection const* const nc ) const override
57 {
58 layer_->get_status( d, nc );
59 }
60
61 void
62 get_status( Dictionary& d, const NodeCollectionPTR nc ) const override
63 {
64 get_status( d, nc.get() );
65 }
66
69 get_layer() const
70 {
71 return layer_;
72 }
73
74 // Using string as enum would make stuff more complicated
75 std::string
76 get_type() const override
77 {
78 return "spatial";
79 }
80
81 void
82 set_first_node_id( size_t node_id ) override
83 {
84 first_node_id_ = node_id;
85 }
86
87 size_t
88 get_first_node_id() const override
89 {
90 return first_node_id_;
91 }
92
93 bool
94 operator==( const NodeCollectionMetadataPTR rhs ) const override
95 {
96 const auto rhs_layer_metadata = dynamic_cast< LayerMetadata* >( rhs.get() );
97 if ( not rhs_layer_metadata )
98 {
99 return false;
100 }
101 // Compare status dictionaries of this layer and rhs layer
102 Dictionary dict;
103 Dictionary rhs_dict;
104
105 // Since we do not have access to the node collection here, we
106 // compare based on all metadata, irrespective of any slicing
107 get_status( dict, /* nc */ nullptr );
108 rhs_layer_metadata->get_status( rhs_dict, /* nc */ nullptr );
109 return dict == rhs_dict;
110 }
111
112private:
115};
116
118NodeCollectionPTR create_layer( const Dictionary& layer_dict );
119std::vector< std::vector< double > > get_position( NodeCollectionPTR layer_nc );
120std::vector< double > get_position( const size_t node_id );
121std::vector< std::vector< double > > displacement( NodeCollectionPTR layer_to_nc, NodeCollectionPTR layer_from_nc );
122std::vector< std::vector< double > > displacement( NodeCollectionPTR layer_nc,
123 const std::vector< std::vector< double > >& point );
124std::vector< double > distance( NodeCollectionPTR layer_to_nc, NodeCollectionPTR layer_from_nc );
125std::vector< double > distance( NodeCollectionPTR layer_nc, const std::vector< std::vector< double > >& point );
126std::vector< double > distance( const std::vector< ConnectionID >& conns );
127MaskPTR create_mask( const Dictionary& mask_dict );
129select_nodes_by_mask( const NodeCollectionPTR layer_nc, const std::vector< double >& anchor, const MaskPTR mask );
130bool inside( const std::vector< double >& point, const MaskPTR mask );
131MaskPTR intersect_mask( const MaskPTR mask1, const MaskPTR mask2 );
132MaskPTR union_mask( const MaskPTR mask1, const MaskPTR mask2 );
133MaskPTR minus_mask( const MaskPTR mask1, const MaskPTR mask2 );
134void connect_layers( NodeCollectionPTR source_nc, NodeCollectionPTR target_nc, const Dictionary& dict );
135void dump_layer_nodes( NodeCollectionPTR layer_nc, const std::string& filename );
136void dump_layer_connections( const NodeCollectionPTR source_layer,
137 const NodeCollectionPTR target_layer,
138 const std::string& synapse_model,
139 const std::string& filename );
141}
142
143#endif /* SPATIAL_H */
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Class containing spatial information to be used as metadata in a NodeCollection.
Definition spatial.h:46
const AbstractLayerPTR layer_
layer object
Definition spatial.h:113
~LayerMetadata() override
Definition spatial.h:49
size_t first_node_id_
Definition spatial.h:114
void set_first_node_id(size_t node_id) override
Definition spatial.h:82
bool operator==(const NodeCollectionMetadataPTR rhs) const override
Definition spatial.h:94
size_t get_first_node_id() const override
Definition spatial.h:88
void set_status(const Dictionary &, bool) override
Definition spatial.h:53
void get_status(Dictionary &d, const NodeCollectionPTR nc) const override
Definition spatial.h:62
void get_status(Dictionary &d, NodeCollection const *const nc) const override
Retrieve status information sliced according to slicing of node collection.
Definition spatial.h:56
const AbstractLayerPTR get_layer() const
Returns pointer to object with layer representation.
Definition spatial.h:69
std::string get_type() const override
Definition spatial.h:76
Class for Metadata attached to NodeCollection.
Definition node_collection.h:60
Superclass for NodeCollections.
Definition node_collection.h:565
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
NodeCollectionPTR select_nodes_by_mask(const NodeCollectionPTR layer_nc, const std::vector< double > &anchor, const MaskPTR mask)
Definition spatial.cpp:446
std::vector< double > distance(NodeCollectionPTR layer_to_nc, NodeCollectionPTR layer_from_nc)
Definition spatial.cpp:224
MaskPTR create_mask(const std::string &name, const Dictionary &d)
Create a new Mask object using the mask factory.
Definition nest.h:284
void dump_layer_connections(const NodeCollectionPTR source_layer_nc, const NodeCollectionPTR target_layer_nc, const std::string &syn_model, const std::string &filename)
Definition spatial.cpp:558
std::shared_ptr< AbstractMask > MaskPTR
Definition mask.h:44
AbstractLayerPTR get_layer(NodeCollectionPTR nc)
Definition spatial.cpp:58
MaskPTR union_mask(const MaskPTR mask1, const MaskPTR mask2)
Definition spatial.cpp:511
MaskPTR intersect_mask(const MaskPTR mask1, const MaskPTR mask2)
Definition spatial.cpp:505
void connect_layers(NodeCollectionPTR source_nc, NodeCollectionPTR target_nc, const Dictionary &connection_dict)
Definition spatial.cpp:524
std::shared_ptr< AbstractLayer > AbstractLayerPTR
Definition layer.h:46
std::shared_ptr< NodeCollectionMetadata > NodeCollectionMetadataPTR
Definition node_collection.h:51
bool inside(const std::vector< double > &point, const MaskPTR mask)
Definition spatial.cpp:499
std::vector< std::vector< double > > displacement(NodeCollectionPTR layer_to_nc, NodeCollectionPTR layer_from_nc)
Definition spatial.cpp:137
MaskPTR minus_mask(const MaskPTR mask1, const MaskPTR mask2)
Definition spatial.cpp:517
void dump_layer_nodes(const NodeCollectionPTR layer_nc, const std::string &filename)
Definition spatial.cpp:545
NodeCollectionPTR create_layer(const Dictionary &layer_dict)
Definition spatial.cpp:71
std::shared_ptr< NodeCollection > NodeCollectionPTR
Definition node_collection.h:50
std::vector< std::vector< double > > get_position(NodeCollectionPTR layer_nc)
Definition spatial.cpp:83
Dictionary get_layer_status(NodeCollectionPTR)
Definition spatial.cpp:575