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
25namespace itk
26{
32template <typename TInputMesh>
34{
35public:
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
48 operator()(const InputMeshType * iMesh, InputQEType * iEdge) const = 0;
49};
50
58template <typename TInputMesh>
59class ITK_TEMPLATE_EXPORT OnesMatrixCoefficients : public MatrixCoefficients<TInputMesh>
60{
61public:
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
73
78 operator()(const InputMeshType * itkNotUsed(iMesh), InputQEType * itkNotUsed(iEdge)) const override
79 {
80 return 1.0;
81 }
82};
83
91template <typename TInputMesh>
92class ITK_TEMPLATE_EXPORT InverseEuclideanDistanceMatrixCoefficients : public MatrixCoefficients<TInputMesh>
93{
94public:
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
138template <typename TInputMesh>
139class ITK_TEMPLATE_EXPORT ConformalMatrixCoefficients : public MatrixCoefficients<TInputMesh>
140{
141public:
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
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
197template <typename TInputMesh>
198class ITK_TEMPLATE_EXPORT AuthalicMatrixCoefficients : public MatrixCoefficients<TInputMesh>
199{
200public:
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
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
258template <typename TInputMesh>
259class ITK_TEMPLATE_EXPORT IntrinsicMatrixCoefficients : public MatrixCoefficients<TInputMesh>
260{
261public:
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 override
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
297template <typename TInputMesh>
298class ITK_TEMPLATE_EXPORT HarmonicMatrixCoefficients : public MatrixCoefficients<TInputMesh>
299{
300public:
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
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
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
Compute a matrix filled with Authalic Coefficients of the edge, wherever two vertices are connected w...
typename InputMeshType::PointIdentifier InputPointIdentifier
InputCoordinateType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
Compute a matrix filed by Conformal Coefficients of the edge wherever two vertices are connected by a...
InputCoordinateType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
typename InputMeshType::PointIdentifier InputPointIdentifier
Compute a matrix filled with Harmonic coefficients, wherever two vertices are connected by an edge.
typename InputMeshType::PointIdentifier InputPointIdentifier
InputCoordinateType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
typename InputPointType::VectorType InputVectorType
Compute a matrix filled by intrinsic Coefficients of the edge, wherever two vertices are connected by...
IntrinsicMatrixCoefficients(const InputCoordinateType &iLambda)
InputCoordinateType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
Compute a matrix filed with the inverse of the euclidean distance wherever two vertices are connected...
InputCoordinateType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
Superclass for all the matrix coefficients computation classes.
typename InputMeshType::CoordinateType InputCoordinateType
typename InputMeshType::QEType InputQEType
virtual ~MatrixCoefficients()=default
virtual InputCoordinateType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const =0
Compute a matrix filled by 1s wherever two vertices are connected by an edge.
InputCoordinateType operator()(const InputMeshType *, InputQEType *) const override
static CoordinateType Cotangent(const PointType &iA, const PointType &iB, const PointType &iC)
Compute cotangent(iA,iB,iC)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....