section.h
1 #pragma once
2 
3 #include <functional>
4 
5 #include <morphio/properties.h>
6 #include <morphio/section.h>
7 #include <morphio/types.h>
8 
9 #include <morphio/section_iterators.hpp>
10 
11 namespace morphio {
12 namespace mut {
13 
17 
19 class Section: public std::enable_shared_from_this<Section>
20 {
21  public:
22  ~Section() = default;
23 
27  inline uint32_t id() const noexcept;
28 
32  inline SectionType& type() noexcept;
33  inline const SectionType& type() const noexcept;
39  inline std::vector<Point>& points() noexcept;
40  inline const std::vector<Point>& points() const noexcept;
46  inline std::vector<morphio::floatType>& diameters() noexcept;
47  inline const std::vector<morphio::floatType>& diameters() const noexcept;
53  inline std::vector<morphio::floatType>& perimeters() noexcept;
54  inline const std::vector<morphio::floatType>& perimeters() const noexcept;
60  inline Property::PointLevel& properties() noexcept;
61  inline const Property::PointLevel& properties() const noexcept;
63  //
65  // Methods that were previously in mut::Morphology
66  //
68 
74  const std::shared_ptr<Section>& parent() const;
75 
79  bool isRoot() const;
80 
84  const std::vector<std::shared_ptr<Section>>& children() const;
85 
86  depth_iterator depth_begin() const;
87  depth_iterator depth_end() const;
88 
89  breadth_iterator breadth_begin() const;
90  breadth_iterator breadth_end() const;
91 
92  upstream_iterator upstream_begin() const;
93  upstream_iterator upstream_end() const;
94 
95  std::shared_ptr<Section> appendSection(const morphio::Section&, bool recursive = false);
96 
97  std::shared_ptr<Section> appendSection(std::shared_ptr<Section> original_section,
98  bool recursive = false);
99 
100  std::shared_ptr<Section> appendSection(
101  const Property::PointLevel&, SectionType sectionType = SectionType::SECTION_UNDEFINED);
102 
103  private:
104  friend class Morphology;
105 
106  Section(Morphology*, unsigned int id, SectionType type, const Property::PointLevel&);
107  Section(Morphology*, unsigned int id, const morphio::Section& section);
108  Section(Morphology*, unsigned int id, const Section&);
109 
110 
114  void throwIfNoOwningMorphology() const;
115 
119  Morphology* getOwningMorphologyOrThrow() const;
120 
121  Morphology* _morphology;
122  Property::PointLevel _pointProperties;
123  uint32_t _id;
124  SectionType _sectionType;
125 };
126 
127 std::ostream& operator<<(std::ostream&, const std::shared_ptr<Section>&);
128 
129 inline uint32_t Section::id() const noexcept {
130  return _id;
131 }
132 
133 inline SectionType& Section::type() noexcept {
134  return _sectionType;
135 }
136 
137 inline const SectionType& Section::type() const noexcept {
138  return _sectionType;
139 }
140 
141 inline std::vector<Point>& Section::points() noexcept {
142  return _pointProperties._points;
143 }
144 
145 inline const std::vector<Point>& Section::points() const noexcept {
146  return _pointProperties._points;
147 }
148 
149 inline std::vector<morphio::floatType>& Section::diameters() noexcept {
150  return _pointProperties._diameters;
151 }
152 
153 inline const std::vector<morphio::floatType>& Section::diameters() const noexcept {
154  return _pointProperties._diameters;
155 }
156 
157 inline std::vector<morphio::floatType>& Section::perimeters() noexcept {
158  return _pointProperties._perimeters;
159 }
160 
161 inline const std::vector<morphio::floatType>& Section::perimeters() const noexcept {
162  return _pointProperties._perimeters;
163 }
164 
166  return _pointProperties;
167 }
168 
169 inline const Property::PointLevel& Section::properties() const noexcept {
170  return _pointProperties;
171 }
172 
173 } // namespace mut
174 } // namespace morphio
175 
176 std::ostream& operator<<(std::ostream&, const morphio::mut::Section&);
Definition: section_iterators.hpp:109
Definition: section_iterators.hpp:53
std::vector< Point > & points() noexcept
Definition: section.h:141
std::vector< morphio::floatType > & perimeters() noexcept
Definition: section.h:157
uint32_t id() const noexcept
Definition: section.h:129
std::vector< morphio::floatType > & diameters() noexcept
Definition: section.h:149
breadth_iterator_t< Section, Morphology > breadth_iterator
Definition: morphology.h:11
const std::vector< std::shared_ptr< Section > > & children() const
Definition: dendritic_spine.h:9
const std::shared_ptr< Section > & parent() const
Definition: section.h:19
Definition: section_iterators.hpp:81
SectionType & type() noexcept
Definition: section.h:133
Property::PointLevel & properties() noexcept
Definition: section.h:165
depth_iterator_t< Section, Morphology > depth_iterator
Definition: morphology.h:13
Definition: properties.h:55
SectionType
Definition: enums.h:61
Definition: section.h:36