ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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 =
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 itkPrintSelfBooleanMacro(TopologicalChange);
91 itkPrintSelfBooleanMacro(SizeCriterion);
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,
139 const ElementType & itkNotUsed(iElement),
140 const MeasureType & itkNotUsed(iValue)) const override
141 {
142 return (iMesh->GetNumberOfPoints() <= this->m_NumberOfElements);
143 }
144
145protected:
147 ~NumberOfPointsCriterion() override = default;
148};
149
155template <typename TMesh,
156 typename TElement = IdentifierType,
157 typename TMeasure = double,
158 typename TPriorityQueueWrapper =
160class ITK_TEMPLATE_EXPORT NumberOfFacesCriterion
161 : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
162{
163public:
164 ITK_DISALLOW_COPY_AND_MOVE(NumberOfFacesCriterion);
165
170
172 itkOverrideGetNameOfClassMacro(NumberOfFacesCriterion);
173
175 itkNewMacro(Self);
176
177 using typename Superclass::MeshType;
178 using CellsContainerConstIterator = typename MeshType::CellsContainerConstIterator;
179 using typename Superclass::ElementType;
180 using typename Superclass::MeasureType;
182 using typename Superclass::PriorityType;
183
184 bool
185 is_satisfied(MeshType * iMesh,
186 const ElementType & itkNotUsed(iElement),
187 const MeasureType & itkNotUsed(iValue)) const override
188 {
189 return (iMesh->GetNumberOfFaces() <= this->m_NumberOfElements);
190 }
191
192protected:
194 ~NumberOfFacesCriterion() override = default;
195};
196
202template <typename TMesh,
203 typename TElement = IdentifierType,
204 typename TMeasure = double,
205 typename TPriorityQueueWrapper =
208 : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
209{
210public:
211 ITK_DISALLOW_COPY_AND_MOVE(MaxMeasureBoundCriterion);
212
217
219 itkOverrideGetNameOfClassMacro(MaxMeasureBoundCriterion);
220
222 itkNewMacro(Self);
223
224 using typename Superclass::MeshType;
225 using CellsContainerConstIterator = typename MeshType::CellsContainerConstIterator;
226 using typename Superclass::ElementType;
227 using typename Superclass::MeasureType;
229 using typename Superclass::PriorityType;
230
231 bool
232 is_satisfied(MeshType * itkNotUsed(iMesh),
233 const ElementType & itkNotUsed(iElement),
234 const MeasureType & iValue) const override
235 {
236 return (iValue <= this->m_MeasureBound);
237 }
238
239protected:
243 ~MaxMeasureBoundCriterion() override = default;
244};
245
251template <typename TMesh,
252 typename TElement = IdentifierType,
253 typename TMeasure = double,
254 typename TPriorityQueueWrapper =
257 : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
258{
259public:
260 ITK_DISALLOW_COPY_AND_MOVE(MinMeasureBoundCriterion);
261
266
268 itkOverrideGetNameOfClassMacro(MinMeasureBoundCriterion);
269
271 itkNewMacro(Self);
272
273 using typename Superclass::MeshType;
274 using CellsContainerConstIterator = typename MeshType::CellsContainerConstIterator;
275 using typename Superclass::ElementType;
276 using typename Superclass::MeasureType;
278 using typename Superclass::PriorityType;
279
280 inline bool
281 is_satisfied(MeshType *, const ElementType &, const MeasureType & iValue) const override
282 {
283 return (iValue >= this->m_MeasureBound);
284 }
285
286protected:
288 ~MinMeasureBoundCriterion() override = default;
289};
290} // namespace itk
291
292#endif
Control indentation during Print() invocation.
Definition itkIndent.h:50
~MaxMeasureBoundCriterion() override=default
QuadEdgeMeshDecimationCriterion< OutputMeshType, IdentifierType, double, MinPriorityQueueElementWrapper< typename OutputMeshType::QEType *, std::pair< bool, double > > > Superclass
typename MeshType::CellsContainerConstIterator CellsContainerConstIterator
bool is_satisfied(MeshType *iMesh, const ElementType &iElement, const MeasureType &iValue) const override
typename MeshType::CellsContainerConstIterator CellsContainerConstIterator
~MinMeasureBoundCriterion() override=default
bool is_satisfied(MeshType *, const ElementType &, const MeasureType &iValue) const override
QuadEdgeMeshDecimationCriterion< TMesh, TElement, TMeasure, TPriorityQueueWrapper > Superclass
~NumberOfFacesCriterion() override=default
bool is_satisfied(MeshType *iMesh, const ElementType &iElement, const MeasureType &iValue) const override
typename MeshType::CellsContainerConstIterator CellsContainerConstIterator
QuadEdgeMeshDecimationCriterion< TMesh, TElement, TMeasure, TPriorityQueueWrapper > Superclass
bool is_satisfied(MeshType *iMesh, const ElementType &iElement, const MeasureType &iValue) const override
QuadEdgeMeshDecimationCriterion< TMesh, TElement, TMeasure, TPriorityQueueWrapper > Superclass
~NumberOfPointsCriterion() override=default
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
Implements transparent reference counting.
unsigned long IdentifierType
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
SizeValueType IdentifierType
Definition itkIntTypes.h:90
unsigned long SizeValueType
Definition itkIntTypes.h:86