ITK  5.4.0
Insight Toolkit
itkQuadEdgeMeshDecimationCriteria.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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
24namespace itk
25{
31template <typename TMesh,
32 typename TElement = IdentifierType,
33 typename TMeasure = double,
34 typename TPriorityQueueWrapper =
35 MinPriorityQueueElementWrapper<typename TMesh::QEType *, std::pair<bool, TMeasure>>>
37{
38public:
39 ITK_DISALLOW_COPY_AND_MOVE(QuadEdgeMeshDecimationCriterion);
40
45
47 itkOverrideGetNameOfClassMacro(QuadEdgeMeshDecimationCriterion);
48
49 using MeshType = TMesh;
50 using ElementType = TElement;
51 using MeasureType = TMeasure;
52 using PriorityQueueWrapperType = TPriorityQueueWrapper;
53 using PriorityType = typename PriorityQueueWrapperType::ElementPriorityType;
54
55 void
56 SetNumberOfElements(const SizeValueType & numberOfElements)
57 {
58 this->m_SizeCriterion = true;
59 this->m_NumberOfElements = numberOfElements;
60 }
61
62 void
64 {
65 this->m_SizeCriterion = false;
66 this->m_MeasureBound = bound;
67 }
68
69 itkBooleanMacro(TopologicalChange);
70 itkGetConstMacro(TopologicalChange, bool);
71 itkSetMacro(TopologicalChange, bool);
72
73 virtual bool
74 is_satisfied(MeshType * iMesh, const ElementType & iElement, const MeasureType & iValue) const = 0;
75
76protected:
78 {
79 this->m_TopologicalChange = true;
80 this->m_SizeCriterion = true;
81 this->m_NumberOfElements = 0;
83 }
84
86 void
87 PrintSelf(std::ostream & os, Indent indent) const override
88 {
89 Superclass::PrintSelf(os, indent);
90 os << indent << "TopologicalChange: " << (m_TopologicalChange ? "On" : "Off") << std::endl;
91 os << indent << "SizeCriterion: " << (m_SizeCriterion ? "On" : "Off") << std::endl;
92 os << indent << "NumberOfElements: " << m_NumberOfElements << std::endl;
93 os << indent << "MeasureBound: " << m_MeasureBound << std::endl;
94 }
95
98
100
102};
103
109template <typename TMesh,
110 typename TElement = IdentifierType,
111 typename TMeasure = double,
112 typename TPriorityQueueWrapper =
113 MinPriorityQueueElementWrapper<typename TMesh::QEType *, std::pair<bool, TMeasure>>>
114class ITK_TEMPLATE_EXPORT NumberOfPointsCriterion
115 : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
116{
117public:
118 ITK_DISALLOW_COPY_AND_MOVE(NumberOfPointsCriterion);
119
124
126 itkOverrideGetNameOfClassMacro(NumberOfPointsCriterion);
127
129 itkNewMacro(Self);
130
131 using typename Superclass::MeshType;
132 using typename Superclass::ElementType;
133 using typename Superclass::MeasureType;
135 using typename Superclass::PriorityType;
136
137 inline bool
138 is_satisfied(MeshType * iMesh, const ElementType & itkNotUsed(iElement), const MeasureType & itkNotUsed(iValue)) const
139 {
140 return (iMesh->GetNumberOfPoints() <= this->m_NumberOfElements);
141 }
142
143protected:
146};
147
153template <typename TMesh,
154 typename TElement = IdentifierType,
155 typename TMeasure = double,
156 typename TPriorityQueueWrapper =
158class ITK_TEMPLATE_EXPORT NumberOfFacesCriterion
159 : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
160{
161public:
162 ITK_DISALLOW_COPY_AND_MOVE(NumberOfFacesCriterion);
163
168
170 itkOverrideGetNameOfClassMacro(NumberOfFacesCriterion);
171
173 itkNewMacro(Self);
174
175 using typename Superclass::MeshType;
176 using CellsContainerConstIterator = typename MeshType::CellsContainerConstIterator;
177 using typename Superclass::ElementType;
178 using typename Superclass::MeasureType;
180 using typename Superclass::PriorityType;
181
182 bool
184 const ElementType & itkNotUsed(iElement),
185 const MeasureType & itkNotUsed(iValue)) const override
186 {
187 return (iMesh->GetNumberOfFaces() <= this->m_NumberOfElements);
188 }
189
190protected:
192 ~NumberOfFacesCriterion() override = default;
193};
194
200template <typename TMesh,
201 typename TElement = IdentifierType,
202 typename TMeasure = double,
203 typename TPriorityQueueWrapper =
206 : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
207{
208public:
209 ITK_DISALLOW_COPY_AND_MOVE(MaxMeasureBoundCriterion);
210
215
217 itkOverrideGetNameOfClassMacro(MaxMeasureBoundCriterion);
218
220 itkNewMacro(Self);
221
222 using typename Superclass::MeshType;
223 using CellsContainerConstIterator = typename MeshType::CellsContainerConstIterator;
224 using typename Superclass::ElementType;
225 using typename Superclass::MeasureType;
227 using typename Superclass::PriorityType;
228
229 bool
230 is_satisfied(MeshType * itkNotUsed(iMesh),
231 const ElementType & itkNotUsed(iElement),
232 const MeasureType & iValue) const override
233 {
234 return (iValue <= this->m_MeasureBound);
235 }
236
237protected:
239 : Superclass()
240 {}
241 ~MaxMeasureBoundCriterion() override = default;
242};
243
249template <typename TMesh,
250 typename TElement = IdentifierType,
251 typename TMeasure = double,
252 typename TPriorityQueueWrapper =
255 : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
256{
257public:
258 ITK_DISALLOW_COPY_AND_MOVE(MinMeasureBoundCriterion);
259
264
266 itkOverrideGetNameOfClassMacro(MinMeasureBoundCriterion);
267
269 itkNewMacro(Self);
270
271 using typename Superclass::MeshType;
272 using CellsContainerConstIterator = typename MeshType::CellsContainerConstIterator;
273 using typename Superclass::ElementType;
274 using typename Superclass::MeasureType;
276 using typename Superclass::PriorityType;
277
278 inline bool
279 is_satisfied(MeshType *, const ElementType &, const MeasureType & iValue) const
280 {
281 return (iValue >= this->m_MeasureBound);
282 }
283
284protected:
287};
288} // namespace itk
289
290#endif
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
~MaxMeasureBoundCriterion() override=default
bool is_satisfied(MeshType *, const ElementType &, const MeasureType &iValue) const override
typename MeshType::CellsContainerConstIterator CellsContainerConstIterator
typename MeshType::CellsContainerConstIterator CellsContainerConstIterator
bool is_satisfied(MeshType *, const ElementType &, const MeasureType &iValue) const
bool is_satisfied(MeshType *iMesh, const ElementType &, const MeasureType &) const override
~NumberOfFacesCriterion() override=default
typename MeshType::CellsContainerConstIterator CellsContainerConstIterator
bool is_satisfied(MeshType *iMesh, const ElementType &, const MeasureType &) const
Base class for most ITK classes.
Definition: itkObject.h:62
void PrintSelf(std::ostream &os, Indent indent) const override
void PrintSelf(std::ostream &os, Indent indent) const override
~QuadEdgeMeshDecimationCriterion() override=default
void SetNumberOfElements(const SizeValueType &numberOfElements)
virtual bool is_satisfied(MeshType *iMesh, const ElementType &iElement, const MeasureType &iValue) const =0
typename PriorityQueueWrapperType::ElementPriorityType PriorityType
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
SizeValueType IdentifierType
Definition: itkIntTypes.h:87
unsigned long SizeValueType
Definition: itkIntTypes.h:83