Medical Imaging Interaction Toolkit  2023.12.99-b884b24c
Medical Imaging Interaction Toolkit
mitkROI.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 mitkROI_h
14 #define mitkROI_h
15 
16 #include <mitkBaseData.h>
17 #include <MitkROIExports.h>
18 
19 namespace mitk
20 {
58  class MITKROI_EXPORT ROI : public BaseData
59  {
60  public:
66  {
67  public:
68  using PointsType = std::map<TimeStepType, Point3D>;
69  using PropertyListsType = std::map<TimeStepType, PropertyList::Pointer>;
70 
71  Element();
72  explicit Element(unsigned int id);
73  ~Element() = default;
74 
80  BaseProperty::ConstPointer GetConstProperty(const std::string& propertyKey, const std::string& contextName = "", bool fallBackOnDefaultContext = true) const override;
81  BaseProperty::ConstPointer GetConstProperty(const std::string& propertyKey, TimeStepType t, bool fallBackOnDefaultContext = true) const;
82 
88  std::vector<std::string> GetPropertyKeys(const std::string& contextName = "", bool includeDefaultContext = false) const override;
89  std::vector<std::string> GetPropertyKeys(TimeStepType t, bool includeDefaultContext = false) const;
90 
93  std::vector<std::string> GetPropertyContextNames() const override;
94 
100  BaseProperty* GetNonConstProperty(const std::string& propertyKey, const std::string& contextName = "", bool fallBackOnDefaultContext = true) override;
101  BaseProperty* GetNonConstProperty(const std::string& propertyKey, TimeStepType t, bool fallBackOnDefaultContext = true);
102 
108  void SetProperty(const std::string& propertyKey, BaseProperty* property, const std::string& contextName = "", bool fallBackOnDefaultContext = false) override;
109  void SetProperty(const std::string& propertyKey, BaseProperty* property, TimeStepType t, bool fallBackOnDefaultContext = false);
110 
116  void RemoveProperty(const std::string& propertyKey, const std::string& contextName = "", bool fallBackOnDefaultContext = false) override;
117  void RemoveProperty(const std::string& propertyKey, TimeStepType t, bool fallBackOnDefaultContext = false);
118 
119  unsigned int GetID() const;
120  void SetID(unsigned int id);
121 
124  bool HasTimeStep(TimeStepType t) const;
125 
128  bool HasTimeSteps() const;
129 
132  std::vector<TimeStepType> GetTimeSteps() const;
133 
134  Point3D GetMin(TimeStepType t = 0) const;
135  void SetMin(const Point3D& min, TimeStepType t = 0);
136 
137  Point3D GetMax(TimeStepType t = 0) const;
138  void SetMax(const Point3D& max, TimeStepType t = 0);
139 
140  PropertyList* GetDefaultProperties() const;
141  void SetDefaultProperties(PropertyList* properties);
142 
145  PropertyList* GetProperties(TimeStepType t = 0) const;
146 
147  void SetProperties(PropertyList* properties, TimeStepType t = 0);
148 
149  private:
150  unsigned int m_ID;
151  PointsType m_Min;
152  PointsType m_Max;
153  PropertyList::Pointer m_DefaultProperties;
154  PropertyListsType m_Properties;
155  };
156 
158  itkFactorylessNewMacro(Self)
159  itkCloneMacro(Self)
160 
161  using ElementsType = std::map<unsigned int, Element>;
162  using Iterator = ElementsType::iterator;
163  using ConstIterator = ElementsType::const_iterator;
164 
165  size_t GetNumberOfElements() const;
166 
171  void AddElement(const Element& element);
172 
173  const Element& GetElement(unsigned int id) const;
174  Element& GetElement(unsigned int id);
175 
176  ConstIterator begin() const;
177  ConstIterator end() const;
178 
179  Iterator begin();
180  Iterator end();
181 
182  void SetRequestedRegionToLargestPossibleRegion() override;
183  bool RequestedRegionIsOutsideOfTheBufferedRegion() override;
184  bool VerifyRequestedRegion() override;
185  void SetRequestedRegion(const itk::DataObject* data) override;
186 
187  protected:
189 
190  ROI();
191  ROI(const Self& other);
192  ~ROI() override;
193 
194  private:
195  ElementsType m_Elements;
196  };
197 
198  MITKROI_EXPORT void to_json(nlohmann::json& j, const ROI::Element& roi);
199  MITKROI_EXPORT void from_json(const nlohmann::json& j, ROI::Element& roi);
200 }
201 
202 #endif
mitk::BaseProperty
Abstract base class for properties.
Definition: mitkBaseProperty.h:36
mitk::DICOMIOHelper::SetProperties
MITKDICOM_EXPORT void SetProperties(BaseData *image, const FindingsListVectorType &findings)
mitk::to_json
void to_json(nlohmann::json &j, const GenericLookupTable< T > &t)
Definition: mitkGenericLookupTable.h:98
MitkROIExports.h
itk::SmartPointer< const Self >
mitk::from_json
void from_json(const nlohmann::json &, GenericLookupTable< T > &)
Definition: mitkGenericLookupTable.h:104
mitk::ROI
A collection of region of interests (ROIs).
Definition: mitkROI.h:58
mitk::ROI::Iterator
ElementsType::iterator Iterator
Definition: mitkROI.h:162
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
json
nlohmann::json json
Definition: mitkModelTestFixture.h:29
mitk::Point< ScalarType, 3 >
mitk::ROI::Element::PropertyListsType
std::map< TimeStepType, PropertyList::Pointer > PropertyListsType
Definition: mitkROI.h:69
mitk::ROI::Element::PointsType
std::map< TimeStepType, Point3D > PointsType
Definition: mitkROI.h:68
mitk::PropertyList
Key-value list holding instances of BaseProperty.
Definition: mitkPropertyList.h:56
mitk::BaseData
Base of all data objects.
Definition: mitkBaseData.h:42
mitk::ROI::ConstIterator
ElementsType::const_iterator ConstIterator
Definition: mitkROI.h:163
map
Definition: mitkFastSymmetricForcesDemonsMultiResDefaultRegistrationAlgorithm_ProfileResource.h:26
itk
SET FUNCTIONS.
Definition: itkIntelligentBinaryClosingFilter.h:30
mitk::TimeStepType
std::size_t TimeStepType
Definition: mitkTimeGeometry.h:27
mitkCloneMacro
#define mitkCloneMacro(classname)
Definition: mitkCommon.h:154
mitk::ROIMapperHelper::GetConstProperty
const T * GetConstProperty(const std::string &propertyKey, const ROI::Element &roi, TimeStepType t)
Syntactic sugar for getting ROI properties.
Definition: mitkROIMapperHelper.h:48
MITKROI_EXPORT
#define MITKROI_EXPORT
Definition: MitkROIExports.h:15
mitkBaseData.h
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::IPropertyOwner
Definition: mitkIPropertyOwner.h:22
mitk::ROI::ElementsType
std::map< unsigned int, Element > ElementsType
Definition: mitkROI.h:161
mitk::ROI::Element
Encapsulates a single (possibly time-resolved) ROI.
Definition: mitkROI.h:65
mitk::ROIMapperHelper::SetDefaultProperties
void SetDefaultProperties(DataNode *node, BaseRenderer *renderer, bool override)
Set common default properties for both 2-d and 3-d ROI mappers.