#include <iostream>
#include <Ponca/Ponca>
using namespace std;
#define DIMENSION 3
using Scalar = MyPoint::Scalar;
using VectorType = MyPoint::VectorType;
template <typename Fit>
void test_fit(Fit& _fit, Scalar* const _interlacedArray, const int _n, const VectorType& _p)
{
Scalar tmax = 100.0;
_fit.setNeighborFilter({_p, tmax});
for (int i = 0; i != _n; i++)
{
_fit.addNeighbor(MyPoint(_interlacedArray, i));
}
_fit.finalize();
if (_fit.isStable())
{
cout << "Center: [" << _fit.center().transpose() << "] ; radius: " << _fit.radius() << endl;
cout << "Pratt normalization" << (_fit.applyPrattNorm() ? " is now done." : " has already been applied.")
<< endl;
cout << "Value of the scalar field at the initial point: " << _p.transpose() << " is equal to "
<< _fit.potential(_p) << endl;
cout << "It's gradient at this place is equal to: " << _fit.primitiveGradient(_p).transpose() << endl;
cout << "Fitted Sphere: " << endl
<< "\t Tau : " << _fit.tau() << endl
<< "\t Eta : " << _fit.eta().transpose() << endl
<< "\t Kappa: " << _fit.kappa() << endl;
cout << "The initial point " << _p.transpose() << endl
<< "Is projected at " << _fit.project(_p).transpose() << endl;
}
}
Scalar* buildInterlacedArray(const int _n)
{
auto* const interlacedArray = new Scalar[2 * DIMENSION * _n];
for (int k = 0; k < _n; ++k)
{
const Eigen::Matrix<Scalar, DIMENSION, 1> nvec = Eigen::Matrix<Scalar, DIMENSION, 1>::Random().normalized();
const Eigen::Matrix<Scalar, DIMENSION, 1> pvec = nvec * Eigen::internal::random<Scalar>(0.9, 1.1);
memcpy(interlacedArray + 2 * DIMENSION * k, pvec.data(), DIMENSION * sizeof(Scalar));
memcpy(interlacedArray + 2 * DIMENSION * k + DIMENSION, nvec.data(), DIMENSION * sizeof(Scalar));
}
return interlacedArray;
}
int main()
{
constexpr int n = 1000;
Scalar* const interlacedArray = buildInterlacedArray(n);
const VectorType p(interlacedArray);
Fit fit;
test_fit(fit, interlacedArray, n, p);
delete[] interlacedArray;
}
Aggregator class used to declare specialized structures using CRTP.
void init()
Initialize the fit.
Weight neighbors according to the Euclidean distance between a query and a reference position.
Variant of the PointPositionNormal data type that uses external raw data.
This Source Code Form is subject to the terms of the Mozilla Public License, v.