Medical Imaging Interaction Toolkit  2022.10.99-122321bb
Medical Imaging Interaction Toolkit
mitkSemanticTypes.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef MITKSEMANTICTYPES_H
14 #define MITKSEMANTICTYPES_H
15 
16 #define BOOST_DATE_TIME_NO_LIB
17 #if defined(BOOST_ALL_DYN_LINK)
18 #undef BOOST_ALL_DYN_LINK
19 #endif
20 
21 // boost
22 #include <boost/date_time/gregorian/gregorian.hpp>
23 
24 // c++
25 #include <set>
26 #include <tuple>
27 #include <vector>
28 
29 namespace mitk
30 {
31  namespace SemanticTypes
32  {
33  using ID = std::string;
34  using CaseID = std::string;
35  using InformationType = std::string;
36 
37  /*
38  * @brief The concept of a control point.
39  */
40  struct ControlPoint
41  {
43  boost::gregorian::date date;
44 
46  {
47  date = boost::gregorian::date(boost::gregorian::min_date_time);
48  }
49 
50  // less comparison to sort containers of control points
51  bool operator<(const ControlPoint& other) const
52  {
53  return date < other.date;
54  }
55 
56  std::string ToString() const
57  {
58  std::stringstream controlPointAsString;
59  if (date.is_not_a_date())
60  {
61  return "";
62  }
63 
64  controlPointAsString << std::to_string(date.year()) << "-"
65  << std::setfill('0') << std::setw(2) << std::to_string(date.month()) << "-"
66  << std::setfill('0') << std::setw(2) << std::to_string(date.day());
67 
68  return controlPointAsString.str();
69  }
70 
71  void SetDateFromString(const std::string& dateAsString)
72  {
73  date = boost::gregorian::from_undelimited_string(dateAsString);
74  }
75 
76  int DistanceInDays(const ControlPoint& other) const
77  {
78  boost::gregorian::date_duration duration = date - other.date;
79  return std::abs(duration.days());
80  }
81  };
82 
90  {
92  std::string name = "";
93  std::vector<ID> controlPointUIDs;
94  };
95 
96  /*
97  * @brief The concept of a lesion class.
98  */
99  struct LesionClass
100  {
102  std::string classType = "";
103  };
104 
105  /*
106  * @brief The concept of a lesion.
107  */
108  struct Lesion
109  {
111  std::string name = "";
113  };
114 
115  using IDVector = std::vector<ID>;
116  using LesionVector = std::vector<Lesion>;
117  using LesionClassVector = std::vector<LesionClass>;
118  using ControlPointVector = std::vector<ControlPoint>;
119  using ExaminationPeriodVector = std::vector<ExaminationPeriod>;
120  using InformationTypeVector = std::vector<InformationType>;
121 
122  } // namespace SemanticTypes
123 } // namespace mitk
124 
125 #endif // MITKSEMANTICTYPES_H
mitk::SemanticTypes::ControlPointVector
std::vector< ControlPoint > ControlPointVector
Definition: mitkSemanticTypes.h:118
mitk::SemanticTypes::ExaminationPeriod::name
std::string name
Definition: mitkSemanticTypes.h:92
mitk::SemanticTypes::ExaminationPeriod::controlPointUIDs
std::vector< ID > controlPointUIDs
Definition: mitkSemanticTypes.h:93
mitk::SemanticTypes::ControlPoint::DistanceInDays
int DistanceInDays(const ControlPoint &other) const
Definition: mitkSemanticTypes.h:76
mitk::SemanticTypes::ControlPoint::UID
ID UID
Definition: mitkSemanticTypes.h:42
mitk::SemanticTypes::ControlPoint::date
boost::gregorian::date date
Definition: mitkSemanticTypes.h:43
mitk::SemanticTypes::ControlPoint::SetDateFromString
void SetDateFromString(const std::string &dateAsString)
Definition: mitkSemanticTypes.h:71
mitk::SemanticTypes::IDVector
std::vector< ID > IDVector
Definition: mitkSemanticTypes.h:115
mitk::SemanticTypes::LesionClass::UID
ID UID
Definition: mitkSemanticTypes.h:101
mitk::SemanticTypes::LesionClassVector
std::vector< LesionClass > LesionClassVector
Definition: mitkSemanticTypes.h:117
mitk::SemanticTypes::ControlPoint::ToString
std::string ToString() const
Definition: mitkSemanticTypes.h:56
mitk::SemanticTypes::ControlPoint
Definition: mitkSemanticTypes.h:40
mitk::SemanticTypes::Lesion
Definition: mitkSemanticTypes.h:108
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::SemanticTypes::LesionClass
Definition: mitkSemanticTypes.h:99
mitk::SemanticTypes::ExaminationPeriod::UID
ID UID
Definition: mitkSemanticTypes.h:91
mitk::SemanticTypes::InformationTypeVector
std::vector< InformationType > InformationTypeVector
Definition: mitkSemanticTypes.h:120
mitk::SemanticTypes::ID
std::string ID
Definition: mitkSemanticTypes.h:33
mitk::SemanticTypes::CaseID
std::string CaseID
Definition: mitkSemanticTypes.h:34
mitk::SemanticTypes::Lesion::name
std::string name
Definition: mitkSemanticTypes.h:111
mitk::SemanticTypes::Lesion::lesionClass
LesionClass lesionClass
Definition: mitkSemanticTypes.h:112
mitk::SemanticTypes::LesionClass::classType
std::string classType
Definition: mitkSemanticTypes.h:102
mitk::SemanticTypes::ControlPoint::operator<
bool operator<(const ControlPoint &other) const
Definition: mitkSemanticTypes.h:51
mitk::SemanticTypes::LesionVector
std::vector< Lesion > LesionVector
Definition: mitkSemanticTypes.h:116
mitk::SemanticTypes::ControlPoint::ControlPoint
ControlPoint()
Definition: mitkSemanticTypes.h:45
mitk::SemanticTypes::ExaminationPeriodVector
std::vector< ExaminationPeriod > ExaminationPeriodVector
Definition: mitkSemanticTypes.h:119
mitk::SemanticTypes::ExaminationPeriod
The concept of an examination period. An examination period holds a vector of control point UIDs....
Definition: mitkSemanticTypes.h:89
mitk::SemanticTypes::InformationType
std::string InformationType
Definition: mitkSemanticTypes.h:35
mitk::SemanticTypes::Lesion::UID
ID UID
Definition: mitkSemanticTypes.h:110