ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkQuadEdgeMeshDecimationCriteria.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkQuadEdgeMeshDecimationCriteria_h
00019 #define __itkQuadEdgeMeshDecimationCriteria_h
00020 
00021 #include "itkIntTypes.h"
00022 #include "itkPriorityQueueContainer.h"
00023 
00024 namespace itk
00025 {
00031 template< class TMesh,
00032           typename TElement  = IdentifierType,
00033           typename TMeasure = double,
00034           class TPriorityQueueWrapper =
00035             MinPriorityQueueElementWrapper< typename TMesh::QEType *,
00036                                             std::pair< bool, TMeasure > > >
00037 class ITK_EXPORT QuadEdgeMeshDecimationCriterion:public Object
00038 {
00039 public:
00040   typedef QuadEdgeMeshDecimationCriterion Self;
00041   typedef SmartPointer< Self >            Pointer;
00042   typedef SmartPointer< const Self >      ConstPointer;
00043   typedef Object                          Superclass;
00044 
00046   itkTypeMacro(QuadEdgeMeshDecimationCriterion, Object);
00047 
00048   typedef TMesh                                                  MeshType;
00049   typedef TElement                                               ElementType;
00050   typedef TMeasure                                               MeasureType;
00051   typedef TPriorityQueueWrapper                                  PriorityQueueWrapperType;
00052   typedef typename PriorityQueueWrapperType::ElementPriorityType PriorityType;
00053 
00054   void SetNumberOfElements(const SizeValueType & numberOfElements)
00055   {
00056     this->m_SizeCriterion = true;
00057     this->m_NumberOfElements = numberOfElements;
00058   }
00059 
00060   void SetMeasureBound(const MeasureType & bound)
00061   {
00062     this->m_SizeCriterion = false;
00063     this->m_MeasureBound = bound;
00064   }
00065 
00066   itkGetConstMacro(TopologicalChange, bool);
00067   itkSetMacro(TopologicalChange, bool);
00068 
00069   virtual bool is_satisfied(MeshType *iMesh,
00070                             const ElementType & iElement,
00071                             const MeasureType & iValue) const = 0;
00072 
00073 protected:
00074   QuadEdgeMeshDecimationCriterion()
00075   {
00076     this->m_TopologicalChange = true;
00077     this->m_SizeCriterion = true;
00078     this->m_NumberOfElements = 0;
00079     this->m_MeasureBound = itk::NumericTraits< MeasureType >::Zero;
00080   }
00081 
00082   ~QuadEdgeMeshDecimationCriterion() {}
00083   void PrintSelf(std::ostream & os, Indent indent) const
00084   {
00085     Superclass::PrintSelf(os, indent);
00086     os << indent << "TopologicalChange: "
00087               << (m_TopologicalChange ? "On" : "Off")
00088               << std::endl;
00089     os << indent << "SizeCriterion: "
00090               << (m_SizeCriterion ? "On" : "Off")
00091               << std::endl;
00092     os << indent << "NumberOfElements: "
00093               << m_NumberOfElements
00094               << std::endl;
00095     os << indent << "MeasureBound: "
00096               << m_MeasureBound
00097               << std::endl;
00098   }
00099 
00100   bool m_TopologicalChange;
00101   bool m_SizeCriterion;
00102 
00103   SizeValueType m_NumberOfElements;
00104 
00105   MeasureType m_MeasureBound;
00106 private:
00107   QuadEdgeMeshDecimationCriterion(const Self &);
00108   void operator=(const Self &);
00109 };
00110 
00116 template< class TMesh,
00117           typename TElement = IdentifierType,
00118           typename TMeasure = double,
00119           class TPriorityQueueWrapper =
00120             MinPriorityQueueElementWrapper< typename TMesh::QEType *,
00121                                             std::pair< bool, TMeasure > > >
00122 class NumberOfPointsCriterion:
00123   public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
00124                                           TMeasure, TPriorityQueueWrapper >
00125 {
00126 public:
00127   typedef NumberOfPointsCriterion    Self;
00128   typedef SmartPointer< Self >       Pointer;
00129   typedef SmartPointer< const Self > ConstPointer;
00130   typedef QuadEdgeMeshDecimationCriterion<
00131     TMesh, TElement, TMeasure, TPriorityQueueWrapper >       Superclass;
00132 
00134   itkTypeMacro(NumberOfPointsCriterion, QuadEdgeMeshDecimationCriterion);
00135 
00137   itkNewMacro(Self);
00138 
00139   typedef typename Superclass::MeshType                 MeshType;
00140   typedef typename Superclass::ElementType              ElementType;
00141   typedef typename Superclass::MeasureType              MeasureType;
00142   typedef typename Superclass::PriorityQueueWrapperType PriorityQueueWrapperType;
00143   typedef typename Superclass::PriorityType             PriorityType;
00144 
00145   inline bool is_satisfied( MeshType *iMesh,
00146                             const ElementType & itkNotUsed(iElement),
00147                             const MeasureType & itkNotUsed(iValue) ) const
00148   {
00149     return ( iMesh->GetNumberOfPoints() <= this->m_NumberOfElements );
00150   }
00151 
00152 protected:
00153   NumberOfPointsCriterion() {}
00154   ~NumberOfPointsCriterion() {}
00155 private:
00156   NumberOfPointsCriterion(const Self &);
00157   void operator=(const Self &);
00158 };
00159 
00165 template< class TMesh,
00166           typename TElement = IdentifierType,
00167           typename TMeasure = double,
00168           class TPriorityQueueWrapper =
00169             MinPriorityQueueElementWrapper< typename TMesh::QEType *,
00170                                             std::pair< bool, TMeasure > > >
00171 class NumberOfFacesCriterion:
00172   public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
00173                                           TMeasure, TPriorityQueueWrapper >
00174 {
00175 public:
00176   typedef NumberOfFacesCriterion     Self;
00177   typedef SmartPointer< Self >       Pointer;
00178   typedef SmartPointer< const Self > ConstPointer;
00179   typedef QuadEdgeMeshDecimationCriterion< TMesh, TElement,
00180                                            TMeasure, TPriorityQueueWrapper >                 Superclass;
00181 
00183   itkTypeMacro(NumberOfFacesCriterion, QuadEdgeMeshDecimationCriterion);
00184 
00186   itkNewMacro(Self);
00187 
00188   typedef typename Superclass::MeshType                  MeshType;
00189   typedef typename MeshType::CellsContainerConstIterator CellsContainerConstIterator;
00190   typedef typename Superclass::ElementType               ElementType;
00191   typedef typename Superclass::MeasureType               MeasureType;
00192   typedef typename Superclass::PriorityQueueWrapperType  PriorityQueueWrapperType;
00193   typedef typename Superclass::PriorityType              PriorityType;
00194 
00195   inline bool is_satisfied( MeshType *iMesh,
00196                             const ElementType & itkNotUsed(iElement),
00197                             const MeasureType & itkNotUsed(iValue) ) const
00198   {
00199     return ( iMesh->GetNumberOfFaces() <= this->m_NumberOfElements );
00200   }
00201 
00202 protected:
00203   NumberOfFacesCriterion() {}
00204   ~NumberOfFacesCriterion() {}
00205 private:
00206   NumberOfFacesCriterion(const Self &);
00207   void operator=(const Self &);
00208 };
00209 
00215 template< class TMesh,
00216           typename TElement = IdentifierType,
00217           typename TMeasure = double,
00218           class TPriorityQueueWrapper =
00219             MinPriorityQueueElementWrapper< typename TMesh::QEType *,
00220                                             std::pair< bool, TMeasure > > >
00221 class MaxMeasureBoundCriterion:
00222   public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
00223                                           TMeasure, TPriorityQueueWrapper >
00224 {
00225 public:
00226   typedef MaxMeasureBoundCriterion   Self;
00227   typedef SmartPointer< Self >       Pointer;
00228   typedef SmartPointer< const Self > ConstPointer;
00229   typedef QuadEdgeMeshDecimationCriterion< TMesh, TElement,
00230                                            TMeasure, TPriorityQueueWrapper >                        Superclass;
00231 
00233   itkTypeMacro(MaxMeasureBoundCriterion, QuadEdgeMeshDecimationCriterion);
00234 
00236   itkNewMacro(Self);
00237 
00238   typedef typename Superclass::MeshType                  MeshType;
00239   typedef typename MeshType::CellsContainerConstIterator CellsContainerConstIterator;
00240   typedef typename Superclass::ElementType               ElementType;
00241   typedef typename Superclass::MeasureType               MeasureType;
00242   typedef typename Superclass::PriorityQueueWrapperType  PriorityQueueWrapperType;
00243   typedef typename Superclass::PriorityType              PriorityType;
00244 
00245   inline bool is_satisfied(MeshType *itkNotUsed(iMesh),
00246                            const ElementType & itkNotUsed(iElement),
00247                            const MeasureType & iValue) const
00248   {
00249     return ( iValue <= this->m_MeasureBound );
00250   }
00251 
00252 protected:
00253   MaxMeasureBoundCriterion():Superclass() {}
00254   ~MaxMeasureBoundCriterion() {}
00255 private:
00256   MaxMeasureBoundCriterion(const Self &);
00257   void operator=(const Self &);
00258 };
00259 
00265 template< class TMesh,
00266           typename TElement = IdentifierType,
00267           typename TMeasure = double,
00268           class TPriorityQueueWrapper =
00269             MaxPriorityQueueElementWrapper< typename TMesh::QEType *,
00270                                             std::pair< bool, TMeasure > > >
00271 class MinMeasureBoundCriterion:
00272   public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
00273                                           TMeasure, TPriorityQueueWrapper >
00274 {
00275 public:
00276   typedef MinMeasureBoundCriterion   Self;
00277   typedef SmartPointer< Self >       Pointer;
00278   typedef SmartPointer< const Self > ConstPointer;
00279   typedef QuadEdgeMeshDecimationCriterion< TMesh, TElement,
00280                                            TMeasure, TPriorityQueueWrapper >                         Superclass;
00281 
00283   itkTypeMacro(MinMeasureBoundCriterion, QuadEdgeMeshDecimationCriterion);
00284 
00286   itkNewMacro(Self);
00287 
00288   typedef typename Superclass::MeshType                  MeshType;
00289   typedef typename MeshType::CellsContainerConstIterator CellsContainerConstIterator;
00290   typedef typename Superclass::ElementType               ElementType;
00291   typedef typename Superclass::MeasureType               MeasureType;
00292   typedef typename Superclass::PriorityQueueWrapperType  PriorityQueueWrapperType;
00293   typedef typename Superclass::PriorityType              PriorityType;
00294 
00295   inline bool is_satisfied(MeshType *,
00296                            const ElementType & ,
00297                            const MeasureType & iValue) const
00298   {
00299     return ( iValue >= this->m_MeasureBound );
00300   }
00301 
00302 protected:
00303   MinMeasureBoundCriterion() {}
00304   ~MinMeasureBoundCriterion() {}
00305 private:
00306   MinMeasureBoundCriterion(const Self &);
00307   void operator=(const Self &);
00308 };
00309 }
00310 
00311 #endif
00312