ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkDelaunayConformingQuadEdgeMeshFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 "vnl/vnl_math.h"
26 
27 namespace itk
28 {
36 template< typename TInputMesh, typename TOutputMesh=TInputMesh >
38  public QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh >
39 {
40 public:
41 
44  typedef QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh,
45  TOutputMesh > Superclass;
48 
50  typedef TInputMesh InputMeshType;
51  typedef typename InputMeshType::Pointer InputMeshPointer;
52  typedef typename InputMeshType::CoordRepType InputCoordRepType;
53  typedef typename InputMeshType::PointType InputPointType;
54  typedef typename InputPointType::VectorType InputPointVectorType;
55  typedef typename InputMeshType::PointIdentifier InputPointIdentifier;
56  typedef typename InputMeshType::QEType InputQEType;
57  typedef typename InputMeshType::VectorType InputVectorType;
58  typedef typename InputMeshType::EdgeListType InputEdgeListType;
59  typedef typename InputMeshType::PixelType InputPixelType;
60  typedef typename InputMeshType::Traits InputTraits;
61 
62  itkStaticConstMacro(InputVDimension, unsigned int, InputMeshType::PointDimension);
63 
64  typedef typename InputMeshType::PointsContainer InputPointsContainer;
65  typedef typename InputMeshType::PointsContainerConstIterator InputPointsContainerConstIterator;
66  typedef typename InputMeshType::CellsContainerConstIterator InputCellsContainerConstIterator;
67  typedef typename InputMeshType::EdgeCellType InputEdgeCellType;
68  typedef typename InputMeshType::PolygonCellType InputPolygonCellType;
69  typedef typename InputMeshType::PointIdList InputPointIdList;
70 
71  typedef typename InputQEType::IteratorGeom InputQEIterator;
72 
74  typedef TOutputMesh OutputMeshType;
75  typedef typename OutputMeshType::Pointer OutputMeshPointer;
76  typedef typename OutputMeshType::CoordRepType OutputCoordRepType;
77  typedef typename OutputMeshType::PointType OutputPointType;
78  typedef typename OutputMeshType::PointIdentifier OutputPointIdentifier;
79  typedef typename OutputMeshType::CellType OutputCellType;
80  typedef typename OutputMeshType::CellIdentifier OutputCellIdentifier;
81  typedef typename OutputMeshType::EdgeCellType OutputEdgeCellType;
82  typedef typename OutputMeshType::QEType OutputQEType;
83  typedef typename OutputQEType::LineCellIdentifier OutputLineCellIdentifier;
84  typedef typename OutputMeshType::VectorType OutputVectorType;
85  typedef typename OutputQEType::IteratorGeom OutputQEIterator;
86  typedef typename OutputMeshType::PointsContainerPointer OutputPointsContainerPointer;
87  typedef typename OutputMeshType::PointsContainerIterator OutputPointsContainerIterator;
88  typedef typename OutputMeshType::CellsContainer OutputCellsContainer;
89  typedef typename OutputMeshType::CellsContainerIterator OutputCellsContainerIterator;
90 
91  itkStaticConstMacro(OutputVDimension, unsigned int, OutputMeshType::PointDimension);
92 
93  itkNewMacro(Self);
95 
96  itkGetConstMacro(NumberOfEdgeFlips, SizeValueType);
97 
98 public:
99  typedef std::list< OutputEdgeCellType * > OutputEdgeCellListType;
100  typedef typename OutputEdgeCellListType::iterator OutputEdgeCellListIterator;
101 
102  typedef double CriterionValueType;
103  typedef std::pair< bool, CriterionValueType > PriorityType;
104 
107 
110  PriorityType,
112 
114  typedef std::map< OutputEdgeCellType *, PriorityQueueItemType * > QueueMapType;
115  typedef typename QueueMapType::iterator QueueMapIterator;
116 
120 
122  {
123  m_ListOfConstrainedEdges = iList;
124  }
125 
126 protected:
129  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
130 
134 
137 
138  void GenerateData() ITK_OVERRIDE;
139 
141 
142  void Process();
143 
144  inline CriterionValueType
146  {
147  OutputPointIdentifier id1 = iEdge->GetOrigin();
148  OutputPointIdentifier id2 = iEdge->GetDestination();
149 
150  OutputPointIdentifier idA = iEdge->GetLnext()->GetDestination();
151  OutputPointIdentifier idB = iEdge->GetRnext()->GetOrigin();
152 
153  OutputPointType pt1 = iMesh->GetPoint(id1);
154  OutputPointType pt2 = iMesh->GetPoint(id2);
155  OutputPointType ptA = iMesh->GetPoint(idA);
156  OutputPointType ptB = iMesh->GetPoint(idB);
157 
158  OutputVectorType v1A = ptA - pt1;
159  OutputVectorType v1B = ptB - pt1;
160  OutputVectorType v2A = ptA - pt2;
161  OutputVectorType v2B = ptB - pt2;
162 
163  OutputCoordRepType sq_norm1A = v1A * v1A;
164  OutputCoordRepType sq_norm1B = v1B * v1B;
165  OutputCoordRepType sq_norm2A = v2A * v2A;
166  OutputCoordRepType sq_norm2B = v2B * v2B;
167 
168  CriterionValueType dotA = static_cast< CriterionValueType >( v1A * v2A );
169  CriterionValueType dotB = static_cast< CriterionValueType >( v1B * v2B );
170  CriterionValueType den = static_cast< CriterionValueType >( sq_norm1A * sq_norm2A );
171 
172  if ( den != 0. )
173  {
174  dotA /= std::sqrt(den);
175  }
176 
177  if ( dotA > 1. )
178  {
179  dotA = 1.;
180  }
181 
182  if ( dotA < -1. )
183  {
184  dotA = -1.;
185  }
186 
187  den = static_cast< CriterionValueType >( sq_norm1B * sq_norm2B );
188 
189  if ( den != 0. )
190  {
191  dotB /= std::sqrt(den);
192  }
193 
194  if ( dotB > 1. )
195  {
196  dotB = 1.;
197  }
198 
199  if ( dotB < -1. )
200  {
201  dotB = -1.;
202  }
203 
204  return ( std::acos(dotA) + std::acos(dotB) - vnl_math::pi );
205  }
206 
207 private:
208 
209  DelaunayConformingQuadEdgeMeshFilter(const Self &); // Purposely not
210  // implemented
211  void operator=(const Self &); // Purposely not
212  // implemented
213 }; //
214 } // end namespace itk
215 
216 #include "itkDelaunayConformingQuadEdgeMeshFilter.hxx"
217 
218 #endif
Light weight base class for most itk classes.
QuadEdgeMeshEulerOperatorFlipEdgeFunction< OutputMeshType, OutputQEType > FlipEdgeFunctionType
TOutputMesh OutputMeshType
Definition: itkMeshSource.h:66
std::map< OutputEdgeCellType *, PriorityQueueItemType * > QueueMapType
QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh > Superclass
OutputMeshType::PointsContainerPointer OutputPointsContainerPointer
static const double pi
Definition: itkMath.h:55
unsigned long SizeValueType
Definition: itkIntTypes.h:143
OutputMeshType::PointsContainerIterator OutputPointsContainerIterator
InputMeshType::CellsContainerConstIterator InputCellsContainerConstIterator
CriterionValueType Dyer07Criterion(OutputMeshType *iMesh, OutputQEType *iEdge) const
void PrintSelf(std::ostream &os, Indent indent) const override
Control indentation during Print() invocation.
Definition: itkIndent.h:49
InputMeshType::PointsContainerConstIterator InputPointsContainerConstIterator
PriorityQueueContainer< PriorityQueueItemType *, ElementWrapperPointerInterface< PriorityQueueItemType * >, PriorityType, long > PriorityQueueType
MaxPriorityQueueElementWrapper< OutputEdgeCellType *, PriorityType, long > PriorityQueueItemType
void SetListOfConstrainedEdges(const OutputEdgeCellListType &iList)
OutputMeshType::CellsContainerIterator OutputCellsContainerIterator