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 {
23  using Type = morphio::VascularSectionType;
24 };
25 
26 struct Diameter {
27  using Type = floatType;
28 };
29 
30 struct Connection {
31  // stores the graph connectivity between the sections
32  // If section1 is connected to section2, then the last point of section1
33  // and the first point of section2 must be equal.
34  using Type = std::array<unsigned int, 2>;
35 };
36 
38  // stores point level information
39  std::vector<Point::Type> _points;
40  std::vector<Diameter::Type> _diameters;
41 
42  VascPointLevel() = default;
43  VascPointLevel(const std::vector<Point::Type>& points,
44  const std::vector<Diameter::Type>& diameters);
45  VascPointLevel(const VascPointLevel& data);
46  VascPointLevel(const VascPointLevel& data, SectionRange range);
47  VascPointLevel& operator=(const VascPointLevel&) = default;
48 };
49 
50 struct VascEdgeLevel {
51  // stores edge level information, more attributes can be added later
52  std::vector<morphio::floatType> leakiness;
53 };
54 
56  // stores section level information
57  std::vector<VascSection::Type> _sections;
58  std::vector<SectionType::Type> _sectionTypes;
59  std::map<uint32_t, std::vector<uint32_t>> _predecessors;
60  std::map<uint32_t, std::vector<uint32_t>> _successors;
61  bool operator==(const VascSectionLevel& other) const;
62  bool operator!=(const VascSectionLevel& other) const;
63 };
64 
65 struct Properties {
66  VascPointLevel _pointLevel;
67  VascEdgeLevel _edgeLevel;
68  VascSectionLevel _sectionLevel;
69  std::vector<Connection::Type> _connectivity;
70 
71  template <typename T>
72  std::vector<typename T::Type>& get_mut() noexcept;
73 
74  template <typename T>
75  const std::vector<typename T::Type>& get() const noexcept;
76 
77  inline const std::map<uint32_t, std::vector<uint32_t>>& predecessors() const noexcept;
78  inline const std::map<uint32_t, std::vector<uint32_t>>& successors() const noexcept;
79 
80  bool operator==(const Properties& other) const;
81  bool operator!=(const Properties& other) const;
82 };
83 
84 inline const std::map<uint32_t, std::vector<uint32_t>>& Properties::predecessors() const noexcept {
85  return _sectionLevel._predecessors;
86 }
87 inline const std::map<uint32_t, std::vector<uint32_t>>& Properties::successors() const noexcept {
88  return _sectionLevel._successors;
89 }
90 
91 std::ostream& operator<<(std::ostream& os, const Properties& properties);
92 std::ostream& operator<<(std::ostream& os, const VascPointLevel& pointLevel);
93 
94 #define INSTANTIATE_TEMPLATE_GET(T, M) \
95  template <> \
96  inline std::vector<T::Type>& Properties::get_mut<T>() noexcept { \
97  return M; \
98  } \
99  template <> \
100  inline const std::vector<T::Type>& Properties::get<T>() const noexcept { \
101  return M; \
102  }
103 
104 INSTANTIATE_TEMPLATE_GET(VascSection, _sectionLevel._sections)
105 INSTANTIATE_TEMPLATE_GET(Point, _pointLevel._points)
106 INSTANTIATE_TEMPLATE_GET(Connection, _connectivity)
107 INSTANTIATE_TEMPLATE_GET(SectionType, _sectionLevel._sectionTypes)
108 INSTANTIATE_TEMPLATE_GET(Diameter, _pointLevel._diameters)
109 
110 #undef INSTANTIATE_TEMPLATE_GET
111 
112 
113 } // namespace property
114 } // namespace vasculature
115 } // namespace morphio
Definition: endoplasmic_reticulum.h:5
Definition: properties.h:26
Definition: properties.h:18