ITK  5.2.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  * 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 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;
51  using InputMeshPointer = typename InputMeshType::Pointer;
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;
75  using OutputMeshPointer = typename OutputMeshType::Pointer;
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);
95 
96  itkGetConstMacro(NumberOfEdgeFlips, SizeValueType);
97 
98 public:
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 
109  PriorityType,
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 
125 protected:
128  void
129  PrintSelf(std::ostream & os, Indent indent) const override;
130 
134 
137 
138  void
139  GenerateData() override;
140 
141  void
142  InitializePriorityQueue();
143 
144  void
145  Process();
146 
147  void
148  ReassignCellData(const OutputCellIdentifier & in, const OutputCellIdentifier & out);
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
itk::DelaunayConformingQuadEdgeMeshFilter::PriorityQueuePointer
typename PriorityQueueType::Pointer PriorityQueuePointer
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:112
itk::DelaunayConformingQuadEdgeMeshFilter::OutputLineCellIdentifier
typename OutputQEType::LineCellIdentifier OutputLineCellIdentifier
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:83
itk::DelaunayConformingQuadEdgeMeshFilter::OutputCellType
typename OutputMeshType::CellType OutputCellType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:79
itk::DelaunayConformingQuadEdgeMeshFilter::InputPointVectorType
typename InputPointType::VectorType InputPointVectorType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:54
itk::DelaunayConformingQuadEdgeMeshFilter::OutputEdgeCellListType
std::list< OutputEdgeCellType * > OutputEdgeCellListType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:99
itk::MeshSource::OutputMeshPointer
typename OutputMeshType::Pointer OutputMeshPointer
Definition: itkMeshSource.h:69
itk::DelaunayConformingQuadEdgeMeshFilter::OutputCellsContainer
typename OutputMeshType::CellsContainer OutputCellsContainer
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:88
itk::DelaunayConformingQuadEdgeMeshFilter::m_QueueMapper
QueueMapType m_QueueMapper
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:133
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputPointsContainerPointer
typename OutputMeshType::PointsContainerPointer OutputPointsContainerPointer
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:86
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:102
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:62
itk::DelaunayConformingQuadEdgeMeshFilter::Dyer07Criterion
CriterionValueType Dyer07Criterion(OutputMeshType *iMesh, OutputQEType *iEdge) const
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:151
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::DelaunayConformingQuadEdgeMeshFilter::InputEdgeListType
typename InputMeshType::EdgeListType InputEdgeListType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:58
itkQuadEdgeMeshToQuadEdgeMeshFilter.h
itk::MeshToMeshFilter::InputMeshType
TInputMesh InputMeshType
Definition: itkMeshToMeshFilter.h:65
itk::DelaunayConformingQuadEdgeMeshFilter::QueueMapIterator
typename QueueMapType::iterator QueueMapIterator
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:114
itk::DelaunayConformingQuadEdgeMeshFilter::PriorityType
std::pair< bool, CriterionValueType > PriorityType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:103
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputPointType
typename InputMeshType::PointType InputPointType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:53
itk::DelaunayConformingQuadEdgeMeshFilter::InputTraits
typename InputMeshType::Traits InputTraits
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:60
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputPointIdList
typename InputMeshType::PointIdList InputPointIdList
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:69
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputPointIdentifier
typename InputMeshType::PointIdentifier InputPointIdentifier
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:54
itkPriorityQueueContainer.h
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputVectorType
typename OutputMeshType::VectorType OutputVectorType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:83
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:56
itk::DelaunayConformingQuadEdgeMeshFilter::OutputCellsContainerIterator
typename OutputMeshType::CellsContainerIterator OutputCellsContainerIterator
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:89
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputCoordRepType
typename OutputMeshType::CoordRepType OutputCoordRepType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:79
itk::DelaunayConformingQuadEdgeMeshFilter::m_ListOfConstrainedEdges
OutputEdgeCellListType m_ListOfConstrainedEdges
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:131
itk::DelaunayConformingQuadEdgeMeshFilter::OutputEdgeCellType
typename OutputMeshType::EdgeCellType OutputEdgeCellType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:81
itkIntTypes.h
itk::DelaunayConformingQuadEdgeMeshFilter::m_PriorityQueue
PriorityQueuePointer m_PriorityQueue
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:132
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputEdgeCellType
typename InputMeshType::EdgeCellType InputEdgeCellType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:67
itk::DelaunayConformingQuadEdgeMeshFilter::SetListOfConstrainedEdges
void SetListOfConstrainedEdges(const OutputEdgeCellListType &iList)
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:120
itk::DelaunayConformingQuadEdgeMeshFilter::InputPixelType
typename InputMeshType::PixelType InputPixelType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:59
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputCoordRepType
typename InputMeshType::CoordRepType InputCoordRepType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:52
itkQuadEdgeMeshEulerOperatorFlipEdgeFunction.h
itk::ElementWrapperPointerInterface
Definition: itkPriorityQueueContainer.h:69
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputPolygonCellType
typename InputMeshType::PolygonCellType InputPolygonCellType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:68
itk::DelaunayConformingQuadEdgeMeshFilter::OutputQEType
typename OutputMeshType::QEType OutputQEType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:82
itk::DelaunayConformingQuadEdgeMeshFilter::m_NumberOfEdgeFlips
SizeValueType m_NumberOfEdgeFlips
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:135
itk::MeshSource::OutputMeshType
TOutputMesh OutputMeshType
Definition: itkMeshSource.h:68
itk::DelaunayConformingQuadEdgeMeshFilter::m_FlipEdge
FlipEdgeFunctionPointer m_FlipEdge
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:136
itk::DelaunayConformingQuadEdgeMeshFilter::FlipEdgeFunctionPointer
typename FlipEdgeFunctionType::Pointer FlipEdgeFunctionPointer
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:117
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputVectorType
typename InputMeshType::VectorType InputVectorType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:56
itk::Math::pi
static constexpr double pi
Definition: itkMath.h:64
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputQEIterator
typename OutputQEPrimal::IteratorGeom OutputQEIterator
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:84
itk::DelaunayConformingQuadEdgeMeshFilter::QueueMapType
std::map< OutputEdgeCellType *, PriorityQueueItemType * > QueueMapType
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:113
itk::DelaunayConformingQuadEdgeMeshFilter::OutputCellIdentifier
typename OutputMeshType::CellIdentifier OutputCellIdentifier
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:80
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputPointIdentifier
typename OutputMeshType::PointIdentifier OutputPointIdentifier
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:81
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputPointType
typename OutputMeshType::PointType OutputPointType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:80
itkMath.h
itk::DelaunayConformingQuadEdgeMeshFilter::InputPointsContainer
typename InputMeshType::PointsContainer InputPointsContainer
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:64
itk::DelaunayConformingQuadEdgeMeshFilter::OutputEdgeCellListIterator
typename OutputEdgeCellListType::iterator OutputEdgeCellListIterator
Definition: itkDelaunayConformingQuadEdgeMeshFilter.h:100
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputPointsContainerIterator
typename OutputMeshType::PointsContainerIterator OutputPointsContainerIterator
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:85
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputCellsContainerConstIterator
typename InputMeshType::CellsContainerConstIterator InputCellsContainerConstIterator
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:64
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::PriorityQueueContainer
Definition: itkPriorityQueueContainer.h:193
itk::MaxPriorityQueueElementWrapper
Definition: itkPriorityQueueContainer.h:156
itk::QuadEdgeMeshToQuadEdgeMeshFilter::InputQEIterator
typename InputQEPrimal::IteratorGeom InputQEIterator
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:73