ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkDecimationQuadEdgeMeshFilter.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 __itkDecimationQuadEdgeMeshFilter_h
00019 #define __itkDecimationQuadEdgeMeshFilter_h
00020 
00021 #include "itkIntTypes.h"
00022 #include "itkQuadEdgeMeshToQuadEdgeMeshFilter.h"
00023 
00024 namespace itk
00025 {
00031 template< class TInput, class TOutput, class TCriterion >
00032 class ITK_EXPORT DecimationQuadEdgeMeshFilter:
00033   public QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >
00034 {
00035 public:
00036   typedef DecimationQuadEdgeMeshFilter                        Self;
00037   typedef SmartPointer< Self >                                Pointer;
00038   typedef SmartPointer< const Self >                          ConstPointer;
00039   typedef QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput > Superclass;
00040 
00042   itkTypeMacro(DecimationQuadEdgeMeshFilter, QuadEdgeMeshToQuadEdgeMeshFilter);
00043 
00044   typedef TInput                          InputMeshType;
00045   typedef typename InputMeshType::Pointer InputMeshPointer;
00046 
00047   typedef TOutput                          OutputMeshType;
00048   typedef typename OutputMeshType::Pointer OutputMeshPointer;
00049 
00050   typedef TCriterion                                       CriterionType;
00051   typedef typename CriterionType::Pointer                  CriterionPointer;
00052   typedef typename CriterionType::MeasureType              MeasureType;
00053   typedef typename CriterionType::PriorityType             PriorityType;
00054   typedef typename CriterionType::PriorityQueueWrapperType PriorityQueueItemType;
00055 
00056   itkSetObjectMacro(Criterion, CriterionType);
00057 protected:
00058   DecimationQuadEdgeMeshFilter()
00059   {
00060     this->m_Iteration = 0;
00061   }
00062 
00063   ~DecimationQuadEdgeMeshFilter() {}
00064 
00065   CriterionPointer m_Criterion;
00066   SizeValueType    m_Iteration;
00067 
00068   void GenerateData()
00069   {
00070     this->CopyInputMeshToOutputMesh();
00071 
00072     Initialize();
00073     FillPriorityQueue();
00074     m_Iteration = 0;
00075 
00076     do
00077       {
00078       this->Extract();
00079 
00080       if ( ProcessWithTopologicalGuarantee() )
00081         {
00082         return;
00083         }
00084 
00085       ++m_Iteration;
00086       }
00087     while ( !IsCriterionSatisfied() );
00088 
00089     this->GetOutput()->SqueezePointsIds();
00090   }
00091 
00092   virtual void Initialize() {}
00093   virtual void FillPriorityQueue() = 0;
00094 
00095   virtual void Extract() = 0;
00096 
00097   virtual bool ProcessWithoutAnyTopologicalGuarantee() = 0;
00098 
00099   virtual bool ProcessWithTopologicalGuarantee() = 0;
00100 
00101   virtual bool IsCriterionSatisfied() = 0;
00102 
00103   void PrintSelf(std::ostream & os, Indent indent) const
00104   {
00105     this->Superclass::PrintSelf(os, indent);
00106     os << indent << "Criterion: " << m_Criterion << std::endl;
00107   }
00108 
00109 private:
00110   DecimationQuadEdgeMeshFilter(const Self &);
00111   void operator=(const Self &);
00112 };
00113 }
00114 
00115 #endif
00116