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 NumberOfPointsCriterion : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
115 {
116 public:
117  ITK_DISALLOW_COPY_AND_MOVE(NumberOfPointsCriterion);
118 
123 
126 
128  itkNewMacro(Self);
129 
130  using MeshType = typename Superclass::MeshType;
135 
136  inline bool
137  is_satisfied(MeshType * iMesh, const ElementType & itkNotUsed(iElement), const MeasureType & itkNotUsed(iValue)) const
138  {
139  return (iMesh->GetNumberOfPoints() <= this->m_NumberOfElements);
140  }
141 
142 protected:
143  NumberOfPointsCriterion() = default;
144  ~NumberOfPointsCriterion() = default;
145 };
146 
152 template <typename TMesh,
153  typename TElement = IdentifierType,
154  typename TMeasure = double,
155  typename TPriorityQueueWrapper =
156  MinPriorityQueueElementWrapper<typename TMesh::QEType *, std::pair<bool, TMeasure>>>
157 class NumberOfFacesCriterion : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
158 {
159 public:
160  ITK_DISALLOW_COPY_AND_MOVE(NumberOfFacesCriterion);
161 
166 
169 
171  itkNewMacro(Self);
172 
173  using MeshType = typename Superclass::MeshType;
174  using CellsContainerConstIterator = typename MeshType::CellsContainerConstIterator;
179 
180  bool
182  const ElementType & itkNotUsed(iElement),
183  const MeasureType & itkNotUsed(iValue)) const override
184  {
185  return (iMesh->GetNumberOfFaces() <= this->m_NumberOfElements);
186  }
187 
188 protected:
189  NumberOfFacesCriterion() = default;
190  ~NumberOfFacesCriterion() override = default;
191 };
192 
198 template <typename TMesh,
199  typename TElement = IdentifierType,
200  typename TMeasure = double,
201  typename TPriorityQueueWrapper =
202  MinPriorityQueueElementWrapper<typename TMesh::QEType *, std::pair<bool, TMeasure>>>
204  : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
205 {
206 public:
207  ITK_DISALLOW_COPY_AND_MOVE(MaxMeasureBoundCriterion);
208 
213 
216 
218  itkNewMacro(Self);
219 
220  using MeshType = typename Superclass::MeshType;
221  using CellsContainerConstIterator = typename MeshType::CellsContainerConstIterator;
226 
227  bool
228  is_satisfied(MeshType * itkNotUsed(iMesh),
229  const ElementType & itkNotUsed(iElement),
230  const MeasureType & iValue) const override
231  {
232  return (iValue <= this->m_MeasureBound);
233  }
234 
235 protected:
237  : Superclass()
238  {}
239  ~MaxMeasureBoundCriterion() override = default;
240 };
241 
247 template <typename TMesh,
248  typename TElement = IdentifierType,
249  typename TMeasure = double,
250  typename TPriorityQueueWrapper =
251  MaxPriorityQueueElementWrapper<typename TMesh::QEType *, std::pair<bool, TMeasure>>>
253  : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
254 {
255 public:
256  ITK_DISALLOW_COPY_AND_MOVE(MinMeasureBoundCriterion);
257 
262 
265 
267  itkNewMacro(Self);
268 
269  using MeshType = typename Superclass::MeshType;
270  using CellsContainerConstIterator = typename MeshType::CellsContainerConstIterator;
275 
276  inline bool
277  is_satisfied(MeshType *, const ElementType &, const MeasureType & iValue) const
278  {
279  return (iValue >= this->m_MeasureBound);
280  }
281 
282 protected:
283  MinMeasureBoundCriterion() = default;
284  ~MinMeasureBoundCriterion() = default;
285 };
286 } // namespace itk
287 
288 #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:174
itk::NumberOfFacesCriterion::NumberOfFacesCriterion
NumberOfFacesCriterion()=default
itk::NumberOfFacesCriterion::~NumberOfFacesCriterion
~NumberOfFacesCriterion() override=default
itk::NumberOfFacesCriterion
Definition: itkQuadEdgeMeshDecimationCriteria.h:157
itk::MaxMeasureBoundCriterion::CellsContainerConstIterator
typename MeshType::CellsContainerConstIterator CellsContainerConstIterator
Definition: itkQuadEdgeMeshDecimationCriteria.h:221
itk::MaxMeasureBoundCriterion
Definition: itkQuadEdgeMeshDecimationCriteria.h:203
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:137
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:181
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
itk::NumberOfPointsCriterion::NumberOfPointsCriterion
NumberOfPointsCriterion()=default
itkPriorityQueueContainer.h
itk::QuadEdgeMeshDecimationCriterion::ElementType
TElement ElementType
Definition: itkQuadEdgeMeshDecimationCriteria.h:50
itk::MinMeasureBoundCriterion::MinMeasureBoundCriterion
MinMeasureBoundCriterion()=default
itkIntTypes.h
itk::NumberOfPointsCriterion::~NumberOfPointsCriterion
~NumberOfPointsCriterion()=default
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:252
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:236
itk::MinMeasureBoundCriterion::CellsContainerConstIterator
typename MeshType::CellsContainerConstIterator CellsContainerConstIterator
Definition: itkQuadEdgeMeshDecimationCriteria.h:270
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:277
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:228