Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 #include "mitkDataNode.h"
19 #include "mitkImage.h"
20 
21 mitk::NodePredicateDimension::NodePredicateDimension(unsigned int dimension, int pixelComponents)
22  : m_Dimension(dimension), m_PixelComponents(pixelComponents)
23 {
24 }
25 
27  : m_Dimension(dimension), m_PixelComponents(1)
28 {
29 }
30 
32 {
33 }
34 
36 {
37  if (node == nullptr)
38  throw std::invalid_argument("NodePredicateDimension: invalid node");
39 
40  mitk::Image *image = dynamic_cast<mitk::Image *>(node->GetData());
41  if (image != nullptr)
42  {
43  return (image->GetDimension() == m_Dimension && image->GetPixelType().GetNumberOfComponents() == m_PixelComponents);
44  }
45 
46  return false;
47 }
virtual bool CheckNode(const mitk::DataNode *node) const override
Checks if the nodes data object is of the specified dimension.
virtual ~NodePredicateDimension()
Standard Destructor.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
NodePredicateDimension(unsigned int dimension)
Standard Constructor.
Image class for storing images.
Definition: mitkImage.h:76
const mitk::PixelType GetPixelType(int n=0) const
Returns the PixelType of channel n.
Definition: mitkImage.cpp:105
vcl_size_t GetNumberOfComponents() const
Get the number of components of which each element consists.
unsigned int GetDimension() const
Get dimension of the image.
Definition: mitkImage.cpp:110
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66