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