ITK  5.1.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_ASSIGN(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  itkGetConstMacro(TopologicalChange, bool);
70  itkSetMacro(TopologicalChange, bool);
71 
72  virtual bool
73  is_satisfied(MeshType * iMesh, const ElementType & iElement, const MeasureType & iValue) const = 0;
74 
75 protected:
77  {
78  this->m_TopologicalChange = true;
79  this->m_SizeCriterion = true;
80  this->m_NumberOfElements = 0;
82  }
83 
84  ~QuadEdgeMeshDecimationCriterion() override = default;
85  void
86  PrintSelf(std::ostream & os, Indent indent) const override
87  {
88  Superclass::PrintSelf(os, indent);
89  os << indent << "TopologicalChange: " << (m_TopologicalChange ? "On" : "Off") << std::endl;
90  os << indent << "SizeCriterion: " << (m_SizeCriterion ? "On" : "Off") << std::endl;
91  os << indent << "NumberOfElements: " << m_NumberOfElements << std::endl;
92  os << indent << "MeasureBound: " << m_MeasureBound << std::endl;
93  }
94 
97 
99 
101 };
102 
108 template <typename TMesh,
109  typename TElement = IdentifierType,
110  typename TMeasure = double,
111  typename TPriorityQueueWrapper =
113 class NumberOfPointsCriterion : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
114 {
115 public:
116  ITK_DISALLOW_COPY_AND_ASSIGN(NumberOfPointsCriterion);
117 
122 
125 
127  itkNewMacro(Self);
128 
129  using MeshType = typename Superclass::MeshType;
134 
135  inline bool
136  is_satisfied(MeshType * iMesh, const ElementType & itkNotUsed(iElement), const MeasureType & itkNotUsed(iValue)) const
137  {
138  return (iMesh->GetNumberOfPoints() <= this->m_NumberOfElements);
139  }
140 
141 protected:
142  NumberOfPointsCriterion() = default;
143  ~NumberOfPointsCriterion() = default;
144 };
145 
151 template <typename TMesh,
152  typename TElement = IdentifierType,
153  typename TMeasure = double,
154  typename TPriorityQueueWrapper =
155  MinPriorityQueueElementWrapper<typename TMesh::QEType *, std::pair<bool, TMeasure>>>
156 class NumberOfFacesCriterion : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
157 {
158 public:
159  ITK_DISALLOW_COPY_AND_ASSIGN(NumberOfFacesCriterion);
160 
165 
168 
170  itkNewMacro(Self);
171 
172  using MeshType = typename Superclass::MeshType;
173  using CellsContainerConstIterator = typename MeshType::CellsContainerConstIterator;
178 
179  bool
181  const ElementType & itkNotUsed(iElement),
182  const MeasureType & itkNotUsed(iValue)) const override
183  {
184  return (iMesh->GetNumberOfFaces() <= this->m_NumberOfElements);
185  }
186 
187 protected:
188  NumberOfFacesCriterion() = default;
189  ~NumberOfFacesCriterion() override = default;
190 };
191 
197 template <typename TMesh,
198  typename TElement = IdentifierType,
199  typename TMeasure = double,
200  typename TPriorityQueueWrapper =
201  MinPriorityQueueElementWrapper<typename TMesh::QEType *, std::pair<bool, TMeasure>>>
203  : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
204 {
205 public:
206  ITK_DISALLOW_COPY_AND_ASSIGN(MaxMeasureBoundCriterion);
207 
212 
215 
217  itkNewMacro(Self);
218 
219  using MeshType = typename Superclass::MeshType;
220  using CellsContainerConstIterator = typename MeshType::CellsContainerConstIterator;
225 
226  bool
227  is_satisfied(MeshType * itkNotUsed(iMesh),
228  const ElementType & itkNotUsed(iElement),
229  const MeasureType & iValue) const override
230  {
231  return (iValue <= this->m_MeasureBound);
232  }
233 
234 protected:
236  : Superclass()
237  {}
238  ~MaxMeasureBoundCriterion() override = default;
239 };
240 
246 template <typename TMesh,
247  typename TElement = IdentifierType,
248  typename TMeasure = double,
249  typename TPriorityQueueWrapper =
250  MaxPriorityQueueElementWrapper<typename TMesh::QEType *, std::pair<bool, TMeasure>>>
252  : public QuadEdgeMeshDecimationCriterion<TMesh, TElement, TMeasure, TPriorityQueueWrapper>
253 {
254 public:
255  ITK_DISALLOW_COPY_AND_ASSIGN(MinMeasureBoundCriterion);
256 
261 
264 
266  itkNewMacro(Self);
267 
268  using MeshType = typename Superclass::MeshType;
269  using CellsContainerConstIterator = typename MeshType::CellsContainerConstIterator;
274 
275  inline bool
276  is_satisfied(MeshType *, const ElementType &, const MeasureType & iValue) const
277  {
278  return (iValue >= this->m_MeasureBound);
279  }
280 
281 protected:
282  MinMeasureBoundCriterion() = default;
283  ~MinMeasureBoundCriterion() = default;
284 };
285 } // namespace itk
286 
287 #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:86
itk::QuadEdgeMeshDecimationCriterion::m_NumberOfElements
SizeValueType m_NumberOfElements
Definition: itkQuadEdgeMeshDecimationCriteria.h:98
itk::NumberOfFacesCriterion::CellsContainerConstIterator
typename MeshType::CellsContainerConstIterator CellsContainerConstIterator
Definition: itkQuadEdgeMeshDecimationCriteria.h:173
itk::NumberOfFacesCriterion::NumberOfFacesCriterion
NumberOfFacesCriterion()=default
itk::NumberOfFacesCriterion::~NumberOfFacesCriterion
~NumberOfFacesCriterion() override=default
itk::NumberOfFacesCriterion
Definition: itkQuadEdgeMeshDecimationCriteria.h:156
itk::MaxMeasureBoundCriterion::CellsContainerConstIterator
typename MeshType::CellsContainerConstIterator CellsContainerConstIterator
Definition: itkQuadEdgeMeshDecimationCriteria.h:220
itk::MaxMeasureBoundCriterion
Definition: itkQuadEdgeMeshDecimationCriteria.h:202
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:136
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:180
itk::QuadEdgeMeshDecimationCriterion::m_MeasureBound
MeasureType m_MeasureBound
Definition: itkQuadEdgeMeshDecimationCriteria.h:100
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:95
itk::NumberOfPointsCriterion
Definition: itkQuadEdgeMeshDecimationCriteria.h:113
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: itkArray.h:26
itk::QuadEdgeMeshDecimationCriterion::MeasureType
TMeasure MeasureType
Definition: itkQuadEdgeMeshDecimationCriteria.h:51
itk::QuadEdgeMeshDecimationCriterion::QuadEdgeMeshDecimationCriterion
QuadEdgeMeshDecimationCriterion()
Definition: itkQuadEdgeMeshDecimationCriteria.h:76
itk::MinMeasureBoundCriterion
Definition: itkQuadEdgeMeshDecimationCriteria.h:251
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:60
itk::MaxMeasureBoundCriterion::~MaxMeasureBoundCriterion
~MaxMeasureBoundCriterion() override=default
itk::MinPriorityQueueElementWrapper
Definition: itkPriorityQueueContainer.h:104
itk::MaxMeasureBoundCriterion::MaxMeasureBoundCriterion
MaxMeasureBoundCriterion()
Definition: itkQuadEdgeMeshDecimationCriteria.h:235
itk::MinMeasureBoundCriterion::CellsContainerConstIterator
typename MeshType::CellsContainerConstIterator CellsContainerConstIterator
Definition: itkQuadEdgeMeshDecimationCriteria.h:269
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:276
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:96
itk::MaxMeasureBoundCriterion::is_satisfied
bool is_satisfied(MeshType *, const ElementType &, const MeasureType &iValue) const override
Definition: itkQuadEdgeMeshDecimationCriteria.h:227