ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkQuadEdgeMeshParamMatrixCoefficients.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 itkQuadEdgeMeshParamMatrixCoefficients_h
19 #define itkQuadEdgeMeshParamMatrixCoefficients_h
20 
21 #include "itkQuadEdgeMesh.h"
22 #include "itkTriangleHelper.h"
23 #include "itkMath.h"
24 
25 namespace itk
26 {
32 template< typename TInputMesh >
34 {
35 public:
36  using InputMeshType = TInputMesh;
37  using InputCoordRepType = typename InputMeshType::CoordRepType;
38  using InputQEType = typename InputMeshType::QEType;
39 
40  MatrixCoefficients()= default;
41  virtual ~MatrixCoefficients() = default;
42 
43  virtual InputCoordRepType operator()
44  (const InputMeshType *iMesh, InputQEType *iEdge) const = 0;
45 };
46 
54 template< typename TInputMesh >
55 class OnesMatrixCoefficients:public MatrixCoefficients< TInputMesh >
56 {
57 public:
59 
60  using InputMeshType = TInputMesh;
61  using InputCoordRepType = typename InputMeshType::CoordRepType;
62  using InputQEType = typename InputMeshType::QEType;
63 
64  OnesMatrixCoefficients() = default;
65 
69  InputCoordRepType operator()( const InputMeshType *itkNotUsed(iMesh),
70  InputQEType *itkNotUsed(iEdge) ) const override
71  {
72  return 1.0;
73  }
74 };
76 
84 template< typename TInputMesh >
86  public MatrixCoefficients< TInputMesh >
87 {
88 public:
90 
91  using InputMeshType = TInputMesh;
92  using InputCoordRepType = typename InputMeshType::CoordRepType;
94  using InputPointIdentifier = typename InputMeshType::PointIdentifier;
95  using InputQEType = typename InputMeshType::QEType;
97 
99 
105  InputCoordRepType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
106  {
107  InputPointIdentifier id1 = iEdge->GetOrigin();
108  InputPointIdentifier id2 = iEdge->GetDestination();
110 
111  InputPointType pt1 = iMesh->GetPoint(id1);
112  InputPointType pt2 = iMesh->GetPoint(id2);
113 
114  InputCoordRepType oValue = 1.0 / pt1.EuclideanDistanceTo(pt2);
115 
116  return oValue;
117  }
118 };
119 
127 template< typename TInputMesh >
129 {
130 public:
132 
133  using InputMeshType = TInputMesh;
134  using InputCoordRepType = typename InputMeshType::CoordRepType;
136  using InputPointIdentifier = typename InputMeshType::PointIdentifier;
137  using InputQEType = typename InputMeshType::QEType;
138 
139  ConformalMatrixCoefficients() = default;
140 
146  InputCoordRepType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
147  {
148  InputPointIdentifier id1 = iEdge->GetOrigin();
149  InputPointIdentifier id2 = iEdge->GetDestination();
150  InputPointType pt1 = iMesh->GetPoint(id1);
151  InputPointType pt2 = iMesh->GetPoint(id2);
153 
154  InputCoordRepType oValue(0.0);
155 
156  if ( iEdge->IsLeftSet() )
157  {
158  InputPointIdentifier idA = iEdge->GetLnext()->GetDestination();
159  InputPointType ptA = iMesh->GetPoint(idA);
160  oValue += TriangleHelper< InputPointType >::Cotangent(pt1, ptA, pt2);
161  }
162  if ( iEdge->IsRightSet() )
163  {
164  InputPointIdentifier idB = iEdge->GetRnext()->GetOrigin();
165  InputPointType ptB = iMesh->GetPoint(idB);
166  oValue += TriangleHelper< InputPointType >::Cotangent(pt1, ptB, pt2);
167  }
168 
169  return std::max( NumericTraits< InputCoordRepType >::ZeroValue(), oValue);
170  }
171 };
172 
181 template< typename TInputMesh >
183 {
184 public:
186 
187  using InputMeshType = TInputMesh;
188  using InputCoordRepType = typename InputMeshType::CoordRepType;
190  using InputPointIdentifier = typename InputMeshType::PointIdentifier;
191  using InputQEType = typename InputMeshType::QEType;
192 
193  AuthalicMatrixCoefficients() = default;
194 
201  InputCoordRepType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
202  {
203  InputPointIdentifier id1 = iEdge->GetOrigin();
204  InputPointType pt1 = iMesh->GetPoint(id1);
206 
207  InputPointIdentifier id2 = iEdge->GetDestination();
208  InputPointType pt2 = iMesh->GetPoint(id2);
209 
211 
212  if ( iEdge->IsLeftSet() )
213  {
214  InputPointIdentifier idA = iEdge->GetLnext()->GetDestination();
215  InputPointType ptA = iMesh->GetPoint(idA);
216  oValue +=
218  }
219 
220  if ( iEdge->IsRightSet() )
221  {
222  InputPointIdentifier idB = iEdge->GetRnext()->GetOrigin();
223  InputPointType ptB = iMesh->GetPoint(idB);
224  oValue += TriangleHelper< InputPointType >::Cotangent(pt1, pt2, ptB);
225  }
226 
227  return oValue / pt1.SquaredEuclideanDistanceTo(pt2);
228  }
229 };
230 
238 template< typename TInputMesh >
240 {
241 public:
243 
244  using InputMeshType = TInputMesh;
245  using InputCoordRepType = typename InputMeshType::CoordRepType;
246  using InputQEType = typename InputMeshType::QEType;
247 
249 
251  m_Lambda(iLambda)
252  {}
253 
255  InputQEType *iEdge) const
256  {
259 
260  InputCoordRepType oValue = m_Lambda * conformal(iMesh, iEdge)
261  + ( 1.0 - m_Lambda ) * authalic(iMesh, iEdge);
262 
263  return oValue;
264  }
265 };
266 
274 template< typename TInputMesh >
276 {
277 public:
279 
280  using InputMeshType = TInputMesh;
281  using InputCoordRepType = typename InputMeshType::CoordRepType;
284  using InputPointIdentifier = typename InputMeshType::PointIdentifier;
285  using InputQEType = typename InputMeshType::QEType;
286 
287  static constexpr unsigned int PointDimension = InputPointType::PointDimension;
288 
289  HarmonicMatrixCoefficients() = default;
290 
291  InputCoordRepType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
292  {
293  InputPointIdentifier id1 = iEdge->GetOrigin();
294  InputPointIdentifier id2 = iEdge->GetDestination();
295 
296  InputPointIdentifier idA = iEdge->GetLnext()->GetDestination();
297  InputPointIdentifier idB = iEdge->GetRnext()->GetOrigin();
298 
299  InputPointType pt1 = iMesh->GetPoint(id1);
300  InputPointType pt2 = iMesh->GetPoint(id2);
301  InputPointType ptA = iMesh->GetPoint(idA);
302  InputPointType ptB = iMesh->GetPoint(idB);
303 
304  InputVectorType v1A = ptA - pt1;
305  InputVectorType v1B = ptB - pt1;
306  InputVectorType v12 = pt2 - pt1;
307 
308  InputCoordRepType L1A = v1A * v1A;
309  InputCoordRepType L1B = v1B * v1B;
310  InputCoordRepType L12 = v12 * v12;
311 
312  InputCoordRepType L2A = pt2.SquaredEuclideanDistanceTo(ptA);
313  InputCoordRepType L2B = pt2.SquaredEuclideanDistanceTo(ptB);
314 
316 
317  InputCoordRepType AreaA = 0.5 * ( cross(v1A, v12).GetNorm() );
318  InputCoordRepType AreaB = 0.5 * ( cross(v1B, v12).GetNorm() );
319 
321  oValue = ( L1A + L2A - L12 ) / AreaA + ( L1B + L2B - L12 ) / AreaB;
322 
323  return oValue;
324  }
325 };
326 }
327 #endif
Compute a matrix filed with the inverse of the euclidian distance wherever two vertices are connected...
Compute a matrix filled by 1s wherever two vertices are connected by an edge.
Define numeric traits for std::vector.
IntrinsicMatrixCoefficients(const InputCoordRepType &iLambda)
typename InputMeshType::PointIdentifier InputPointIdentifier
Compute a matrix filed by Conformal Coefficients of the edge wherever two vertices are connected by a...
InputCoordRepType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const
InputCoordRepType operator()(const InputMeshType *, InputQEType *) const override
InputCoordRepType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
typename InputMeshType::PointIdentifier InputPointIdentifier
virtual ~MatrixCoefficients()=default
static CoordRepType Cotangent(const PointType &iA, const PointType &iB, const PointType &iC)
Compute cotangent(iA,iB,iC)
typename InputMeshType::PointIdentifier InputPointIdentifier
Compute a matrix filled with Authalic Coefiicients of the edge, wherever two vertices are connected w...
Compute a matrix filled with Harmonic coefficients, wherever two vertices are connected by an edge...
InputCoordRepType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
Compute a mtrix filled by intrinsic Coefficients of the edge, wherever two vertices are connected by ...
typename InputMeshType::QEType InputQEType
InputCoordRepType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
InputCoordRepType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
typename InputPointType::VectorType InputVectorType
Superclass for all the matrix coefficients computation classes.
typename InputMeshType::CoordRepType InputCoordRepType