ITK  5.3.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  * 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 *, std::pair<bool, TMeasure>>>
37 {
38 public:
39  ITK_DISALLOW_COPY_AND_MOVE(QuadEdgeMeshDecimationCriterion);
40 
44  using Superclass = Object;
45 
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 
76 protected:
78  {
79  this->m_TopologicalChange = true;
80  this->m_SizeCriterion = true;
81  this->m_NumberOfElements = 0;
83  }
84 
85  ~QuadEdgeMeshDecimationCriterion() override = default;
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 
109 template <typename TMesh,
110  typename TElement = IdentifierType,
111  typename TMeasure = double,
112  typename TPriorityQueueWrapper =
114 class ITK_TEMPLATE_EXPORT NumberOfPointsCriterion
115  : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
116 {
117 public:
118  ITK_DISALLOW_COPY_AND_MOVE(NumberOfPointsCriterion);
119 
124 
127 
129  itkNewMacro(Self);
130 
131  using typename Superclass::MeshType;
132  using typename Superclass::ElementType;
133  using typename Superclass::MeasureType;
134  using typename Superclass::PriorityQueueWrapperType;
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 
143 protected:
144  NumberOfPointsCriterion() = default;
145  ~NumberOfPointsCriterion() = default;
146 };
147 
153 template <typename TMesh,
154  typename TElement = IdentifierType,
155  typename TMeasure = double,
156  typename TPriorityQueueWrapper =
157  MinPriorityQueueElementWrapper<typename TMesh::QEType *, std::pair<bool, TMeasure>>>
158 class ITK_TEMPLATE_EXPORT NumberOfFacesCriterion
159  : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
160 {
161 public:
162  ITK_DISALLOW_COPY_AND_MOVE(NumberOfFacesCriterion);
163 
168 
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;
179  using typename Superclass::PriorityQueueWrapperType;
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 
190 protected:
191  NumberOfFacesCriterion() = default;
192  ~NumberOfFacesCriterion() override = default;
193 };
194 
200 template <typename TMesh,
201  typename TElement = IdentifierType,
202  typename TMeasure = double,
203  typename TPriorityQueueWrapper =
204  MinPriorityQueueElementWrapper<typename TMesh::QEType *, std::pair<bool, TMeasure>>>
206  : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
207 {
208 public:
209  ITK_DISALLOW_COPY_AND_MOVE(MaxMeasureBoundCriterion);
210 
215 
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 
237 protected:
239  : Superclass()
240  {}
241  ~MaxMeasureBoundCriterion() override = default;
242 };
243 
249 template <typename TMesh,
250  typename TElement = IdentifierType,
251  typename TMeasure = double,
252  typename TPriorityQueueWrapper =
253  MaxPriorityQueueElementWrapper<typename TMesh::QEType *, std::pair<bool, TMeasure>>>
255  : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
256 {
257 public:
258  ITK_DISALLOW_COPY_AND_MOVE(MinMeasureBoundCriterion);
259 
264 
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 
284 protected:
285  MinMeasureBoundCriterion() = default;
286  ~MinMeasureBoundCriterion() = default;
287 };
288 } // namespace itk
289 
290 #endif
itk::QuadEdgeMeshDecimationCriterion::is_satisfied
virtual bool is_satisfied(MeshType *iMesh, const ElementType &iElement, const MeasureType &iValue) const =0
itk::QuadEdgeMeshDecimationCriterion::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkQuadEdgeMeshDecimationCriteria.h:87
itk::QuadEdgeMeshDecimationCriterion::m_NumberOfElements
SizeValueType m_NumberOfElements
Definition: itkQuadEdgeMeshDecimationCriteria.h:99
itk::NumberOfFacesCriterion::CellsContainerConstIterator
typename MeshType::CellsContainerConstIterator CellsContainerConstIterator
Definition: itkQuadEdgeMeshDecimationCriteria.h:176
itk::NumberOfFacesCriterion
Definition: itkQuadEdgeMeshDecimationCriteria.h:158
itk::MaxMeasureBoundCriterion::CellsContainerConstIterator
typename MeshType::CellsContainerConstIterator CellsContainerConstIterator
Definition: itkQuadEdgeMeshDecimationCriteria.h:223
itk::MaxMeasureBoundCriterion
Definition: itkQuadEdgeMeshDecimationCriteria.h:205
itk::QuadEdgeMeshDecimationCriterion::SetNumberOfElements
void SetNumberOfElements(const SizeValueType &numberOfElements)
Definition: itkQuadEdgeMeshDecimationCriteria.h:56
itk::QuadEdgeMeshDecimationCriterion::SetMeasureBound
void SetMeasureBound(const MeasureType &bound)
Definition: itkQuadEdgeMeshDecimationCriteria.h:63
itk::NumberOfPointsCriterion::is_satisfied
bool is_satisfied(MeshType *iMesh, const ElementType &, const MeasureType &) const
Definition: itkQuadEdgeMeshDecimationCriteria.h:138
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::NumberOfFacesCriterion::is_satisfied
bool is_satisfied(MeshType *iMesh, const ElementType &, const MeasureType &) const override
Definition: itkQuadEdgeMeshDecimationCriteria.h:183
itk::QuadEdgeMeshDecimationCriterion::m_MeasureBound
MeasureType m_MeasureBound
Definition: itkQuadEdgeMeshDecimationCriteria.h:101
itk::QuadEdgeMeshDecimationCriterion::MeshType
TMesh MeshType
Definition: itkQuadEdgeMeshDecimationCriteria.h:49
itk::MinMeasureBoundCriterion::~MinMeasureBoundCriterion
~MinMeasureBoundCriterion()=default
itk::QuadEdgeMeshDecimationCriterion::~QuadEdgeMeshDecimationCriterion
~QuadEdgeMeshDecimationCriterion() override=default
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::QuadEdgeMeshDecimationCriterion::m_TopologicalChange
bool m_TopologicalChange
Definition: itkQuadEdgeMeshDecimationCriteria.h:96
itk::NumberOfPointsCriterion
Definition: itkQuadEdgeMeshDecimationCriteria.h:114
itk::QuadEdgeMeshDecimationCriterion::PriorityType
typename PriorityQueueWrapperType::ElementPriorityType PriorityType
Definition: itkQuadEdgeMeshDecimationCriteria.h:53
itk::QuadEdgeMeshDecimationCriterion
Definition: itkQuadEdgeMeshDecimationCriteria.h:36
itkPriorityQueueContainer.h
itk::QuadEdgeMeshDecimationCriterion::ElementType
TElement ElementType
Definition: itkQuadEdgeMeshDecimationCriteria.h:50
itk::MinMeasureBoundCriterion::MinMeasureBoundCriterion
MinMeasureBoundCriterion()=default
itkIntTypes.h
itk::NumericTraits::ZeroValue
static T ZeroValue()
Definition: itkNumericTraits.h:148
itk::QuadEdgeMeshDecimationCriterion::PriorityQueueWrapperType
TPriorityQueueWrapper PriorityQueueWrapperType
Definition: itkQuadEdgeMeshDecimationCriteria.h:52
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::QuadEdgeMeshDecimationCriterion::MeasureType
TMeasure MeasureType
Definition: itkQuadEdgeMeshDecimationCriteria.h:51
itk::QuadEdgeMeshDecimationCriterion::QuadEdgeMeshDecimationCriterion
QuadEdgeMeshDecimationCriterion()
Definition: itkQuadEdgeMeshDecimationCriteria.h:77
itk::MinMeasureBoundCriterion
Definition: itkQuadEdgeMeshDecimationCriteria.h:254
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itk::MaxMeasureBoundCriterion::~MaxMeasureBoundCriterion
~MaxMeasureBoundCriterion() override=default
itk::MinPriorityQueueElementWrapper
Definition: itkPriorityQueueContainer.h:104
itk::MaxMeasureBoundCriterion::MaxMeasureBoundCriterion
MaxMeasureBoundCriterion()
Definition: itkQuadEdgeMeshDecimationCriteria.h:238
itk::MinMeasureBoundCriterion::CellsContainerConstIterator
typename MeshType::CellsContainerConstIterator CellsContainerConstIterator
Definition: itkQuadEdgeMeshDecimationCriteria.h:272
itk::Object::Object
Object()
itk::Object::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::MinMeasureBoundCriterion::is_satisfied
bool is_satisfied(MeshType *, const ElementType &, const MeasureType &iValue) const
Definition: itkQuadEdgeMeshDecimationCriteria.h:279
itk::IdentifierType
SizeValueType IdentifierType
Definition: itkIntTypes.h:87
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::QuadEdgeMeshDecimationCriterion::m_SizeCriterion
bool m_SizeCriterion
Definition: itkQuadEdgeMeshDecimationCriteria.h:97
itk::MaxMeasureBoundCriterion::is_satisfied
bool is_satisfied(MeshType *, const ElementType &, const MeasureType &iValue) const override
Definition: itkQuadEdgeMeshDecimationCriteria.h:230