properties.h
1 #pragma once
2 
3 #include <map>
4 #include <string> // std::string
5 #include <vector> // std::vector
6 
7 #include <morphio/types.h>
8 
9 namespace morphio {
10 namespace vasculature {
11 namespace property {
12 
13 struct VascSection {
14  // offset
15  // refers to the index in the points vector from which the section begins
16  using Type = unsigned int;
17 };
18 
19 struct Point {
20  using Type = morphio::Point;
21 };
22 
23 struct SectionType {
25 };
26 
27 struct Diameter {
28  using Type = floatType;
29 };
30 
35 struct Connection {
36  using Type = std::array<unsigned int, 2>;
37 };
38 
41  std::vector<Point::Type> _points;
42  std::vector<Diameter::Type> _diameters;
43 
44  VascPointLevel() = default;
45  VascPointLevel(const std::vector<Point::Type>& points,
46  const std::vector<Diameter::Type>& diameters);
47  VascPointLevel(const VascPointLevel& data);
48  VascPointLevel(const VascPointLevel& data, SectionRange range);
49  VascPointLevel& operator=(const VascPointLevel&) = default;
50 };
51 
53 struct VascEdgeLevel {
54  std::vector<morphio::floatType> leakiness;
55 };
56 
59  std::vector<VascSection::Type> _sections;
60  std::vector<SectionType::Type> _sectionTypes;
61  std::map<uint32_t, std::vector<uint32_t>> _predecessors;
62  std::map<uint32_t, std::vector<uint32_t>> _successors;
63  bool operator==(const VascSectionLevel& other) const;
64  bool operator!=(const VascSectionLevel& other) const;
65 };
66 
68 struct Properties {
69  VascPointLevel _pointLevel;
70  VascEdgeLevel _edgeLevel;
71  VascSectionLevel _sectionLevel;
72  std::vector<Connection::Type> _connectivity;
73 
74  template <typename T>
75  std::vector<typename T::Type>& get_mut() noexcept;
76 
77  template <typename T>
78  const std::vector<typename T::Type>& get() const noexcept;
79 
80  inline const std::map<uint32_t, std::vector<uint32_t>>& predecessors() const noexcept;
81  inline const std::map<uint32_t, std::vector<uint32_t>>& successors() const noexcept;
82 
83  bool operator==(const Properties& other) const;
84  bool operator!=(const Properties& other) const;
85 };
86 
87 inline const std::map<uint32_t, std::vector<uint32_t>>& Properties::predecessors() const noexcept {
88  return _sectionLevel._predecessors;
89 }
90 inline const std::map<uint32_t, std::vector<uint32_t>>& Properties::successors() const noexcept {
91  return _sectionLevel._successors;
92 }
93 
94 std::ostream& operator<<(std::ostream& os, const Properties& properties);
95 std::ostream& operator<<(std::ostream& os, const VascPointLevel& pointLevel);
96 
97 #define INSTANTIATE_TEMPLATE_GET(T, M) \
98  template <> \
99  inline std::vector<T::Type>& Properties::get_mut<T>() noexcept { \
100  return M; \
101  } \
102  template <> \
103  inline const std::vector<T::Type>& Properties::get<T>() const noexcept { \
104  return M; \
105  }
106 
107 INSTANTIATE_TEMPLATE_GET(VascSection, _sectionLevel._sections)
108 INSTANTIATE_TEMPLATE_GET(Point, _pointLevel._points)
109 INSTANTIATE_TEMPLATE_GET(Connection, _connectivity)
110 INSTANTIATE_TEMPLATE_GET(SectionType, _sectionLevel._sectionTypes)
111 INSTANTIATE_TEMPLATE_GET(Diameter, _pointLevel._diameters)
112 
113 #undef INSTANTIATE_TEMPLATE_GET
114 
115 
116 } // namespace property
117 } // namespace vasculature
118 } // namespace morphio
morphio::vasculature::property::Point
Definition: properties.h:19
morphio::enums::SectionType
SectionType
Definition: enums.h:62
morphio::vasculature::property::Properties
Definition: properties.h:68
morphio::vasculature::property::Diameter
Definition: properties.h:27
morphio::vasculature::property::VascPointLevel
Definition: properties.h:40
morphio::vasculature::property::VascEdgeLevel
Definition: properties.h:53
morphio::vasculature::property::VascSectionLevel
Definition: properties.h:58
morphio::vasculature::property::Connection
Definition: properties.h:35
morphio::vasculature::property::VascSection
Definition: properties.h:13
morphio::enums::VascularSectionType
VascularSectionType
Definition: enums.h:99
morphio::vasculature::property::SectionType
Definition: properties.h:23