ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkQuadEdgeMeshDecimationCriteria.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkQuadEdgeMeshDecimationCriteria_h
19 #define __itkQuadEdgeMeshDecimationCriteria_h
20 
21 #include "itkIntTypes.h"
23 
24 namespace itk
25 {
31 template< class TMesh,
32  typename TElement = IdentifierType,
33  typename TMeasure = double,
34  class TPriorityQueueWrapper =
35  MinPriorityQueueElementWrapper< typename TMesh::QEType *,
36  std::pair< bool, TMeasure > > >
37 class ITK_EXPORT QuadEdgeMeshDecimationCriterion:public Object
38 {
39 public:
43  typedef Object Superclass;
44 
47 
48  typedef TMesh MeshType;
49  typedef TElement ElementType;
50  typedef TMeasure MeasureType;
51  typedef TPriorityQueueWrapper PriorityQueueWrapperType;
52  typedef typename PriorityQueueWrapperType::ElementPriorityType PriorityType;
53 
54  void SetNumberOfElements(const SizeValueType & numberOfElements)
55  {
56  this->m_SizeCriterion = true;
57  this->m_NumberOfElements = numberOfElements;
58  }
59 
60  void SetMeasureBound(const MeasureType & bound)
61  {
62  this->m_SizeCriterion = false;
63  this->m_MeasureBound = bound;
64  }
65 
66  itkGetConstMacro(TopologicalChange, bool);
67  itkSetMacro(TopologicalChange, bool);
68 
69  virtual bool is_satisfied(MeshType *iMesh,
70  const ElementType & iElement,
71  const MeasureType & iValue) const = 0;
72 
73 protected:
75  {
76  this->m_TopologicalChange = true;
77  this->m_SizeCriterion = true;
78  this->m_NumberOfElements = 0;
79  this->m_MeasureBound = itk::NumericTraits< MeasureType >::Zero;
80  }
81 
83  void PrintSelf(std::ostream & os, Indent indent) const
84  {
85  Superclass::PrintSelf(os, indent);
86  os << indent << "TopologicalChange: "
87  << (m_TopologicalChange ? "On" : "Off")
88  << std::endl;
89  os << indent << "SizeCriterion: "
90  << (m_SizeCriterion ? "On" : "Off")
91  << std::endl;
92  os << indent << "NumberOfElements: "
93  << m_NumberOfElements
94  << std::endl;
95  os << indent << "MeasureBound: "
96  << m_MeasureBound
97  << std::endl;
98  }
99 
102 
104 
106 private:
108  void operator=(const Self &);
109 };
110 
116 template< class TMesh,
117  typename TElement = IdentifierType,
118  typename TMeasure = double,
119  class TPriorityQueueWrapper =
120  MinPriorityQueueElementWrapper< typename TMesh::QEType *,
121  std::pair< bool, TMeasure > > >
123  public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
124  TMeasure, TPriorityQueueWrapper >
125 {
126 public:
131  TMesh, TElement, TMeasure, TPriorityQueueWrapper > Superclass;
132 
135 
137  itkNewMacro(Self);
138 
139  typedef typename Superclass::MeshType MeshType;
144 
145  inline bool is_satisfied( MeshType *iMesh,
146  const ElementType & itkNotUsed(iElement),
147  const MeasureType & itkNotUsed(iValue) ) const
148  {
149  return ( iMesh->GetNumberOfPoints() <= this->m_NumberOfElements );
150  }
151 
152 protected:
155 private:
156  NumberOfPointsCriterion(const Self &);
157  void operator=(const Self &);
158 };
159 
165 template< class TMesh,
166  typename TElement = IdentifierType,
167  typename TMeasure = double,
168  class TPriorityQueueWrapper =
169  MinPriorityQueueElementWrapper< typename TMesh::QEType *,
170  std::pair< bool, TMeasure > > >
172  public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
173  TMeasure, TPriorityQueueWrapper >
174 {
175 public:
179  typedef QuadEdgeMeshDecimationCriterion< TMesh, TElement,
180  TMeasure, TPriorityQueueWrapper > Superclass;
181 
184 
186  itkNewMacro(Self);
187 
188  typedef typename Superclass::MeshType MeshType;
189  typedef typename MeshType::CellsContainerConstIterator CellsContainerConstIterator;
194 
195  inline bool is_satisfied( MeshType *iMesh,
196  const ElementType & itkNotUsed(iElement),
197  const MeasureType & itkNotUsed(iValue) ) const
198  {
199  return ( iMesh->GetNumberOfFaces() <= this->m_NumberOfElements );
200  }
201 
202 protected:
205 private:
206  NumberOfFacesCriterion(const Self &);
207  void operator=(const Self &);
208 };
209 
215 template< class TMesh,
216  typename TElement = IdentifierType,
217  typename TMeasure = double,
218  class TPriorityQueueWrapper =
219  MinPriorityQueueElementWrapper< typename TMesh::QEType *,
220  std::pair< bool, TMeasure > > >
222  public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
223  TMeasure, TPriorityQueueWrapper >
224 {
225 public:
229  typedef QuadEdgeMeshDecimationCriterion< TMesh, TElement,
230  TMeasure, TPriorityQueueWrapper > Superclass;
231 
234 
236  itkNewMacro(Self);
237 
238  typedef typename Superclass::MeshType MeshType;
239  typedef typename MeshType::CellsContainerConstIterator CellsContainerConstIterator;
244 
245  inline bool is_satisfied(MeshType *itkNotUsed(iMesh),
246  const ElementType & itkNotUsed(iElement),
247  const MeasureType & iValue) const
248  {
249  return ( iValue <= this->m_MeasureBound );
250  }
251 
252 protected:
255 private:
257  void operator=(const Self &);
258 };
259 
265 template< class TMesh,
266  typename TElement = IdentifierType,
267  typename TMeasure = double,
268  class TPriorityQueueWrapper =
269  MaxPriorityQueueElementWrapper< typename TMesh::QEType *,
270  std::pair< bool, TMeasure > > >
272  public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
273  TMeasure, TPriorityQueueWrapper >
274 {
275 public:
279  typedef QuadEdgeMeshDecimationCriterion< TMesh, TElement,
280  TMeasure, TPriorityQueueWrapper > Superclass;
281 
284 
286  itkNewMacro(Self);
287 
288  typedef typename Superclass::MeshType MeshType;
289  typedef typename MeshType::CellsContainerConstIterator CellsContainerConstIterator;
294 
295  inline bool is_satisfied(MeshType *,
296  const ElementType & ,
297  const MeasureType & iValue) const
298  {
299  return ( iValue >= this->m_MeasureBound );
300  }
301 
302 protected:
305 private:
307  void operator=(const Self &);
308 };
309 }
310 
311 #endif
312