ITK  4.3.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 
107 private:
109  void operator=(const Self &);
110 };
111 
117 template< class TMesh,
118  typename TElement = IdentifierType,
119  typename TMeasure = double,
120  class TPriorityQueueWrapper =
121  MinPriorityQueueElementWrapper< typename TMesh::QEType *,
122  std::pair< bool, TMeasure > > >
124  public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
125  TMeasure, TPriorityQueueWrapper >
126 {
127 public:
132  TMesh, TElement, TMeasure, TPriorityQueueWrapper > Superclass;
133 
136 
138  itkNewMacro(Self);
139 
140  typedef typename Superclass::MeshType MeshType;
145 
146  inline bool is_satisfied( MeshType *iMesh,
147  const ElementType & itkNotUsed(iElement),
148  const MeasureType & itkNotUsed(iValue) ) const
149  {
150  return ( iMesh->GetNumberOfPoints() <= this->m_NumberOfElements );
151  }
152 
153 protected:
156 
157 private:
158  NumberOfPointsCriterion(const Self &);
159  void operator=(const Self &);
160 };
161 
167 template< class TMesh,
168  typename TElement = IdentifierType,
169  typename TMeasure = double,
170  class TPriorityQueueWrapper =
171  MinPriorityQueueElementWrapper< typename TMesh::QEType *,
172  std::pair< bool, TMeasure > > >
174  public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
175  TMeasure, TPriorityQueueWrapper >
176 {
177 public:
181  typedef QuadEdgeMeshDecimationCriterion< TMesh, TElement,
182  TMeasure, TPriorityQueueWrapper > Superclass;
183 
186 
188  itkNewMacro(Self);
189 
190  typedef typename Superclass::MeshType MeshType;
191  typedef typename MeshType::CellsContainerConstIterator CellsContainerConstIterator;
196 
197  inline bool is_satisfied( MeshType *iMesh,
198  const ElementType & itkNotUsed(iElement),
199  const MeasureType & itkNotUsed(iValue) ) const
200  {
201  return ( iMesh->GetNumberOfFaces() <= this->m_NumberOfElements );
202  }
203 
204 protected:
207 
208 private:
209  NumberOfFacesCriterion(const Self &);
210  void operator=(const Self &);
211 };
212 
218 template< class TMesh,
219  typename TElement = IdentifierType,
220  typename TMeasure = double,
221  class TPriorityQueueWrapper =
222  MinPriorityQueueElementWrapper< typename TMesh::QEType *,
223  std::pair< bool, TMeasure > > >
225  public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
226  TMeasure, TPriorityQueueWrapper >
227 {
228 public:
232  typedef QuadEdgeMeshDecimationCriterion< TMesh, TElement,
233  TMeasure, TPriorityQueueWrapper > Superclass;
234 
237 
239  itkNewMacro(Self);
240 
241  typedef typename Superclass::MeshType MeshType;
242  typedef typename MeshType::CellsContainerConstIterator CellsContainerConstIterator;
247 
248  inline bool is_satisfied(MeshType *itkNotUsed(iMesh),
249  const ElementType & itkNotUsed(iElement),
250  const MeasureType & iValue) const
251  {
252  return ( iValue <= this->m_MeasureBound );
253  }
254 
255 protected:
258 
259 private:
261  void operator=(const Self &);
262 };
263 
269 template< class TMesh,
270  typename TElement = IdentifierType,
271  typename TMeasure = double,
272  class TPriorityQueueWrapper =
273  MaxPriorityQueueElementWrapper< typename TMesh::QEType *,
274  std::pair< bool, TMeasure > > >
276  public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
277  TMeasure, TPriorityQueueWrapper >
278 {
279 public:
283  typedef QuadEdgeMeshDecimationCriterion< TMesh, TElement,
284  TMeasure, TPriorityQueueWrapper > Superclass;
285 
288 
290  itkNewMacro(Self);
291 
292  typedef typename Superclass::MeshType MeshType;
293  typedef typename MeshType::CellsContainerConstIterator CellsContainerConstIterator;
298 
299  inline bool is_satisfied(MeshType *,
300  const ElementType & ,
301  const MeasureType & iValue) const
302  {
303  return ( iValue >= this->m_MeasureBound );
304  }
305 
306 protected:
309 
310 private:
312  void operator=(const Self &);
313 };
314 }
315 
316 #endif
317