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 
27 namespace itk
28 {
36 template <typename TInputMesh, typename TOutputMesh = TInputMesh>
37 class ITK_TEMPLATE_EXPORT DelaunayConformingQuadEdgeMeshFilter
38  : public QuadEdgeMeshToQuadEdgeMeshFilter<TInputMesh, TOutputMesh>
39 {
40 public:
41  ITK_DISALLOW_COPY_AND_MOVE(DelaunayConformingQuadEdgeMeshFilter);
42 
48 
50  using InputMeshType = TInputMesh;
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
59  using InputPointIdentifier = typename InputMeshType::PointIdentifier;
60  using InputQEType = typename InputMeshType::QEType;
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;
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
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;
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 
106 public:
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 
117  PriorityType,
118  long>;
119 
121  using QueueMapType = std::map<OutputEdgeCellType *, PriorityQueueItemType *>;
122  using QueueMapIterator = typename QueueMapType::iterator;
123 
126 
127  void
129  {
130  m_ListOfConstrainedEdges = iList;
131  }
132 
133 protected:
136  void
137  PrintSelf(std::ostream & os, Indent indent) const override;
138 
139  OutputEdgeCellListType m_ListOfConstrainedEdges{};
140  PriorityQueuePointer m_PriorityQueue{};
141  QueueMapType m_QueueMapper{};
142 
143  SizeValueType m_NumberOfEdgeFlips{};
145 
146  void
147  GenerateData() override;
148 
149  void
150  InitializePriorityQueue();
151 
152  void
153  Process();
154 
155  void
156  ReassignCellData(const OutputCellIdentifier & in, const OutputCellIdentifier & out);
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
itk::DelaunayConformingQuadEdgeMeshFilter::PriorityQueuePointer
typename PriorityQueueType::Pointer PriorityQueuePointer
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:120
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::DelaunayConformingQuadEdgeMeshFilter::OutputLineCellIdentifier
typename OutputQEType::LineCellIdentifier OutputLineCellIdentifier
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:91
itk::DelaunayConformingQuadEdgeMeshFilter::OutputCellType
typename OutputMeshType::CellType OutputCellType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:87
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputCoordinateType
typename InputMeshType::CoordinateType InputCoordinateType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:52
itk::DelaunayConformingQuadEdgeMeshFilter::InputPointVectorType
typename InputPointType::VectorType InputPointVectorType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:58
itk::DelaunayConformingQuadEdgeMeshFilter::OutputEdgeCellListType
std::list< OutputEdgeCellType * > OutputEdgeCellListType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:107
itk::MeshSource::OutputMeshPointer
typename OutputMeshType::Pointer OutputMeshPointer
Definition: itkMeshSource.h:69
itk::DelaunayConformingQuadEdgeMeshFilter::OutputCellsContainer
typename OutputMeshType::CellsContainer OutputCellsContainer
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:96
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputPointsContainerPointer
typename OutputMeshType::PointsContainerPointer OutputPointsContainerPointer
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:94
itk::DelaunayConformingQuadEdgeMeshFilter
FIXME Add documentation.
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:37
itk::MeshToMeshFilter::InputMeshPointer
typename InputMeshType::Pointer InputMeshPointer
Definition: itkMeshToMeshFilter.h:66
itk::DelaunayConformingQuadEdgeMeshFilter::CriterionValueType
double CriterionValueType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:110
itk::GTest::TypedefsAndConstructors::Dimension2::VectorType
ImageBaseType::SpacingType VectorType
Definition: itkGTestTypedefsAndConstructors.h:53
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputPointsContainerConstIterator
typename InputMeshType::PointsContainerConstIterator InputPointsContainerConstIterator
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:66
itk::DelaunayConformingQuadEdgeMeshFilter::Dyer07Criterion
CriterionValueType Dyer07Criterion(OutputMeshType *iMesh, OutputQEType *iEdge) const
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:159
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::DelaunayConformingQuadEdgeMeshFilter::InputEdgeListType
typename InputMeshType::EdgeListType InputEdgeListType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:62
itkQuadEdgeMeshToQuadEdgeMeshFilter.h
itk::MeshToMeshFilter::InputMeshType
TInputMesh InputMeshType
Definition: itkMeshToMeshFilter.h:65
itk::DelaunayConformingQuadEdgeMeshFilter::QueueMapIterator
typename QueueMapType::iterator QueueMapIterator
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:122
itk::DelaunayConformingQuadEdgeMeshFilter::PriorityType
std::pair< bool, CriterionValueType > PriorityType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:111
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputPointType
typename InputMeshType::PointType InputPointType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:57
itk::DelaunayConformingQuadEdgeMeshFilter::InputTraits
typename InputMeshType::Traits InputTraits
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:64
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputPointIdList
typename InputMeshType::PointIdList InputPointIdList
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:73
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputPointIdentifier
typename InputMeshType::PointIdentifier InputPointIdentifier
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:58
itkPriorityQueueContainer.h
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputVectorType
typename OutputMeshType::VectorType OutputVectorType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:91
itk::QuadEdgeMeshToQuadEdgeMeshFilter
Duplicates the content of a Mesh.
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:37
itk::QuadEdgeMeshEulerOperatorFlipEdgeFunction
Flip an edge.
Definition: itkQuadEdgeMeshEulerOperatorFlipEdgeFunction.h:68
itk::DelaunayConformingQuadEdgeMeshFilter::InputQEType
typename InputMeshType::QEType InputQEType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:60
itk::DelaunayConformingQuadEdgeMeshFilter::OutputCellsContainerIterator
typename OutputMeshType::CellsContainerIterator OutputCellsContainerIterator
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:97
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputCoordinateType
typename OutputMeshType::CoordinateType OutputCoordinateType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:83
itk::DelaunayConformingQuadEdgeMeshFilter::OutputEdgeCellType
typename OutputMeshType::EdgeCellType OutputEdgeCellType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:89
itkIntTypes.h
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputEdgeCellType
typename InputMeshType::EdgeCellType InputEdgeCellType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:71
itk::DelaunayConformingQuadEdgeMeshFilter::SetListOfConstrainedEdges
void SetListOfConstrainedEdges(const OutputEdgeCellListType &iList)
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:128
itk::DelaunayConformingQuadEdgeMeshFilter::InputPixelType
typename InputMeshType::PixelType InputPixelType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:63
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itkQuadEdgeMeshEulerOperatorFlipEdgeFunction.h
itk::ElementWrapperPointerInterface
Definition: itkPriorityQueueContainer.h:69
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputPolygonCellType
typename InputMeshType::PolygonCellType InputPolygonCellType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:72
itk::DelaunayConformingQuadEdgeMeshFilter::OutputQEType
typename OutputMeshType::QEType OutputQEType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:90
itk::MeshSource::OutputMeshType
TOutputMesh OutputMeshType
Definition: itkMeshSource.h:68
itk::DelaunayConformingQuadEdgeMeshFilter::FlipEdgeFunctionPointer
typename FlipEdgeFunctionType::Pointer FlipEdgeFunctionPointer
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:125
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputVectorType
typename InputMeshType::VectorType InputVectorType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:60
itk::Math::pi
static constexpr double pi
Definition: itkMath.h:66
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputQEIterator
typename OutputQEPrimal::IteratorGeom OutputQEIterator
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:92
itk::DelaunayConformingQuadEdgeMeshFilter::QueueMapType
std::map< OutputEdgeCellType *, PriorityQueueItemType * > QueueMapType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:121
itk::DelaunayConformingQuadEdgeMeshFilter::OutputCellIdentifier
typename OutputMeshType::CellIdentifier OutputCellIdentifier
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:88
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputPointIdentifier
typename OutputMeshType::PointIdentifier OutputPointIdentifier
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:89
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputPointType
typename OutputMeshType::PointType OutputPointType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:88
itkMath.h
itk::DelaunayConformingQuadEdgeMeshFilter::InputPointsContainer
typename InputMeshType::PointsContainer InputPointsContainer
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:68
itk::DelaunayConformingQuadEdgeMeshFilter::OutputEdgeCellListIterator
typename OutputEdgeCellListType::iterator OutputEdgeCellListIterator
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:108
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputPointsContainerIterator
typename OutputMeshType::PointsContainerIterator OutputPointsContainerIterator
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:93
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputCellsContainerConstIterator
typename InputMeshType::CellsContainerConstIterator InputCellsContainerConstIterator
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:68
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
itk::PriorityQueueContainer
Definition: itkPriorityQueueContainer.h:193
itk::MaxPriorityQueueElementWrapper
Definition: itkPriorityQueueContainer.h:156
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputQEIterator
typename InputQEPrimal::IteratorGeom InputQEIterator
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:77