ITK  6.0.0
Insight Toolkit
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;
52 using InputCoordRepType = typename InputMeshType::CoordRepType;
55 using InputPointIdentifier = typename InputMeshType::PointIdentifier;
56 using InputQEType = typename InputMeshType::QEType;
58 using InputEdgeListType = typename InputMeshType::EdgeListType;
59 using InputPixelType = typename InputMeshType::PixelType;
60 using InputTraits = typename InputMeshType::Traits;
61
62 static constexpr unsigned int InputVDimension = InputMeshType::PointDimension;
63
64 using InputPointsContainer = typename InputMeshType::PointsContainer;
65 using InputPointsContainerConstIterator = typename InputMeshType::PointsContainerConstIterator;
66 using InputCellsContainerConstIterator = typename InputMeshType::CellsContainerConstIterator;
67 using InputEdgeCellType = typename InputMeshType::EdgeCellType;
68 using InputPolygonCellType = typename InputMeshType::PolygonCellType;
69 using InputPointIdList = typename InputMeshType::PointIdList;
70
71 using InputQEIterator = typename InputQEType::IteratorGeom;
72
74 using OutputMeshType = TOutputMesh;
76 using OutputCoordRepType = typename OutputMeshType::CoordRepType;
78 using OutputPointIdentifier = typename OutputMeshType::PointIdentifier;
79 using OutputCellType = typename OutputMeshType::CellType;
80 using OutputCellIdentifier = typename OutputMeshType::CellIdentifier;
81 using OutputEdgeCellType = typename OutputMeshType::EdgeCellType;
82 using OutputQEType = typename OutputMeshType::QEType;
83 using OutputLineCellIdentifier = typename OutputQEType::LineCellIdentifier;
85 using OutputQEIterator = typename OutputQEType::IteratorGeom;
86 using OutputPointsContainerPointer = typename OutputMeshType::PointsContainerPointer;
87 using OutputPointsContainerIterator = typename OutputMeshType::PointsContainerIterator;
88 using OutputCellsContainer = typename OutputMeshType::CellsContainer;
89 using OutputCellsContainerIterator = typename OutputMeshType::CellsContainerIterator;
90
91 static constexpr unsigned int OutputVDimension = OutputMeshType::PointDimension;
92
93 itkNewMacro(Self);
94 itkOverrideGetNameOfClassMacro(DelaunayConformingQuadEdgeMeshFilter);
95
96 itkGetConstMacro(NumberOfEdgeFlips, SizeValueType);
97
98public:
99 using OutputEdgeCellListType = std::list<OutputEdgeCellType *>;
100 using OutputEdgeCellListIterator = typename OutputEdgeCellListType::iterator;
101
102 using CriterionValueType = double;
103 using PriorityType = std::pair<bool, CriterionValueType>;
104
106
110 long>;
111
113 using QueueMapType = std::map<OutputEdgeCellType *, PriorityQueueItemType *>;
114 using QueueMapIterator = typename QueueMapType::iterator;
115
118
119 void
121 {
122 m_ListOfConstrainedEdges = iList;
123 }
124
125protected:
128 void
129 PrintSelf(std::ostream & os, Indent indent) const override;
130
131 OutputEdgeCellListType m_ListOfConstrainedEdges{};
132 PriorityQueuePointer m_PriorityQueue{};
133 QueueMapType m_QueueMapper{};
134
135 SizeValueType m_NumberOfEdgeFlips{};
137
138 void
139 GenerateData() override;
140
141 void
143
144 void
146
147 void
149
150 inline CriterionValueType
152 {
153 OutputPointIdentifier id1 = iEdge->GetOrigin();
154 OutputPointIdentifier id2 = iEdge->GetDestination();
155
156 OutputPointIdentifier idA = iEdge->GetLnext()->GetDestination();
157 OutputPointIdentifier idB = iEdge->GetRnext()->GetOrigin();
158
159 OutputPointType pt1 = iMesh->GetPoint(id1);
160 OutputPointType pt2 = iMesh->GetPoint(id2);
161 OutputPointType ptA = iMesh->GetPoint(idA);
162 OutputPointType ptB = iMesh->GetPoint(idB);
163
164 OutputVectorType v1A = ptA - pt1;
165 OutputVectorType v1B = ptB - pt1;
166 OutputVectorType v2A = ptA - pt2;
167 OutputVectorType v2B = ptB - pt2;
168
169 OutputCoordRepType sq_norm1A = v1A * v1A;
170 OutputCoordRepType sq_norm1B = v1B * v1B;
171 OutputCoordRepType sq_norm2A = v2A * v2A;
172 OutputCoordRepType sq_norm2B = v2B * v2B;
173
174 auto dotA = static_cast<CriterionValueType>(v1A * v2A);
175 auto dotB = static_cast<CriterionValueType>(v1B * v2B);
176 auto den = static_cast<CriterionValueType>(sq_norm1A * sq_norm2A);
177
178 if (den != 0.)
179 {
180 dotA /= std::sqrt(den);
181 }
182
183 if (dotA > 1.)
184 {
185 dotA = 1.;
186 }
187
188 if (dotA < -1.)
189 {
190 dotA = -1.;
191 }
192
193 den = static_cast<CriterionValueType>(sq_norm1B * sq_norm2B);
194
195 if (den != 0.)
196 {
197 dotB /= std::sqrt(den);
198 }
199
200 if (dotB > 1.)
201 {
202 dotB = 1.;
203 }
204
205 if (dotB < -1.)
206 {
207 dotB = -1.;
208 }
209
210 return (std::acos(dotA) + std::acos(dotB) - itk::Math::pi);
211 }
212};
213} // end namespace itk
214
215#include "itkDelaunayConformingQuadEdgeMeshFilter.hxx"
216
217#endif
typename InputMeshType::CellsContainerConstIterator InputCellsContainerConstIterator
typename InputMeshType::PolygonCellType InputPolygonCellType
typename InputMeshType::PointsContainerConstIterator InputPointsContainerConstIterator
typename InputMeshType::PointIdentifier InputPointIdentifier
typename OutputEdgeCellListType::iterator OutputEdgeCellListIterator
typename OutputQEType::LineCellIdentifier OutputLineCellIdentifier
typename OutputMeshType::PointIdentifier OutputPointIdentifier
CriterionValueType Dyer07Criterion(OutputMeshType *iMesh, OutputQEType *iEdge) const
typename InputMeshType::PointsContainer InputPointsContainer
typename OutputMeshType::PointsContainerPointer OutputPointsContainerPointer
std::map< OutputEdgeCellType *, PriorityQueueItemType * > QueueMapType
typename OutputMeshType::CellsContainer OutputCellsContainer
typename FlipEdgeFunctionType::Pointer FlipEdgeFunctionPointer
typename OutputMeshType::CellIdentifier OutputCellIdentifier
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
Light weight base class for most itk classes.
SmartPointer< Self > Pointer
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