00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision: 11215 $ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #include "mitkNodePredicateDimension.h" 00019 00020 #include "mitkDataNode.h" 00021 00022 00023 mitk::NodePredicateDimension::NodePredicateDimension(unsigned int dimension, int pixelComponents) 00024 : m_Dimension( dimension ), 00025 m_PixelComponents( pixelComponents ) 00026 { 00027 } 00028 00029 mitk::NodePredicateDimension::NodePredicateDimension( unsigned int dimension ) 00030 : m_Dimension( dimension ), 00031 m_PixelComponents(1) 00032 { 00033 00034 } 00035 00036 mitk::NodePredicateDimension::~NodePredicateDimension() 00037 { 00038 } 00039 00040 00041 bool mitk::NodePredicateDimension::CheckNode(const mitk::DataNode* node) const 00042 { 00043 if (node == NULL) 00044 throw std::invalid_argument("NodePredicateDimension: invalid node"); 00045 00046 mitk::Image *image = dynamic_cast<mitk::Image *>( node->GetData() ); 00047 if (image != NULL) 00048 { 00049 return (image->GetDimension() == m_Dimension && image->GetPixelType().GetNumberOfComponents() == m_PixelComponents); 00050 } 00051 00052 return false; 00053 } 00054