From 1785481cc6895480432f7b9e6f9d1b32daaf0e91 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@orfeo-toolbox.org> Date: Mon, 7 Sep 2009 17:49:06 +0200 Subject: [PATCH] COMP: Adding a utils file to provide functors that were deleted by ITK --- .../InsightJournal/itkLabelObjectUtils.h | 89 +++++++++++++++++++ .../itkShapeKeepNObjectsLabelMapFilter.txx | 1 + ...tkStatisticsKeepNObjectsLabelMapFilter.txx | 1 + 3 files changed, 91 insertions(+) create mode 100644 Utilities/InsightJournal/itkLabelObjectUtils.h diff --git a/Utilities/InsightJournal/itkLabelObjectUtils.h b/Utilities/InsightJournal/itkLabelObjectUtils.h new file mode 100644 index 0000000000..6be33ba3a1 --- /dev/null +++ b/Utilities/InsightJournal/itkLabelObjectUtils.h @@ -0,0 +1,89 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkLabelObject.h,v $ + Language: C++ + Date: $Date: 2005/01/21 20:13:31 $ + Version: $Revision: 1.6 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef __itkLabelObjectUtils_h +#define __itkLabelObjectUtils_h + +#include <deque> +#include <itkLightObject.h> +#include "itkLabelMap.h" +#include "itkLabelObjectLine.h" + +namespace itk +{ + + +namespace Functor { + +template< class TLabelObject > +class ITK_EXPORT LabelLabelObjectAccessor +{ +public: + typedef TLabelObject LabelObjectType; + typedef typename LabelObjectType::LabelType AttributeValueType; + + inline const AttributeValueType operator()( const LabelObjectType * labelObject ) + { + return labelObject->GetLabel(); + } +}; + +template< class TLabelObject > +class ITK_EXPORT NumberOfLinesLabelObjectAccessor +{ +public: + typedef TLabelObject LabelObjectType; + typedef int AttributeValueType; + + inline const AttributeValueType operator()( const LabelObjectType * labelObject ) + { + return labelObject->GetNumberOfLines(); + } +}; + +template< class TLabelObject, class TAttributeAccessor > +class LabelObjectComparator +{ +public: + typedef TLabelObject LabelObjectType; + typedef TAttributeAccessor AttributeAccessorType; + bool operator()( const LabelObjectType * a, const LabelObjectType * b ) + { + return accessor( a ) > accessor( b ); + } +private: + AttributeAccessorType accessor; +}; + +template< class TLabelObject, class TAttributeAccessor > +class LabelObjectReverseComparator +{ +public: + typedef TLabelObject LabelObjectType; + typedef TAttributeAccessor AttributeAccessorType; + bool operator()( const LabelObjectType * a, const LabelObjectType * b ) + { + return accessor( a ) < accessor( b ); + } +private: + AttributeAccessorType accessor; +}; + +} + +} // end namespace itk + +#endif diff --git a/Utilities/InsightJournal/itkShapeKeepNObjectsLabelMapFilter.txx b/Utilities/InsightJournal/itkShapeKeepNObjectsLabelMapFilter.txx index c49b0e020a..b6216bb607 100644 --- a/Utilities/InsightJournal/itkShapeKeepNObjectsLabelMapFilter.txx +++ b/Utilities/InsightJournal/itkShapeKeepNObjectsLabelMapFilter.txx @@ -19,6 +19,7 @@ #include "itkShapeKeepNObjectsLabelMapFilter.h" #include "itkProgressReporter.h" +#include "itkLabelObjectUtils.h" namespace itk { diff --git a/Utilities/InsightJournal/itkStatisticsKeepNObjectsLabelMapFilter.txx b/Utilities/InsightJournal/itkStatisticsKeepNObjectsLabelMapFilter.txx index 2e25f5f1d5..435ba468bc 100644 --- a/Utilities/InsightJournal/itkStatisticsKeepNObjectsLabelMapFilter.txx +++ b/Utilities/InsightJournal/itkStatisticsKeepNObjectsLabelMapFilter.txx @@ -19,6 +19,7 @@ #include "itkStatisticsKeepNObjectsLabelMapFilter.h" #include "itkProgressReporter.h" +#include "itkLabelObjectUtils.h" namespace itk { -- GitLab