ITK  5.0.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< typename TMesh,
32  typename TElement = IdentifierType,
33  typename TMeasure = double,
34  typename TPriorityQueueWrapper =
35  MinPriorityQueueElementWrapper< typename TMesh::QEType *,
36  std::pair< bool, TMeasure > > >
38 {
39 public:
43  using Superclass = Object;
44 
47 
48  using MeshType = TMesh;
49  using ElementType = TElement;
50  using MeasureType = TMeasure;
51  using PriorityQueueWrapperType = TPriorityQueueWrapper;
52  using PriorityType = typename PriorityQueueWrapperType::ElementPriorityType;
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 >::ZeroValue();
80  }
81 
82  ~QuadEdgeMeshDecimationCriterion() override = default;
83  void PrintSelf(std::ostream & os, Indent indent) const override
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: "
94  << std::endl;
95  os << indent << "MeasureBound: "
97  << std::endl;
98  }
99 
102 
104 
106 
107 private:
108  QuadEdgeMeshDecimationCriterion(const Self &) = delete;
109  void operator=(const Self &) = delete;
110 };
111 
117 template< typename TMesh,
118  typename TElement = IdentifierType,
119  typename TMeasure = double,
120  typename 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 >;
133 
136 
138  itkNewMacro(Self);
139 
140  using MeshType = typename Superclass::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:
154  NumberOfPointsCriterion() = default;
155  ~NumberOfPointsCriterion() = default;
156 
157 private:
158  NumberOfPointsCriterion(const Self &) = delete;
159  void operator=(const Self &) = delete;
160 };
161 
167 template< typename TMesh,
168  typename TElement = IdentifierType,
169  typename TMeasure = double,
170  typename TPriorityQueueWrapper =
171  MinPriorityQueueElementWrapper< typename TMesh::QEType *,
172  std::pair< bool, TMeasure > > >
174  public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
175  TMeasure, TPriorityQueueWrapper >
176 {
177 public:
181  using Superclass = QuadEdgeMeshDecimationCriterion< TMesh, TElement,
182  TMeasure, TPriorityQueueWrapper >;
183 
186 
188  itkNewMacro(Self);
189 
190  using MeshType = typename Superclass::MeshType;
191  using CellsContainerConstIterator = typename MeshType::CellsContainerConstIterator;
196 
197  bool is_satisfied( MeshType *iMesh,
198  const ElementType & itkNotUsed(iElement),
199  const MeasureType & itkNotUsed(iValue) ) const override
200  {
201  return ( iMesh->GetNumberOfFaces() <= this->m_NumberOfElements );
202  }
203 
204 protected:
205  NumberOfFacesCriterion() = default;
206  ~NumberOfFacesCriterion() override = default;
207 
208 private:
209  NumberOfFacesCriterion(const Self &) = delete;
210  void operator=(const Self &) = delete;
211 };
212 
218 template< typename TMesh,
219  typename TElement = IdentifierType,
220  typename TMeasure = double,
221  typename TPriorityQueueWrapper =
222  MinPriorityQueueElementWrapper< typename TMesh::QEType *,
223  std::pair< bool, TMeasure > > >
225  public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
226  TMeasure, TPriorityQueueWrapper >
227 {
228 public:
232  using Superclass = QuadEdgeMeshDecimationCriterion< TMesh, TElement,
233  TMeasure, TPriorityQueueWrapper >;
234 
237 
239  itkNewMacro(Self);
240 
241  using MeshType = typename Superclass::MeshType;
242  using CellsContainerConstIterator = typename MeshType::CellsContainerConstIterator;
247 
248  bool is_satisfied(MeshType *itkNotUsed(iMesh),
249  const ElementType & itkNotUsed(iElement),
250  const MeasureType & iValue) const override
251  {
252  return ( iValue <= this->m_MeasureBound );
253  }
254 
255 protected:
257  ~MaxMeasureBoundCriterion() override = default;
258 
259 private:
260  MaxMeasureBoundCriterion(const Self &) = delete;
261  void operator=(const Self &) = delete;
262 };
263 
269 template< typename TMesh,
270  typename TElement = IdentifierType,
271  typename TMeasure = double,
272  typename TPriorityQueueWrapper =
273  MaxPriorityQueueElementWrapper< typename TMesh::QEType *,
274  std::pair< bool, TMeasure > > >
276  public QuadEdgeMeshDecimationCriterion< TMesh, TElement,
277  TMeasure, TPriorityQueueWrapper >
278 {
279 public:
283  using Superclass = QuadEdgeMeshDecimationCriterion< TMesh, TElement,
284  TMeasure, TPriorityQueueWrapper >;
285 
288 
290  itkNewMacro(Self);
291 
292  using MeshType = typename Superclass::MeshType;
293  using CellsContainerConstIterator = typename MeshType::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:
307  MinMeasureBoundCriterion() = default;
308  ~MinMeasureBoundCriterion() = default;
309 
310 private:
311  MinMeasureBoundCriterion(const Self &) = delete;
312  void operator=(const Self &) = delete;
313 };
314 }
315 
316 #endif
void operator=(const Self &)=delete
Light weight base class for most itk classes.
bool is_satisfied(MeshType *iMesh, const ElementType &, const MeasureType &) const override
void SetNumberOfElements(const SizeValueType &numberOfElements)
bool is_satisfied(MeshType *, const ElementType &, const MeasureType &iValue) const override
unsigned long SizeValueType
Definition: itkIntTypes.h:83
~QuadEdgeMeshDecimationCriterion() override=default
typename MeshType::CellsContainerConstIterator CellsContainerConstIterator
void operator=(const Self &)=delete
typename MeshType::CellsContainerConstIterator CellsContainerConstIterator
void operator=(const Self &)=delete
typename PriorityQueueWrapperType::ElementPriorityType PriorityType
void PrintSelf(std::ostream &os, Indent indent) const override
SizeValueType IdentifierType
Definition: itkIntTypes.h:87
bool is_satisfied(MeshType *iMesh, const ElementType &, const MeasureType &) const
void PrintSelf(std::ostream &os, Indent indent) const override
virtual bool is_satisfied(MeshType *iMesh, const ElementType &iElement, const MeasureType &iValue) const =0
~MaxMeasureBoundCriterion() override=default
void operator=(const Self &)=delete
bool is_satisfied(MeshType *, const ElementType &, const MeasureType &iValue) const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
~NumberOfFacesCriterion() override=default
void operator=(const Self &)=delete
Base class for most ITK classes.
Definition: itkObject.h:60
typename MeshType::CellsContainerConstIterator CellsContainerConstIterator