section.h
1 #pragma once
2 
3 #include <memory> // std::shared_ptr
4 
5 #include <morphio/morphology.h>
6 #include <morphio/properties.h>
7 #include <morphio/section_base.h>
8 #include <morphio/section_iterators.hpp>
9 #include <morphio/types.h>
10 
11 namespace morphio {
12 
13 using upstream_iterator = upstream_iterator_t<Section>;
14 using breadth_iterator = breadth_iterator_t<Section, Morphology>;
15 using depth_iterator = depth_iterator_t<Section, Morphology>;
16 
36 class Section: public SectionBase<Section>
37 {
40 
41  public:
44  return depth_iterator(*this);
45  }
46  depth_iterator depth_end() const {
47  return depth_iterator();
48  }
49 
52  return breadth_iterator(*this);
53  }
54  breadth_iterator breadth_end() const {
55  return breadth_iterator();
56  }
57 
60  return upstream_iterator(*this);
61  }
62  upstream_iterator upstream_end() const {
63  return upstream_iterator();
64  }
65 
71  range<const Point> points() const {
72  return get<Property::Point>();
73  }
74 
80  range<const floatType> diameters() const {
81  return get<Property::Diameter>();
82  }
83 
89  range<const floatType> perimeters() const {
90  return get<Property::Perimeter>();
91  }
92 
94  SectionType type() const {
95  return properties_->get<Property::SectionType>()[id_];
96  }
97 
102  bool isHeterogeneous(bool downstream = true) const;
103 
105  bool hasSameShape(const Section& other) const noexcept;
106 
107  friend class mut::Section;
108  friend Section Morphology::section(uint32_t) const;
109  friend class SectionBase<Section>;
110 
111  protected:
112  Section(uint32_t id, const std::shared_ptr<Property::Properties>& properties)
113  : SectionBase(id, properties) {}
114 };
115 
116 } // namespace morphio
117 
118 std::ostream& operator<<(std::ostream& os, const morphio::Section& section);
morphio::depth_iterator_t
Definition: section_iterators.hpp:82
morphio::enums::SectionType
SectionType
Definition: enums.h:62
morphio::Section
Definition: section.h:36
morphio::Section::hasSameShape
bool hasSameShape(const Section &other) const noexcept
Return true if the both sections have the same points, diameters and perimeters.
morphio::Property::SectionType
Definition: properties.h:37
morphio::Section::type
SectionType type() const
Return the morphological type of this section (dendrite, axon, ...)
Definition: section.h:94
morphio::Section::diameters
range< const floatType > diameters() const
Definition: section.h:80
morphio::Section::perimeters
range< const floatType > perimeters() const
Definition: section.h:89
morphio::Property::Section
Definition: properties.h:23
morphio::Section::upstream_begin
upstream_iterator upstream_begin() const
Upstream iterator.
Definition: section.h:59
morphio::Property::Point
Definition: properties.h:33
morphio::upstream_iterator_t
Definition: section_iterators.hpp:111
morphio::Section::breadth_begin
breadth_iterator breadth_begin() const
Breadth first iterator.
Definition: section.h:51
morphio::Section::depth_begin
depth_iterator depth_begin() const
Depth first iterator.
Definition: section.h:43
morphio::Section::isHeterogeneous
bool isHeterogeneous(bool downstream=true) const
morphio::Section::points
range< const Point > points() const
Definition: section.h:71
morphio::breadth_iterator_t
Definition: section_iterators.hpp:53
morphio::mut::Section
Definition: section.h:19
morphio::SectionBase< Section >::id
uint32_t id() const noexcept
Definition: section_base.h:49
morphio::SectionBase
Definition: section_base.h:25
morphio::Morphology::section
Section section(uint32_t id) const