Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkNodePredicateGeometry.cpp
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 
14 #include "mitkDataNode.h"
15 #include "mitkImage.h"
16 
18  : m_RefGeometry(refGeometry), m_RefTimeGeometry(nullptr), m_TimePoint(relevantTimePoint), m_UseTimePoint(true), m_CheckPrecision(mitk::eps)
19 {
20  if (m_RefGeometry.IsNull()) mitkThrow() << "Invalid constructor initialization. Reference base geometry instance is nullptr pointer.";
21 }
22 
24  : m_RefGeometry(refGeometry), m_RefTimeGeometry(nullptr), m_TimePoint(0), m_UseTimePoint(false), m_CheckPrecision(mitk::eps)
25 {
26  if (m_RefGeometry.IsNull()) mitkThrow() << "Invalid constructor initialization. Reference base geometry instance is nullptr pointer.";
27 }
28 
30  : m_RefGeometry(nullptr), m_RefTimeGeometry(refGeometry), m_TimePoint(0), m_UseTimePoint(false), m_CheckPrecision(mitk::eps)
31 {
32  if (m_RefTimeGeometry.IsNull()) mitkThrow() << "Invalid constructor initialization. Reference base geometry instance is nullptr pointer.";
33 }
34 
36 {
37 }
38 
40 {
41  if (node == nullptr)
42  mitkThrow() << "NodePredicateGeometry: invalid node";
43 
44  mitk::BaseData *data = node->GetData();
45  if (data)
46  {
47  if (m_RefGeometry.IsNotNull())
48  { //check only one time point.
49  mitk::BaseGeometry::Pointer testGeometry = data->GetGeometry();
50  if (this->m_UseTimePoint)
51  {
52  testGeometry = data->GetTimeGeometry()->GetGeometryForTimePoint(m_TimePoint);
53  }
54 
55  if (testGeometry)
56  {
57  return Equal(*testGeometry, *m_RefGeometry, this->m_CheckPrecision, false);
58  }
59  }
60  else
61  { //check whole time geometry
62  return Equal(*data->GetTimeGeometry(), *m_RefTimeGeometry, this->m_CheckPrecision, false);
63  }
64  }
65 
66  return false;
67 }
bool CheckNode(const mitk::DataNode *node) const override
This method will be used to evaluate the node. Has to be overwritten in subclasses.
Base of all data objects.
Definition: mitkBaseData.h:37
NodePredicateGeometry(const BaseGeometry *refGeometry)
DataCollection - Class to facilitate loading/accessing structured data.
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
Definition: mitkBaseData.h:61
virtual BaseGeometry::Pointer GetGeometryForTimePoint(TimePointType timePoint) const =0
Returns the geometry of a specific time point.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
#define mitkThrow()
BaseGeometry::ConstPointer m_RefGeometry
mitk::ScalarType TimePointType
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
MITKCORE_EXPORT const ScalarType eps
TimeGeometry::ConstPointer m_RefTimeGeometry
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
Definition: mitkBaseData.h:138
BaseGeometry Describes the geometry of a data object.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57