ITK  5.2.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  * 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
44  operator()(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 
70  operator()(const InputMeshType * itkNotUsed(iMesh), InputQEType * itkNotUsed(iEdge)) const override
71  {
72  return 1.0;
73  }
74 };
75 
83 template <typename TInputMesh>
85 {
86 public:
88 
89  using InputMeshType = TInputMesh;
90  using InputCoordRepType = typename InputMeshType::CoordRepType;
92  using InputPointIdentifier = typename InputMeshType::PointIdentifier;
93  using InputQEType = typename InputMeshType::QEType;
95 
97 
104  operator()(const InputMeshType * iMesh, InputQEType * iEdge) const override
105  {
106  InputPointIdentifier id1 = iEdge->GetOrigin();
107  InputPointIdentifier id2 = iEdge->GetDestination();
109 
110  InputPointType pt1 = iMesh->GetPoint(id1);
111  InputPointType pt2 = iMesh->GetPoint(id2);
112 
113  InputCoordRepType oValue = 1.0 / pt1.EuclideanDistanceTo(pt2);
114 
115  return oValue;
116  }
117 };
118 
126 template <typename TInputMesh>
128 {
129 public:
131 
132  using InputMeshType = TInputMesh;
133  using InputCoordRepType = typename InputMeshType::CoordRepType;
135  using InputPointIdentifier = typename InputMeshType::PointIdentifier;
136  using InputQEType = typename InputMeshType::QEType;
137 
138  ConformalMatrixCoefficients() = default;
139 
146  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 
202  operator()(const InputMeshType * iMesh, InputQEType * iEdge) const override
203  {
204  InputPointIdentifier id1 = iEdge->GetOrigin();
205  InputPointType pt1 = iMesh->GetPoint(id1);
207 
208  InputPointIdentifier id2 = iEdge->GetDestination();
209  InputPointType pt2 = iMesh->GetPoint(id2);
210 
212 
213  if (iEdge->IsLeftSet())
214  {
215  InputPointIdentifier idA = iEdge->GetLnext()->GetDestination();
216  InputPointType ptA = iMesh->GetPoint(idA);
217  oValue += TriangleHelper<InputPointType>::Cotangent(pt1, pt2, ptA);
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  operator()(const InputMeshType * iMesh, InputQEType * iEdge) const
256  {
259 
260  InputCoordRepType oValue = m_Lambda * conformal(iMesh, iEdge) + (1.0 - m_Lambda) * authalic(iMesh, iEdge);
261 
262  return oValue;
263  }
264 };
265 
273 template <typename TInputMesh>
275 {
276 public:
278 
279  using InputMeshType = TInputMesh;
280  using InputCoordRepType = typename InputMeshType::CoordRepType;
283  using InputPointIdentifier = typename InputMeshType::PointIdentifier;
284  using InputQEType = typename InputMeshType::QEType;
285 
286  static constexpr unsigned int PointDimension = InputPointType::PointDimension;
287 
288  HarmonicMatrixCoefficients() = default;
289 
291  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 
320  InputCoordRepType oValue = (L1A + L2A - L12) / AreaA + (L1B + L2B - L12) / AreaB;
321 
322  return oValue;
323  }
324 };
325 } // namespace itk
326 #endif
itk::OnesMatrixCoefficients::OnesMatrixCoefficients
OnesMatrixCoefficients()=default
itk::HarmonicMatrixCoefficients::InputPointIdentifier
typename InputMeshType::PointIdentifier InputPointIdentifier
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:283
itk::AuthalicMatrixCoefficients::AuthalicMatrixCoefficients
AuthalicMatrixCoefficients()=default
itk::InverseEuclideanDistanceMatrixCoefficients::InputVectorType
typename InputMeshType::VectorType InputVectorType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:94
itk::AuthalicMatrixCoefficients
Compute a matrix filled with Authalic Coefiicients of the edge, wherever two vertices are connected w...
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:182
itk::MatrixCoefficients::operator()
virtual InputCoordRepType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const =0
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::OnesMatrixCoefficients::operator()
InputCoordRepType operator()(const InputMeshType *, InputQEType *) const override
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:70
itk::IntrinsicMatrixCoefficients::operator()
InputCoordRepType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:255
itk::HarmonicMatrixCoefficients::InputVectorType
typename InputPointType::VectorType InputVectorType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:282
itk::HarmonicMatrixCoefficients
Compute a matrix filled with Harmonic coefficients, wherever two vertices are connected by an edge.
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:274
itk::InverseEuclideanDistanceMatrixCoefficients::InputPointIdentifier
typename InputMeshType::PointIdentifier InputPointIdentifier
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:92
itk::AuthalicMatrixCoefficients::InputPointIdentifier
typename InputMeshType::PointIdentifier InputPointIdentifier
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:190
itk::HarmonicMatrixCoefficients::operator()
InputCoordRepType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:291
itk::MatrixCoefficients::InputQEType
typename InputMeshType::QEType InputQEType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:38
itk::ConformalMatrixCoefficients::InputPointIdentifier
typename InputMeshType::PointIdentifier InputPointIdentifier
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:135
itk::TriangleHelper::Cotangent
static CoordRepType Cotangent(const PointType &iA, const PointType &iB, const PointType &iC)
Compute cotangent(iA,iB,iC)
itk::OnesMatrixCoefficients
Compute a matrix filled by 1s wherever two vertices are connected by an edge.
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:55
itk::IntrinsicMatrixCoefficients::m_Lambda
InputCoordRepType m_Lambda
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:248
itk::MatrixCoefficients::InputMeshType
TInputMesh InputMeshType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:36
itk::ConformalMatrixCoefficients::InputPointType
typename InputMeshType::PointType InputPointType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:134
itk::ConformalMatrixCoefficients
Compute a matrix filed by Conformal Coefficients of the edge wherever two vertices are connected by a...
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:127
itk::MatrixCoefficients::~MatrixCoefficients
virtual ~MatrixCoefficients()=default
itk::HarmonicMatrixCoefficients::InputPointType
typename InputMeshType::PointType InputPointType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:281
itk::ConformalMatrixCoefficients::operator()
InputCoordRepType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:146
itk::InverseEuclideanDistanceMatrixCoefficients
Compute a matrix filed with the inverse of the euclidian distance wherever two vertices are connected...
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:84
itk::MatrixCoefficients::InputCoordRepType
typename InputMeshType::CoordRepType InputCoordRepType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:37
itk::CrossHelper
Definition: itkCrossHelper.h:36
itk::HarmonicMatrixCoefficients::PointDimension
static constexpr unsigned int PointDimension
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:286
itkTriangleHelper.h
itk::AuthalicMatrixCoefficients::InputPointType
typename InputMeshType::PointType InputPointType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:189
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
itkQuadEdgeMesh.h
itk::NumericTraits::ZeroValue
static T ZeroValue()
Definition: itkNumericTraits.h:148
itk::InverseEuclideanDistanceMatrixCoefficients::InputPointType
typename InputMeshType::PointType InputPointType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:91
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::IntrinsicMatrixCoefficients::IntrinsicMatrixCoefficients
IntrinsicMatrixCoefficients(const InputCoordRepType &iLambda)
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:250
itk::MatrixCoefficients
Superclass for all the matrix coefficients computation classes.
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:33
itk::InverseEuclideanDistanceMatrixCoefficients::InverseEuclideanDistanceMatrixCoefficients
InverseEuclideanDistanceMatrixCoefficients()=default
itk::HarmonicMatrixCoefficients::HarmonicMatrixCoefficients
HarmonicMatrixCoefficients()=default
itk::MatrixCoefficients::MatrixCoefficients
MatrixCoefficients()=default
itk::IntrinsicMatrixCoefficients
Compute a mtrix filled by intrinsic Coefficients of the edge, wherever two vertices are connected by ...
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:239
itk::IntrinsicMatrixCoefficients::InputCoordRepType
typename InputMeshType::CoordRepType InputCoordRepType
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:245
itk::ConformalMatrixCoefficients::ConformalMatrixCoefficients
ConformalMatrixCoefficients()=default
itk::InverseEuclideanDistanceMatrixCoefficients::operator()
InputCoordRepType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:104
itkMath.h
itk::AuthalicMatrixCoefficients::operator()
InputCoordRepType operator()(const InputMeshType *iMesh, InputQEType *iEdge) const override
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:202