Medical Imaging Interaction Toolkit  2018.4.99-b20efe7f
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
std::vector< ID > IDVector
std::vector< LesionClass > LesionClassVector
void SetDateFromString(const std::string &dateAsString)
DataCollection - Class to facilitate loading/accessing structured data.
std::vector< Lesion > LesionVector
std::vector< ControlPoint > ControlPointVector
The concept of an examination period. An examination period holds a vector of control point UIDs...
int DistanceInDays(const ControlPoint &other) const
std::string InformationType
std::vector< InformationType > InformationTypeVector
bool operator<(const ControlPoint &other) const
std::vector< ExaminationPeriod > ExaminationPeriodVector