13#include "cncFormulaEigen.h"
14#include "weightFunc.h"
15#include "weightKernel.h"
29template <
class DataPo
int >
32 typedef typename DataPoint::Scalar Scalar;
33 typedef typename DataPoint::VectorType VectorType;
34 typedef typename DataPoint::MatrixType MatrixType;
36 std::array < VectorType, 3 > m_points;
37 std::array < VectorType, 3 > m_normals;
39 Triangle(DataPoint pointA, DataPoint pointB, DataPoint pointC) {
52 Triangle(
const std::array < VectorType, 3 >& points,
const std::array < VectorType, 3 >& normals) {
62 PONCA_MULTIARCH [[nodiscard]] VectorType&
getPos(
const int index) {
63 return m_points[index];
66 PONCA_MULTIARCH [[nodiscard]]
bool operator==(
const Triangle& other)
const {
67 return (m_points[0] == other.m_points[0])
68 && (m_points[1] == other.m_points[1])
69 && (m_points[2] == other.m_points[2]);
72 PONCA_MULTIARCH [[nodiscard]]
bool operator!=(
const Triangle& other)
const {
73 return !((*this) == other);
76#define DEFINE_CNC_FUNC(CNC_FUNC, RETURN_TYPE) \
77 template<bool differentOrder = false> \
78 inline RETURN_TYPE CNC_FUNC () { \
79 return CNCEigen<DataPoint>::CNC_FUNC( \
80 m_points[0] , m_points[2-differentOrder], m_points[1+differentOrder], \
81 m_normals[0], m_normals[2-differentOrder], m_normals[1+differentOrder] \
85 DEFINE_CNC_FUNC(mu0InterpolatedU , Scalar)
86 DEFINE_CNC_FUNC(mu1InterpolatedU , Scalar)
87 DEFINE_CNC_FUNC(mu2InterpolatedU , Scalar)
88 DEFINE_CNC_FUNC(muXYInterpolatedU, MatrixType)
97 UniformGeneration, HexagramGeneration, IndependentGeneration, AvgHexagramGeneration
109template <
class P, TriangleGenerationMethod _method = UniformGeneration>
114 PROVIDES_PRINCIPAL_CURVATURES
118 using MatrixType =
typename DataPoint::MatrixType;
119 using Scalar =
typename DataPoint::Scalar;
120 using VectorType =
typename DataPoint::VectorType;
121 typedef Eigen::VectorXd DenseVector;
122 typedef Eigen::MatrixXd DenseMatrix;
130 std::vector <internal::Triangle < DataPoint > > m_triangles;
154 PONCA_FITTING_DECLARE_FINALIZE
157 PONCA_MULTIARCH
inline void init() {
173 template <
typename Po
intContainer>
181 template <
typename IndexRange,
typename Po
intContainer>
190 return static_cast<size_t>(m_nb_vt);
193 PONCA_FITTING_APIDOC_SETWFUNC
195 m_nFilter = _nFilter;
203 PONCA_MULTIARCH [[nodiscard]] std::vector< internal::Triangle<DataPoint> >&
getTriangles() {
217 && (m_T11 == other.m_T11) && (m_T12 == other.m_T12) && (m_T13 == other.m_T13)
218 && (m_T22 == other.m_T22) && (m_T23 == other.m_T23)
219 && (m_T33 == other.m_T33);
225 return !(
this == &other);
229 PONCA_MULTIARCH [[nodiscard]]
bool isApprox(
const CNC& other,
const Scalar& epsilon = Eigen::NumTraits<Scalar>::dummy_precision())
const {
230 PONCA_MULTIARCH_STD_MATH(abs);
233 && (std::abs(
kMean() - other.
kMean()) < epsilon)
235 && (std::abs(
kmin() - other.
kmin()) < epsilon)
236 && (std::abs(
kmax() - other.
kmax()) < epsilon);
243 PONCA_MULTIARCH [[nodiscard]]
inline Scalar
kmin()
const {
return m_k1; }
246 PONCA_MULTIARCH [[nodiscard]]
inline Scalar
kmax()
const {
return m_k2; }
249 PONCA_MULTIARCH [[nodiscard]]
inline VectorType
kminDirection()
const {
return m_v1; }
252 PONCA_MULTIARCH [[nodiscard]]
inline VectorType
kmaxDirection()
const {
return m_v2; }
255 PONCA_MULTIARCH [[nodiscard]]
inline Scalar
kMean()
const {
return m_H; }
Corrected Normal Current Fit type.
void setNeighborFilter(const NeighborFilter &_nFilter)
Init the WeightFunc, without changing the other internal states.
void init()
Set the scalar field values to 0 and reset the isNormalized() status.
size_t getNumTriangles() const
Get the number of triangles that were generated with the compute method.
bool operator==(const CNC &other) const
Comparison operator.
bool isApprox(const CNC &other, const Scalar &epsilon=Eigen::NumTraits< Scalar >::dummy_precision()) const
Approximate operator.
Scalar GaussianCurvature() const
Returns an estimate of the Gaussian curvature.
VectorType kmaxDirection() const
Returns an estimate of the maximal principal curvature direction.
FIT_RESULT m_eCurrentState
Represent the current state of the fit (finalize function update the state)
Scalar kmax() const
Returns an estimate of the maximal principal curvature value.
bool operator!=(const CNC &other) const
Comparison operator, convenience function.
bool isStable() const
Is the fitted primitive ready to use (finalize has been called and the result is stable)
Scalar kMean() const
Returns an estimate of the mean curvature.
std::vector< internal::Triangle< DataPoint > > & getTriangles()
Returns the triangles.
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.
VectorType kminDirection() const
Returns an estimate of the minimal principal curvature direction.
Scalar kmin() const
Returns an estimate of the minimal principal curvature value.
This Source Code Form is subject to the terms of the Mozilla Public License, v.
TriangleGenerationMethod
\breif Generation method of the triangles for the Corrected Normal Current formula
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.
ComputeObject is a virtual object that represents an algorithm which can be used with the compute fun...
Stores the three points and normals of the triangles and provides access to Corrected Normal Current ...
VectorType & getPos(const int index)
Get the position of the point at the given index.