properties.h
1 /* Copyright (c) 2013-2023, EPFL/Blue Brain Project
2  *
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 #pragma once
6 
7 #include <map>
8 #include <string> // std::string
9 #include <vector> // std::vector
10 
11 #include <morphio/types.h>
12 
13 namespace morphio {
14 namespace vasculature {
15 namespace property {
16 
17 struct VascSection {
18  // offset
19  // refers to the index in the points vector from which the section begins
20  using Type = unsigned int;
21 };
22 
23 struct Point {
24  using Type = morphio::Point;
25 };
26 
27 struct SectionType {
29 };
30 
31 struct Diameter {
32  using Type = floatType;
33 };
34 
39 struct Connection {
40  using Type = std::array<unsigned int, 2>;
41 };
42 
45  std::vector<Point::Type> _points;
46  std::vector<Diameter::Type> _diameters;
47 
48  VascPointLevel() = default;
49  VascPointLevel(const std::vector<Point::Type>& points,
50  const std::vector<Diameter::Type>& diameters);
51  VascPointLevel(const VascPointLevel& data);
52  VascPointLevel(const VascPointLevel& data, SectionRange range);
53  VascPointLevel& operator=(const VascPointLevel&) = default;
54 };
55 
57 struct VascEdgeLevel {
58  std::vector<morphio::floatType> leakiness;
59 };
60 
63  std::vector<VascSection::Type> _sections;
64  std::vector<SectionType::Type> _sectionTypes;
65  std::map<uint32_t, std::vector<uint32_t>> _predecessors;
66  std::map<uint32_t, std::vector<uint32_t>> _successors;
67  bool operator==(const VascSectionLevel& other) const;
68  bool operator!=(const VascSectionLevel& other) const;
69 
70  bool diff(const VascSectionLevel& other) const;
71 };
72 
74 struct Properties {
75  VascPointLevel _pointLevel;
76  VascEdgeLevel _edgeLevel;
77  VascSectionLevel _sectionLevel;
78  std::vector<Connection::Type> _connectivity;
79 
80  template <typename T>
81  std::vector<typename T::Type>& get_mut() noexcept;
82 
83  template <typename T>
84  const std::vector<typename T::Type>& get() const noexcept;
85 
86  const std::map<uint32_t, std::vector<uint32_t>>& predecessors() const noexcept {
87  return _sectionLevel._predecessors;
88  }
89  const std::map<uint32_t, std::vector<uint32_t>>& successors() const noexcept {
90  return _sectionLevel._successors;
91  }
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:23
morphio::vasculature::property::Properties
Definition: properties.h:74
morphio::vasculature::property::Diameter
Definition: properties.h:31
morphio::vasculature::property::VascPointLevel
Definition: properties.h:44
morphio::vasculature::property::VascEdgeLevel
Definition: properties.h:57
morphio::vasculature::property::VascSectionLevel
Definition: properties.h:62
morphio::vasculature::property::Connection
Definition: properties.h:39
morphio::vasculature::property::VascSection
Definition: properties.h:17
morphio::enums::VascularSectionType
VascularSectionType
Definition: enums.h:121
morphio::vasculature::property::SectionType
Definition: properties.h:27