ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkDelaunayConformingQuadEdgeMeshFilter.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 itkDelaunayConformingQuadEdgeMeshFilter_h
19#define itkDelaunayConformingQuadEdgeMeshFilter_h
20
21#include "itkIntTypes.h"
25#include "itkMath.h"
26
27namespace itk
28{
36template <typename TInputMesh, typename TOutputMesh = TInputMesh>
37class ITK_TEMPLATE_EXPORT DelaunayConformingQuadEdgeMeshFilter
38 : public QuadEdgeMeshToQuadEdgeMeshFilter<TInputMesh, TOutputMesh>
39{
40public:
41 ITK_DISALLOW_COPY_AND_MOVE(DelaunayConformingQuadEdgeMeshFilter);
42
48
50 using InputMeshType = TInputMesh;
51 using InputMeshPointer = typename InputMeshType::Pointer;
52 using InputCoordinateType = typename InputMeshType::CoordinateType;
53#ifndef ITK_FUTURE_LEGACY_REMOVE
54 using InputCoordRepType ITK_FUTURE_DEPRECATED(
55 "ITK 6 discourages using `InputCoordRepType`. Please use `InputCoordinateType` instead!") = InputCoordinateType;
56#endif
57 using InputPointType = typename InputMeshType::PointType;
58 using InputPointVectorType = typename InputPointType::VectorType;
59 using InputPointIdentifier = typename InputMeshType::PointIdentifier;
60 using InputQEType = typename InputMeshType::QEType;
61 using InputVectorType = typename InputMeshType::VectorType;
62 using InputEdgeListType = typename InputMeshType::EdgeListType;
63 using InputPixelType = typename InputMeshType::PixelType;
64 using InputTraits = typename InputMeshType::Traits;
65
66 static constexpr unsigned int InputVDimension = InputMeshType::PointDimension;
67
68 using InputPointsContainer = typename InputMeshType::PointsContainer;
69 using InputPointsContainerConstIterator = typename InputMeshType::PointsContainerConstIterator;
70 using InputCellsContainerConstIterator = typename InputMeshType::CellsContainerConstIterator;
71 using InputEdgeCellType = typename InputMeshType::EdgeCellType;
72 using InputPolygonCellType = typename InputMeshType::PolygonCellType;
73 using InputPointIdList = typename InputMeshType::PointIdList;
74
75 using InputQEIterator = typename InputQEType::IteratorGeom;
76
78 using OutputMeshType = TOutputMesh;
79 using OutputMeshPointer = typename OutputMeshType::Pointer;
80 using OutputCoordinateType = typename OutputMeshType::CoordinateType;
81#ifndef ITK_FUTURE_LEGACY_REMOVE
82 using OutputCoordRepType ITK_FUTURE_DEPRECATED(
83 "ITK 6 discourages using `OutputCoordRepType`. Please use `OutputCoordinateType` instead!") = OutputCoordinateType;
84#endif
85 using OutputPointType = typename OutputMeshType::PointType;
86 using OutputPointIdentifier = typename OutputMeshType::PointIdentifier;
87 using OutputCellType = typename OutputMeshType::CellType;
88 using OutputCellIdentifier = typename OutputMeshType::CellIdentifier;
89 using OutputEdgeCellType = typename OutputMeshType::EdgeCellType;
90 using OutputQEType = typename OutputMeshType::QEType;
91 using OutputLineCellIdentifier = typename OutputQEType::LineCellIdentifier;
92 using OutputVectorType = typename OutputMeshType::VectorType;
93 using OutputQEIterator = typename OutputQEType::IteratorGeom;
94 using OutputPointsContainerPointer = typename OutputMeshType::PointsContainerPointer;
95 using OutputPointsContainerIterator = typename OutputMeshType::PointsContainerIterator;
96 using OutputCellsContainer = typename OutputMeshType::CellsContainer;
97 using OutputCellsContainerIterator = typename OutputMeshType::CellsContainerIterator;
98
99 static constexpr unsigned int OutputVDimension = OutputMeshType::PointDimension;
100
101 itkNewMacro(Self);
102 itkOverrideGetNameOfClassMacro(DelaunayConformingQuadEdgeMeshFilter);
103
104 itkGetConstMacro(NumberOfEdgeFlips, SizeValueType);
105
106public:
107 using OutputEdgeCellListType = std::list<OutputEdgeCellType *>;
108 using OutputEdgeCellListIterator = typename OutputEdgeCellListType::iterator;
109
110 using CriterionValueType = double;
111 using PriorityType = std::pair<bool, CriterionValueType>;
112
114
118 long>;
119
121 using QueueMapType = std::map<OutputEdgeCellType *, PriorityQueueItemType *>;
122 using QueueMapIterator = typename QueueMapType::iterator;
123
126
127 void
132
133protected:
136 void
137 PrintSelf(std::ostream & os, Indent indent) const override;
138
142
145
146 void
147 GenerateData() override;
148
149 void
151
152 void
154
155 void
157
158 inline CriterionValueType
160 {
161 const OutputPointIdentifier id1 = iEdge->GetOrigin();
162 const OutputPointIdentifier id2 = iEdge->GetDestination();
163
164 const OutputPointIdentifier idA = iEdge->GetLnext()->GetDestination();
165 const OutputPointIdentifier idB = iEdge->GetRnext()->GetOrigin();
166
167 const OutputPointType pt1 = iMesh->GetPoint(id1);
168 const OutputPointType pt2 = iMesh->GetPoint(id2);
169 const OutputPointType ptA = iMesh->GetPoint(idA);
170 const OutputPointType ptB = iMesh->GetPoint(idB);
171
172 const OutputVectorType v1A = ptA - pt1;
173 const OutputVectorType v1B = ptB - pt1;
174 const OutputVectorType v2A = ptA - pt2;
175 const OutputVectorType v2B = ptB - pt2;
176
177 const OutputCoordinateType sq_norm1A = v1A * v1A;
178 const OutputCoordinateType sq_norm1B = v1B * v1B;
179 const OutputCoordinateType sq_norm2A = v2A * v2A;
180 const OutputCoordinateType sq_norm2B = v2B * v2B;
181
182 auto dotA = static_cast<CriterionValueType>(v1A * v2A);
183 auto dotB = static_cast<CriterionValueType>(v1B * v2B);
184 auto den = static_cast<CriterionValueType>(sq_norm1A * sq_norm2A);
185
186 if (den != 0.)
187 {
188 dotA /= std::sqrt(den);
189 }
190
191 if (dotA > 1.)
192 {
193 dotA = 1.;
194 }
195
196 if (dotA < -1.)
197 {
198 dotA = -1.;
199 }
200
201 den = static_cast<CriterionValueType>(sq_norm1B * sq_norm2B);
202
203 if (den != 0.)
204 {
205 dotB /= std::sqrt(den);
206 }
207
208 if (dotB > 1.)
209 {
210 dotB = 1.;
211 }
212
213 if (dotB < -1.)
214 {
215 dotB = -1.;
216 }
217
218 return (std::acos(dotA) + std::acos(dotB) - itk::Math::pi);
219 }
220};
221} // end namespace itk
222
223#include "itkDelaunayConformingQuadEdgeMeshFilter.hxx"
224
225#endif
typename InputMeshType::CellsContainerConstIterator InputCellsContainerConstIterator
typename InputMeshType::PointsContainerConstIterator InputPointsContainerConstIterator
PriorityQueueContainer< PriorityQueueItemType *, ElementWrapperPointerInterface< PriorityQueueItemType * >, PriorityType, long > PriorityQueueType
typename OutputEdgeCellListType::iterator OutputEdgeCellListIterator
typename OutputQEType::LineCellIdentifier OutputLineCellIdentifier
typename OutputMeshType::PointIdentifier OutputPointIdentifier
CriterionValueType Dyer07Criterion(OutputMeshType *iMesh, OutputQEType *iEdge) const
QuadEdgeMeshEulerOperatorFlipEdgeFunction< OutputMeshType, OutputQEType > FlipEdgeFunctionType
typename OutputMeshType::PointsContainerPointer OutputPointsContainerPointer
MaxPriorityQueueElementWrapper< OutputEdgeCellType *, PriorityType, long > PriorityQueueItemType
std::map< OutputEdgeCellType *, PriorityQueueItemType * > QueueMapType
QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh > Superclass
void ReassignCellData(const OutputCellIdentifier &in, const OutputCellIdentifier &out)
void SetListOfConstrainedEdges(const OutputEdgeCellListType &iList)
typename OutputMeshType::PointsContainerIterator OutputPointsContainerIterator
typename OutputMeshType::CellsContainerIterator OutputCellsContainerIterator
void PrintSelf(std::ostream &os, Indent indent) const override
Control indentation during Print() invocation.
Definition itkIndent.h:50
Implements transparent reference counting.
static constexpr double pi
Definition itkMath.h:66
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition itkIntTypes.h:86