Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkQuadEdgeMeshDecimationCriteria.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkQuadEdgeMeshDecimationCriteria.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-04-23 03:43:42 $
00007   Version:   $Revision: 1.6 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 #ifndef __itkQuadEdgeMeshDecimationCriteria_h
00019 #define __itkQuadEdgeMeshDecimationCriteria_h
00020 
00021 #include "itkPriorityQueueContainer.h"
00022 
00023 namespace itk
00024 {
00029 template< class TMesh,
00030   typename TElement  = unsigned long,
00031   typename TMeasure = double,
00032   class TPriorityQueueWrapper = 
00033     MinPriorityQueueElementWrapper< typename TMesh::QEType*, 
00034       std::pair< bool, TMeasure > > >
00035 class QuadEdgeMeshDecimationCriterion : public Object
00036 {
00037 public:
00038   typedef QuadEdgeMeshDecimationCriterion       Self;
00039   typedef SmartPointer< Self >                  Pointer;
00040   typedef SmartPointer< const Self >            ConstPointer;
00041   typedef Object                                Superclass;
00042 
00044   itkTypeMacro( QuadEdgeMeshDecimationCriterion, Object );
00045 
00046   typedef TMesh                                                    MeshType;
00047   typedef TElement                                                 ElementType;
00048   typedef TMeasure                                                 MeasureType;
00049   typedef TPriorityQueueWrapper                                    PriorityQueueWrapperType;
00050   typedef typename PriorityQueueWrapperType::ElementPriorityType   PriorityType;
00051 
00052   void SetNumberOfElements( const unsigned long & numberOfElements )
00053     {
00054     this->m_SizeCriterion = true;
00055     this->m_NumberOfElements = numberOfElements;
00056     }
00057 
00058   void SetMeasureBound( const MeasureType& bound )
00059     {
00060     this->m_SizeCriterion = false;
00061     this->m_MeasureBound = bound;
00062     }
00063 
00064   itkGetConstMacro( TopologicalChange, bool );
00065   itkSetMacro( TopologicalChange, bool );
00066   
00067   virtual bool is_satisfied( MeshType* iMesh,
00068     const ElementType& iElement,
00069     const MeasureType& iValue ) const = 0;
00070 
00071 protected:
00072   QuadEdgeMeshDecimationCriterion()
00073     {
00074     this->m_TopologicalChange = true;
00075     this->m_SizeCriterion = true;
00076     this->m_NumberOfElements = 0;
00077     this->m_MeasureBound= itk::NumericTraits< MeasureType >::Zero;
00078     }
00079 
00080   ~QuadEdgeMeshDecimationCriterion() {}
00081 
00082   bool                m_TopologicalChange;
00083   bool                m_SizeCriterion;
00084   unsigned long       m_NumberOfElements;
00085   MeasureType         m_MeasureBound;
00086 
00087 private:
00088   QuadEdgeMeshDecimationCriterion( const Self& );
00089   void operator = ( const Self& );
00090 };
00091 
00096 template< class TMesh,
00097   typename TElement = unsigned long,
00098   typename TMeasure = double,
00099   class TPriorityQueueWrapper = 
00100     MinPriorityQueueElementWrapper< typename TMesh::QEType*, 
00101       std::pair< bool, TMeasure > > >
00102 class NumberOfPointsCriterion :
00103 public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
00104   TMeasure, TPriorityQueueWrapper >
00105 {
00106 public:
00107   typedef NumberOfPointsCriterion                            Self;
00108   typedef SmartPointer< Self >                               Pointer;
00109   typedef SmartPointer< const Self >                         ConstPointer;
00110   typedef QuadEdgeMeshDecimationCriterion< 
00111     TMesh, TElement, TMeasure, TPriorityQueueWrapper >       Superclass;
00112 
00114   itkTypeMacro( NumberOfPointsCriterion, QuadEdgeMeshDecimationCriterion );
00115 
00117   itkNewMacro( Self );
00118 
00119   typedef typename Superclass::MeshType                      MeshType;
00120   typedef typename Superclass::ElementType                   ElementType;
00121   typedef typename Superclass::MeasureType                   MeasureType;
00122   typedef typename Superclass::PriorityQueueWrapperType      PriorityQueueWrapperType;
00123   typedef typename Superclass::PriorityType                  PriorityType;
00124     
00125   inline bool is_satisfied( MeshType* iMesh, 
00126     const ElementType& itkNotUsed( iElement ),
00127     const MeasureType & itkNotUsed( iValue ) ) const
00128     {
00129     return ( iMesh->GetNumberOfPoints() <= this->m_NumberOfElements );
00130     }
00131 
00132 protected:
00133   NumberOfPointsCriterion( ) {}
00134   ~NumberOfPointsCriterion() {}
00135 
00136 private:
00137   NumberOfPointsCriterion( const Self& );
00138   void operator = ( const Self& );
00139 };
00140 
00145 template< class TMesh,
00146   typename TElement = unsigned long,
00147   typename TMeasure = double,
00148   class TPriorityQueueWrapper = 
00149     MinPriorityQueueElementWrapper< ITK_TYPENAME TMesh::QEType*, 
00150       std::pair< bool, TMeasure > > >
00151 class NumberOfFacesCriterion :
00152 public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
00153   TMeasure, TPriorityQueueWrapper >
00154 {
00155 public:
00156   typedef NumberOfFacesCriterion                      Self;
00157   typedef SmartPointer< Self >                        Pointer;
00158   typedef SmartPointer< const Self >                  ConstPointer;
00159   typedef QuadEdgeMeshDecimationCriterion< TMesh, TElement,
00160     TMeasure, TPriorityQueueWrapper >                 Superclass;
00161 
00163   itkTypeMacro( NumberOfFacesCriterion, QuadEdgeMeshDecimationCriterion );
00164 
00166   itkNewMacro( Self );
00167 
00168   typedef typename Superclass::MeshType                     MeshType;
00169   typedef typename MeshType::CellsContainerConstIterator    CellsContainerConstIterator;
00170   typedef typename Superclass::ElementType                  ElementType;
00171   typedef typename Superclass::MeasureType                  MeasureType;
00172   typedef typename Superclass::PriorityQueueWrapperType     PriorityQueueWrapperType;
00173   typedef typename Superclass::PriorityType                 PriorityType;
00174 
00175   inline bool is_satisfied( MeshType* iMesh,
00176     const ElementType& itkNotUsed( iElement ),
00177     const MeasureType& itkNotUsed( iValue ) ) const
00178     {
00179     return ( iMesh->GetNumberOfFaces() <= this->m_NumberOfElements );
00180     }
00181 
00182 protected:
00183   NumberOfFacesCriterion( ) {}
00184   ~NumberOfFacesCriterion() {}
00185 
00186 private:
00187   NumberOfFacesCriterion( const Self& );
00188   void operator = ( const Self& );
00189 };
00190 
00195 template< class TMesh,
00196   typename TElement = unsigned long,
00197   typename TMeasure = double,
00198   class TPriorityQueueWrapper = 
00199     MinPriorityQueueElementWrapper< typename TMesh::QEType*, 
00200       std::pair< bool, TMeasure > > >
00201 class MaxMeasureBoundCriterion :
00202 public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
00203   TMeasure, TPriorityQueueWrapper >
00204 {
00205 public:
00206   typedef MaxMeasureBoundCriterion                           Self;
00207   typedef SmartPointer< Self >                               Pointer;
00208   typedef SmartPointer< const Self >                         ConstPointer;
00209   typedef QuadEdgeMeshDecimationCriterion< TMesh, TElement,
00210     TMeasure, TPriorityQueueWrapper >                        Superclass;
00211 
00213   itkTypeMacro( MaxMeasureBoundCriterion, QuadEdgeMeshDecimationCriterion );
00214 
00216   itkNewMacro( Self );
00217 
00218   typedef typename Superclass::MeshType                      MeshType;
00219   typedef typename MeshType::CellsContainerConstIterator     CellsContainerConstIterator;
00220   typedef typename Superclass::ElementType                   ElementType;
00221   typedef typename Superclass::MeasureType                   MeasureType;
00222   typedef typename Superclass::PriorityQueueWrapperType      PriorityQueueWrapperType;
00223   typedef typename Superclass::PriorityType                  PriorityType;
00224 
00225   inline bool is_satisfied( MeshType * itkNotUsed( iMesh ),
00226     const ElementType& itkNotUsed( iElement ),
00227     const MeasureType& iValue ) const
00228     {
00229     return ( iValue <= this->m_MeasureBound );
00230     }
00231 
00232 protected:
00233   MaxMeasureBoundCriterion( ) : Superclass( ) {}
00234   ~MaxMeasureBoundCriterion() {}
00235 
00236 private:
00237   MaxMeasureBoundCriterion( const Self& );
00238   void operator = ( const Self& );
00239 };
00240 
00245 template< class TMesh,
00246   typename TElement = unsigned long,
00247   typename TMeasure = double,
00248   class TPriorityQueueWrapper = 
00249     MaxPriorityQueueElementWrapper< typename TMesh::QEType*,
00250       std::pair< bool, TMeasure > > >
00251 class MinMeasureBoundCriterion :
00252 public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
00253   TMeasure, TPriorityQueueWrapper >
00254 {
00255 public:
00256   typedef MinMeasureBoundCriterion                            Self;
00257   typedef SmartPointer< Self >                                Pointer;
00258   typedef SmartPointer< const Self >                          ConstPointer;
00259   typedef QuadEdgeMeshDecimationCriterion< TMesh, TElement,
00260     TMeasure, TPriorityQueueWrapper >                         Superclass;
00261 
00263   itkTypeMacro( MinMeasureBoundCriterion, QuadEdgeMeshDecimationCriterion );
00264 
00266   itkNewMacro( Self );
00267 
00268   typedef typename Superclass::MeshType                       MeshType;
00269   typedef typename MeshType::CellsContainerConstIterator      CellsContainerConstIterator;
00270   typedef typename Superclass::ElementType                    ElementType;
00271   typedef typename Superclass::MeasureType                    MeasureType;
00272   typedef typename Superclass::PriorityQueueWrapperType       PriorityQueueWrapperType;
00273   typedef typename Superclass::PriorityType                   PriorityType;
00274 
00275   inline bool is_satisfied( MeshType* iMesh,
00276     const ElementType& iElement,
00277     const MeasureType& iValue ) const
00278     {
00279     return ( iValue >= this->m_MeasureBound );
00280     }
00281 
00282 protected:
00283   MinMeasureBoundCriterion( ) {}
00284   ~MinMeasureBoundCriterion() {}
00285 
00286 private:
00287   MinMeasureBoundCriterion( const Self& );
00288   void operator = ( const Self& );
00289 };
00290 }
00291 
00292 #endif
00293 

Generated at Tue Sep 15 04:25:43 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000