ITK  6.0.0
Insight Toolkit
itkQuadEdgeMeshParamMatrixCoefficients.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 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 InputCoordinateType = typename InputMeshType::CoordinateType;
38 #ifndef ITK_FUTURE_LEGACY_REMOVE
39  using InputCoordRepType ITK_FUTURE_DEPRECATED(
40  "ITK 6 discourages using `InputCoordRepType`. Please use `InputCoordinateType` instead!") = InputCoordinateType;
41 #endif
42  using InputQEType = typename InputMeshType::QEType;
43 
44  MatrixCoefficients() = default;
45  virtual ~MatrixCoefficients() = default;
46 
47  virtual InputCoordinateType
48  operator()(const InputMeshType * iMesh, InputQEType * iEdge) const = 0;
49 };
50 
58 template <typename TInputMesh>
59 class ITK_TEMPLATE_EXPORT OnesMatrixCoefficients : public MatrixCoefficients<TInputMesh>
60 {
61 public:
63 
64  using InputMeshType = TInputMesh;
65  using InputCoordinateType = typename InputMeshType::CoordinateType;
66 #ifndef ITK_FUTURE_LEGACY_REMOVE
67  using InputCoordRepType ITK_FUTURE_DEPRECATED(
68  "ITK 6 discourages using `InputCoordRepType`. Please use `InputCoordinateType` instead!") = InputCoordinateType;
69 #endif
70  using InputQEType = typename InputMeshType::QEType;
71 
72  OnesMatrixCoefficients() = default;
73 
78  operator()(const InputMeshType * itkNotUsed(iMesh), InputQEType * itkNotUsed(iEdge)) const override
79  {
80  return 1.0;
81  }
82 };
83 
91 template <typename TInputMesh>
92 class ITK_TEMPLATE_EXPORT InverseEuclideanDistanceMatrixCoefficients : public MatrixCoefficients<TInputMesh>
93 {
94 public:
96 
97  using InputMeshType = TInputMesh;
98  using InputCoordinateType = typename InputMeshType::CoordinateType;
99 #ifndef ITK_FUTURE_LEGACY_REMOVE
100  using InputCoordRepType ITK_FUTURE_DEPRECATED(
101  "ITK 6 discourages using `InputCoordRepType`. Please use `InputCoordinateType` instead!") = InputCoordinateType;
102 #endif
104  using InputPointIdentifier = typename InputMeshType::PointIdentifier;
105  using InputQEType = typename InputMeshType::QEType;
107 
109 
116  operator()(const InputMeshType * iMesh, InputQEType * iEdge) const override
117  {
118  const InputPointIdentifier id1 = iEdge->GetOrigin();
119  const InputPointIdentifier id2 = iEdge->GetDestination();
122  const InputPointType pt1 = iMesh->GetPoint(id1);
123  const InputPointType pt2 = iMesh->GetPoint(id2);
124 
125  const InputCoordinateType oValue = 1.0 / pt1.EuclideanDistanceTo(pt2);
126 
127  return oValue;
128  }
129 };
130 
138 template <typename TInputMesh>
139 class ITK_TEMPLATE_EXPORT ConformalMatrixCoefficients : public MatrixCoefficients<TInputMesh>
140 {
141 public:
143 
144  using InputMeshType = TInputMesh;
145  using InputCoordinateType = typename InputMeshType::CoordinateType;
146 #ifndef ITK_FUTURE_LEGACY_REMOVE
147  using InputCoordRepType ITK_FUTURE_DEPRECATED(
148  "ITK 6 discourages using `InputCoordRepType`. Please use `InputCoordinateType` instead!") = InputCoordinateType;
149 #endif
151  using InputPointIdentifier = typename InputMeshType::PointIdentifier;
152  using InputQEType = typename InputMeshType::QEType;
153 
154  ConformalMatrixCoefficients() = default;
155 
162  operator()(const InputMeshType * iMesh, InputQEType * iEdge) const override
163  {
164  const InputPointIdentifier id1 = iEdge->GetOrigin();
165  const InputPointIdentifier id2 = iEdge->GetDestination();
166  const InputPointType pt1 = iMesh->GetPoint(id1);
167  const InputPointType pt2 = iMesh->GetPoint(id2);
170  InputCoordinateType oValue(0.0);
171 
172  if (iEdge->IsLeftSet())
173  {
174  const InputPointIdentifier idA = iEdge->GetLnext()->GetDestination();
175  const InputPointType ptA = iMesh->GetPoint(idA);
176  oValue += TriangleHelper<InputPointType>::Cotangent(pt1, ptA, pt2);
177  }
178  if (iEdge->IsRightSet())
179  {
180  const InputPointIdentifier idB = iEdge->GetRnext()->GetOrigin();
181  const InputPointType ptB = iMesh->GetPoint(idB);
182  oValue += TriangleHelper<InputPointType>::Cotangent(pt1, ptB, pt2);
183  }
184 
185  return std::max(InputCoordinateType{}, oValue);
186  }
187 };
188 
197 template <typename TInputMesh>
198 class ITK_TEMPLATE_EXPORT AuthalicMatrixCoefficients : public MatrixCoefficients<TInputMesh>
199 {
200 public:
202 
203  using InputMeshType = TInputMesh;
204  using InputCoordinateType = typename InputMeshType::CoordinateType;
205 #ifndef ITK_FUTURE_LEGACY_REMOVE
206  using InputCoordRepType ITK_FUTURE_DEPRECATED(
207  "ITK 6 discourages using `InputCoordRepType`. Please use `InputCoordinateType` instead!") = InputCoordinateType;
208 #endif
210  using InputPointIdentifier = typename InputMeshType::PointIdentifier;
211  using InputQEType = typename InputMeshType::QEType;
212 
213  AuthalicMatrixCoefficients() = default;
214 
222  operator()(const InputMeshType * iMesh, InputQEType * iEdge) const override
223  {
224  const InputPointIdentifier id1 = iEdge->GetOrigin();
225  const InputPointType pt1 = iMesh->GetPoint(id1);
228  const InputPointIdentifier id2 = iEdge->GetDestination();
229  const InputPointType pt2 = iMesh->GetPoint(id2);
230 
231  InputCoordinateType oValue{};
232 
233  if (iEdge->IsLeftSet())
234  {
235  const InputPointIdentifier idA = iEdge->GetLnext()->GetDestination();
236  const InputPointType ptA = iMesh->GetPoint(idA);
237  oValue += TriangleHelper<InputPointType>::Cotangent(pt1, pt2, ptA);
238  }
239 
240  if (iEdge->IsRightSet())
241  {
242  const InputPointIdentifier idB = iEdge->GetRnext()->GetOrigin();
243  const InputPointType ptB = iMesh->GetPoint(idB);
244  oValue += TriangleHelper<InputPointType>::Cotangent(pt1, pt2, ptB);
245  }
246 
247  return oValue / pt1.SquaredEuclideanDistanceTo(pt2);
248  }
249 };
250 
258 template <typename TInputMesh>
259 class ITK_TEMPLATE_EXPORT IntrinsicMatrixCoefficients : public MatrixCoefficients<TInputMesh>
260 {
261 public:
263 
264  using InputMeshType = TInputMesh;
265  using InputCoordinateType = typename InputMeshType::CoordinateType;
266 #ifndef ITK_FUTURE_LEGACY_REMOVE
267  using InputCoordRepType ITK_FUTURE_DEPRECATED(
268  "ITK 6 discourages using `InputCoordRepType`. Please use `InputCoordinateType` instead!") = InputCoordinateType;
269 #endif
270  using InputQEType = typename InputMeshType::QEType;
271 
273 
275  : m_Lambda(iLambda)
276  {}
277 
278  InputCoordinateType
279  operator()(const InputMeshType * iMesh, InputQEType * iEdge) const
280  {
283 
284  const InputCoordinateType oValue = m_Lambda * conformal(iMesh, iEdge) + (1.0 - m_Lambda) * authalic(iMesh, iEdge);
285 
286  return oValue;
287  }
288 };
289 
297 template <typename TInputMesh>
298 class ITK_TEMPLATE_EXPORT HarmonicMatrixCoefficients : public MatrixCoefficients<TInputMesh>
299 {
300 public:
302 
303  using InputMeshType = TInputMesh;
304  using InputCoordinateType = typename InputMeshType::CoordinateType;
305 #ifndef ITK_FUTURE_LEGACY_REMOVE
306  using InputCoordRepType ITK_FUTURE_DEPRECATED(
307  "ITK 6 discourages using `InputCoordRepType`. Please use `InputCoordinateType` instead!") = InputCoordinateType;
308 #endif
311  using InputPointIdentifier = typename InputMeshType::PointIdentifier;
312  using InputQEType = typename InputMeshType::QEType;
313 
314  static constexpr unsigned int PointDimension = InputPointType::PointDimension;
315 
316  HarmonicMatrixCoefficients() = default;
317 
319  operator()(const InputMeshType * iMesh, InputQEType * iEdge) const override
320  {
321  const InputPointIdentifier id1 = iEdge->GetOrigin();
322  const InputPointIdentifier id2 = iEdge->GetDestination();
323 
324  const InputPointIdentifier idA = iEdge->GetLnext()->GetDestination();
325  const InputPointIdentifier idB = iEdge->GetRnext()->GetOrigin();
326 
327  const InputPointType pt1 = iMesh->GetPoint(id1);
328  const InputPointType pt2 = iMesh->GetPoint(id2);
329  const InputPointType ptA = iMesh->GetPoint(idA);
330  const InputPointType ptB = iMesh->GetPoint(idB);
331 
332  const InputVectorType v1A = ptA - pt1;
333  const InputVectorType v1B = ptB - pt1;
334  const InputVectorType v12 = pt2 - pt1;
335 
336  const InputCoordinateType L1A = v1A * v1A;
337  const InputCoordinateType L1B = v1B * v1B;
338  const InputCoordinateType L12 = v12 * v12;
339 
340  const InputCoordinateType L2A = pt2.SquaredEuclideanDistanceTo(ptA);
341  const InputCoordinateType L2B = pt2.SquaredEuclideanDistanceTo(ptB);
342 
343  const CrossHelper<InputVectorType> cross;
344 
345  const InputCoordinateType AreaA = 0.5 * (cross(v1A, v12).GetNorm());
346  const InputCoordinateType AreaB = 0.5 * (cross(v1B, v12).GetNorm());
347 
348  const InputCoordinateType oValue = (L1A + L2A - L12) / AreaA + (L1B + L2B - L12) / AreaB;
349 
350  return oValue;
351  }
352 };
353 } // namespace itk
354 #endif
itk::MatrixCoefficients::operator()
virtual InputCoordinateType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const =0
itk::HarmonicMatrixCoefficients::InputPointIdentifier
typename InputMeshType::PointIdentifier InputPointIdentifier
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:311
itk::MatrixCoefficients::InputCoordinateType
typename InputMeshType::CoordinateType InputCoordinateType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:37
itk::InverseEuclideanDistanceMatrixCoefficients::InputVectorType
typename InputMeshType::VectorType InputVectorType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:106
itk::AuthalicMatrixCoefficients
Compute a matrix filled with Authalic Coefficients of the edge, wherever two vertices are connected w...
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:198
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::HarmonicMatrixCoefficients::InputVectorType
typename InputPointType::VectorType InputVectorType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:310
itk::HarmonicMatrixCoefficients
Compute a matrix filled with Harmonic coefficients, wherever two vertices are connected by an edge.
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:298
itk::InverseEuclideanDistanceMatrixCoefficients::InputPointIdentifier
typename InputMeshType::PointIdentifier InputPointIdentifier
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:104
itk::AuthalicMatrixCoefficients::InputPointIdentifier
typename InputMeshType::PointIdentifier InputPointIdentifier
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:210
itk::IntrinsicMatrixCoefficients::IntrinsicMatrixCoefficients
IntrinsicMatrixCoefficients(const InputCoordinateType &iLambda)
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:274
itk::MatrixCoefficients::InputQEType
typename InputMeshType::QEType InputQEType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:42
itk::ConformalMatrixCoefficients::InputPointIdentifier
typename InputMeshType::PointIdentifier InputPointIdentifier
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:151
itk::IntrinsicMatrixCoefficients::m_Lambda
InputCoordinateType m_Lambda
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:272
itk::OnesMatrixCoefficients
Compute a matrix filled by 1s wherever two vertices are connected by an edge.
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:59
itk::AuthalicMatrixCoefficients::operator()
InputCoordinateType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:222
itk::MatrixCoefficients::InputMeshType
TInputMesh InputMeshType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:36
itk::ConformalMatrixCoefficients::InputPointType
typename InputMeshType::PointType InputPointType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:150
itk::ConformalMatrixCoefficients
Compute a matrix filed by Conformal Coefficients of the edge wherever two vertices are connected by a...
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:139
itk::MatrixCoefficients::~MatrixCoefficients
virtual ~MatrixCoefficients()=default
itk::HarmonicMatrixCoefficients::InputPointType
typename InputMeshType::PointType InputPointType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:309
itk::HarmonicMatrixCoefficients::operator()
InputCoordinateType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:319
itk::OnesMatrixCoefficients::operator()
InputCoordinateType operator()(const InputMeshType *, InputQEType *) const override
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:78
itk::InverseEuclideanDistanceMatrixCoefficients
Compute a matrix filed with the inverse of the euclidean distance wherever two vertices are connected...
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:92
itk::InverseEuclideanDistanceMatrixCoefficients::operator()
InputCoordinateType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:116
itk::CrossHelper
Definition: itkCrossHelper.h:36
itkTriangleHelper.h
itk::AuthalicMatrixCoefficients::InputPointType
typename InputMeshType::PointType InputPointType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:209
itk::TriangleHelper::Cotangent
static CoordinateType Cotangent(const PointType &iA, const PointType &iB, const PointType &iC)
Compute cotangent(iA,iB,iC)
itkQuadEdgeMesh.h
itk::InverseEuclideanDistanceMatrixCoefficients::InputPointType
typename InputMeshType::PointType InputPointType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:103
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::MatrixCoefficients
Superclass for all the matrix coefficients computation classes.
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:33
itk::IntrinsicMatrixCoefficients::operator()
InputCoordinateType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:279
itk::MatrixCoefficients::MatrixCoefficients
MatrixCoefficients()=default
itk::IntrinsicMatrixCoefficients
Compute a matrix filled by intrinsic Coefficients of the edge, wherever two vertices are connected by...
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:259
itk::ConformalMatrixCoefficients::operator()
InputCoordinateType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:162
itkMath.h