Medical Imaging Interaction Toolkit  2018.4.99-4c24e3cb
Medical Imaging Interaction Toolkit
mitkNodePredicateDimension.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 
17 mitk::NodePredicateDimension::NodePredicateDimension(unsigned int dimension, int pixelComponents)
18  : m_Dimension(dimension), m_PixelComponents(pixelComponents)
19 {
20 }
21 
23  : m_Dimension(dimension), m_PixelComponents(1)
24 {
25 }
26 
28 {
29 }
30 
32 {
33  if (node == nullptr)
34  throw std::invalid_argument("NodePredicateDimension: invalid node");
35 
36  auto *image = dynamic_cast<mitk::Image *>(node->GetData());
37  if (image != nullptr)
38  {
39  return (image->GetDimension() == m_Dimension && image->GetPixelType().GetNumberOfComponents() == m_PixelComponents);
40  }
41 
42  return false;
43 }
bool CheckNode(const mitk::DataNode *node) const override
Checks if the nodes data object is of the specified dimension.
NodePredicateDimension(unsigned int dimension)
Standard Constructor.
~NodePredicateDimension() override
Standard Destructor.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
Image class for storing images.
Definition: mitkImage.h:72
mitk::Image::Pointer image
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64