29 template <TriangleGenerationMethod Method,
typename P>
32 using VectorType =
typename P::VectorType;
33 template <
typename IndexRange,
typename Po
intContainer,
typename NeighborFilter>
38 throw std::invalid_argument(
"Triangle generation method not implemented!");
50 static constexpr int maxTriangles{100};
53 using VectorType =
typename P::VectorType;
54 using Scalar =
typename P::Scalar;
56 template <
typename IndexRange,
typename Po
intContainer,
typename NeighborFilter>
61 std::vector<int> indices;
65 if (
w(points[index]).first == Scalar(0.))
67 indices.push_back(index);
73 for (
int i = 0;
i < maxTriangles; ++
i)
76 int i1 = indices[Eigen::internal::random<int>(0,
lastIndex)];
77 int i2 = indices[Eigen::internal::random<int>(0,
lastIndex)];
78 int i3 = indices[Eigen::internal::random<int>(0,
lastIndex)];
96 static constexpr int maxTriangles{100};
99 using VectorType =
typename P::VectorType;
100 using Scalar =
typename P::Scalar;
102 template <
typename IndexRange,
typename Po
intContainer,
typename NeighborFilter>
107 std::vector<int> indices;
108 for (
int index :
ids)
111 if (
w(points[index]).first == Scalar(0.))
113 indices.push_back(index);
119 std::random_device
rd;
120 std::mt19937
rg(
rd());
121 std::shuffle(indices.begin(), indices.end(),
rg);
137 template <
typename P>
140 using Scalar =
typename P::Scalar;
141 static constexpr Scalar avg_normal_coef{Scalar(0.5)};
148 template <
typename P>
151 using VectorType =
typename P::VectorType;
152 using Scalar =
typename P::Scalar;
154 template <
typename IndexRange,
typename Po
intContainer,
typename NeighborFilter>
158 PONCA_MULTIARCH_STD_MATH(
abs);
160 VectorType
c =
w.evalPos();
161 VectorType n =
w.evalNormal();
162 VectorType
a{VectorType::Zero()};
163 Scalar
avg_d = Scalar(0);
167 for (
int index :
ids)
170 if (
w(points[index]).first == Scalar(0.))
172 auto p = points[index];
187 const int m =
abs(n[0]) >
abs(n[1]) ? (
abs(n[0]) >
abs(n[2]) ? 0 : 2) : (
abs(n[1]) >
abs(n[2]) ? 1 : 2);
189 const VectorType
e = (
m == 0) ? VectorType(0, 1, 0) : (
m == 1) ? VectorType(0, 0, 1) : VectorType(1, 0, 0);
191 VectorType
u = n.cross(
e);
192 VectorType
v = n.cross(
u);
197 std::array<VectorType, 6>
normals;
199 std::array<VectorType, 6>
targets;
201 for (
int i = 0;
i < 6;
i++)
210 for (
int index :
ids)
213 if (
w(points[index]).first == Scalar(0.))
216 VectorType
p = points[index].pos();
219 const VectorType
d =
p -
c;
221 for (
int j = 0;
j < 6;
j++)
228 normals[
j] = points[index].normal();
245 template <
typename P>
248 using VectorType =
typename P::VectorType;
249 using Scalar =
typename P::Scalar;
251 template <
typename IndexRange,
typename Po
intContainer,
typename NeighborFilter>
256 VectorType
c =
w.evalPos();
257 VectorType n =
w.evalNormal();
258 VectorType
a = VectorType::Zero();
259 Scalar
avg_d = Scalar(0);
261 std::array<VectorType, 6>
targets;
266 for (
int index :
ids)
268 if (
w(points[index]).first == Scalar(0.))
270 a += points[index].normal();
284 const int m = (std::abs(n[0]) > std::abs(n[1])) ? ((std::abs(n[0])) > std::abs(n[2]) ? 0 : 2)
285 : ((std::abs(n[1])) > std::abs(n[2]) ? 1 : 2);
287 const VectorType
e = (
m == 0) ? VectorType(0, 1, 0) : (
m == 1) ? VectorType(0, 0, 1) : VectorType(1, 0, 0);
288 VectorType
u = n.cross(
e);
289 VectorType
v = n.cross(
u);
297 for (
int i = 0;
i < 6;
i++)
305 for (
int index :
ids)
307 if (
w(points[index]).first == Scalar(0.))
309 VectorType
p = points[index].pos() -
c;
312 for (
int k = 1; k < 6; k++)
326 for (
int i = 0;
i < 6;
i++)
353 template <
class P, TriangleGenerationMethod M>
354 template <
typename Po
intContainer>
362 if (m_eCurrentState !=
STABLE)
363 return m_eCurrentState;
364 m_nb_vt =
int(m_triangles.size());
368 template <
class P, TriangleGenerationMethod M>
369 template <
typename IndexRange,
typename Po
intContainer>
374 if (m_eCurrentState !=
STABLE)
375 return m_eCurrentState;
376 m_nb_vt =
int(m_triangles.size());
380 template <
class P, TriangleGenerationMethod M>
387 MatrixType
localT = MatrixType::Zero();
389 for (
int t = 0;
t < m_nb_vt; ++
t)
392 Scalar
tA = m_triangles[
t].mu0InterpolatedU();
403 m_H += m_triangles[
t].mu1InterpolatedU();
404 m_G += m_triangles[
t].mu2InterpolatedU();
405 localT += m_triangles[
t].muXYInterpolatedU();
419 T << m_T11, m_T12, m_T13, m_T12, m_T22, m_T23, m_T13, m_T23, m_T33;
Aggregator class used to declare specialized structures using CRTP.
typename P::Scalar Scalar
Scalar type used for computation, as defined from template parameter P
FIT_RESULT finalize()
Finalize the procedure.
FIT_RESULT compute(const PointContainer &points)
Compute function for STL-like containers.
FIT_RESULT computeWithIds(const IndexRange &ids, const PointContainer &points)
Compute function that iterates over a subset of sampled points from an STL-Like container.
Copyright (c) 2022 Jacques-Olivier Lachaud (jacques-olivier.lachaud@univ-savoie.fr) Laboratory of Mat...
This Source Code Form is subject to the terms of the Mozilla Public License, v.
FIT_RESULT
Enum corresponding to the state of a fitting method (and what the finalize function returns)
@ UNDEFINED
The fitting is undefined, you can't use it for valid results.
@ STABLE
The fitting is stable and ready to use.
This class contains some stand-alone CorrectedNormalCurrent formulas for triangles,...
static std::tuple< Scalar, Scalar, VectorType, VectorType > curvaturesFromTensor(const MatrixType &tensor, const Scalar area, const VectorType &N)
Computing principal curvatures k1 and k2 from tensor.
Stores the three points and normals of the triangles and provides access to Corrected Normal Current ...