1 #ifndef __CPM__ALGORITHMS__QUADEDGE__DECIMATIONCRITERIA__H__
2 #define __CPM__ALGORITHMS__QUADEDGE__DECIMATIONCRITERIA__H__
4 #include <itkIntTypes.h>
5 #include <itkPriorityQueueContainer.h>
15 template< class M, class E = unsigned long, class S = double, class Q = itk::MinPriorityQueueElementWrapper< class M::TPrimalEdge*, std::pair< bool, S > > >
16 class DecimationCriterion
20 typedef DecimationCriterion Self;
21 typedef itk::SmartPointer< Self > Pointer;
22 typedef itk::SmartPointer< const Self > ConstPointer;
23 typedef itk::Object Superclass;
28 typedef Q TQueueWrapper;
29 typedef typename Q::ElementPriorityType TPriority;
32 itkTypeMacro( DecimationCriterion, itkObject );
34 itkBooleanMacro( TopologicalChange );
35 itkGetConstMacro( TopologicalChange, bool );
36 itkSetMacro( TopologicalChange, bool );
38 void SetNumberOfElements( const unsigned long& numberOfElements )
40 this->m_SizeCriterion = true;
41 this->m_NumberOfElements = numberOfElements;
44 void SetMeasureBound( const S& bound )
46 this->m_SizeCriterion = false;
47 this->m_MeasureBound = bound;
50 virtual bool is_satisfied( M* m, const E& e, const S& v ) const = 0;
53 DecimationCriterion( )
56 this->m_TopologicalChange = true;
57 this->m_SizeCriterion = true;
58 this->m_NumberOfElements = 0;
59 this->m_MeasureBound = itk::NumericTraits< TScalar >::Zero;
61 virtual ~DecimationCriterion( )
65 bool m_TopologicalChange;
67 unsigned long m_NumberOfElements;
71 // Purposely not implemented
72 DecimationCriterion( const Self& );
73 void operator=( const Self& );
78 template< class M, class E = unsigned long, class S = double, class Q = itk::MinPriorityQueueElementWrapper< class M::TPrimalEdge*, std::pair< bool, S > > >
79 class NumberOfPointsCriterion
80 : public DecimationCriterion< M, E, S, Q >
83 typedef NumberOfPointsCriterion Self;
84 typedef DecimationCriterion< M, E, S, Q > Superclass;
85 typedef itk::SmartPointer< Self > Pointer;
86 typedef itk::SmartPointer< const Self > ConstPointer;
88 typedef typename Superclass::TMesh TMesh;
89 typedef typename Superclass::TElement TElement;
90 typedef typename Superclass::TScalar TScalar;
91 typedef typename Superclass::TQueueWrapper TQueueWrapper;
92 typedef typename Superclass::TPriority TPriority;
96 itkTypeMacro( NumberOfPointsCriterion, DecimationCriterion );
99 inline bool is_satisfied( M* m, const E& e, const S& v ) const
101 return( m->GetNumberOfPoints( ) <= this->m_NumberOfElements );
105 NumberOfPointsCriterion( )
108 virtual ~NumberOfPointsCriterion( )
112 // Purposely not implemented
113 NumberOfPointsCriterion( const Self& );
114 void operator=( const Self& );
119 template< class M, class E = unsigned long, class S = double, class Q = itk::MinPriorityQueueElementWrapper< class M::TPrimalEdge*, std::pair< bool, S > > >
120 class NumberOfFacesCriterion
121 : public DecimationCriterion< M, E, S, Q >
124 typedef NumberOfFacesCriterion Self;
125 typedef DecimationCriterion< M, E, S, Q > Superclass;
126 typedef itk::SmartPointer< Self > Pointer;
127 typedef itk::SmartPointer< const Self > ConstPointer;
129 typedef typename Superclass::TMesh TMesh;
130 typedef typename Superclass::TElement TElement;
131 typedef typename Superclass::TScalar TScalar;
132 typedef typename Superclass::TQueueWrapper TQueueWrapper;
133 typedef typename Superclass::TPriority TPriority;
137 itkTypeMacro( NumberOfFacesCriterion, DecimationCriterion );
140 inline bool is_satisfied( M* m, const E& e, const S& v ) const
142 return( m->GetNumberOfFaces( ) <= this->m_NumberOfElements );
146 NumberOfFacesCriterion( )
149 virtual ~NumberOfFacesCriterion( )
153 // Purposely not implemented
154 NumberOfFacesCriterion( const Self& );
155 void operator=( const Self& );
160 template< class M, class E = unsigned long, class S = double, class Q = itk::MinPriorityQueueElementWrapper< class M::TPrimalEdge*, std::pair< bool, S > > >
161 class MaxMeasureBoundCriterion
162 : public DecimationCriterion< M, E, S, Q >
165 typedef MaxMeasureBoundCriterion Self;
166 typedef DecimationCriterion< M, E, S, Q > Superclass;
167 typedef itk::SmartPointer< Self > Pointer;
168 typedef itk::SmartPointer< const Self > ConstPointer;
170 typedef typename Superclass::TMesh TMesh;
171 typedef typename Superclass::TElement TElement;
172 typedef typename Superclass::TScalar TScalar;
173 typedef typename Superclass::TQueueWrapper TQueueWrapper;
174 typedef typename Superclass::TPriority TPriority;
178 itkTypeMacro( MaxMeasureBoundCriterion, DecimationCriterion );
180 inline bool is_satisfied( M* m, const E& e, const S& v ) const
182 return( v <= this->m_MeasureBound );
186 MaxMeasureBoundCriterion( )
189 virtual ~MaxMeasureBoundCriterion( )
193 // Purposely not implemented
194 MaxMeasureBoundCriterion( const Self& );
195 void operator=( const Self& );
200 template< class M, class E = unsigned long, class S = double, class Q = itk::MaxPriorityQueueElementWrapper< class M::TPrimalEdge*, std::pair< bool, S > > >
201 class MinMeasureBoundCriterion
202 : public DecimationCriterion< M, E, S, Q >
205 typedef MinMeasureBoundCriterion Self;
206 typedef DecimationCriterion< M, E, S, Q > Superclass;
207 typedef itk::SmartPointer< Self > Pointer;
208 typedef itk::SmartPointer< const Self > ConstPointer;
210 typedef typename Superclass::TMesh TMesh;
211 typedef typename Superclass::TElement TElement;
212 typedef typename Superclass::TScalar TScalar;
213 typedef typename Superclass::TQueueWrapper TQueueWrapper;
214 typedef typename Superclass::TPriority TPriority;
218 itkTypeMacro( MinMeasureBoundCriterion, DecimationCriterion );
220 inline bool is_satisfied( M* m, const E& e, const S& v ) const
222 return( v >= this->m_MeasureBound );
226 MinMeasureBoundCriterion( )
229 virtual ~MinMeasureBoundCriterion( )
233 // Purposely not implemented
234 MinMeasureBoundCriterion( const Self& );
235 void operator=( const Self& );
244 #endif // __CPM__ALGORITHMS__QUADEDGE__DECIMATIONCRITERIA__H__