#include <algorithm>
#include <iostream>
#include <vector>
#include <Ponca/Ponca>
using namespace std;
using Scalar = MyPoint::Scalar;
using VectorType = MyPoint::VectorType;
template <typename Fit>
void test_fit(Fit& _fit,
const KdTree<MyPoint>& tree,
const VectorType& _p)
{
constexpr Scalar tmax = Scalar(100.0);
_fit.setNeighborFilter({_p, tmax});
_fit.init();
{
_fit.addNeighbor(tree.
points()[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;
}
}
int main()
{
VectorType p = VectorType::Random();
constexpr int n = 10000;
vector<MyPoint> vecs(n);
p = vecs.at(0).pos();
std::cout << "====================\nOrientedSphereFit:\n";
Fit1 fit1;
test_fit(fit1, tree, p);
std::cout << "\n\n====================\nUnorientedSphereFit:\n";
Fit2 fit2;
test_fit(fit2, tree, p);
std::cout << "\n\n====================\nUnorientedSphereFit:\n";
Fit3 fit3;
test_fit(fit3, tree, p);
if (fit3.isStable())
{
cout << "eigen values: " << endl;
cout << fit3.kmin() << endl;
cout << fit3.kmax() << endl;
cout << "eigen vectors: " << endl;
cout << fit3.kminDirection() << endl << endl;
cout << fit3.kmaxDirection() << endl;
}
std::cout << "\n\n====================\nSphereFit:\n";
Fit4 fit4;
test_fit(fit4, tree, p);
return 0;
}
Aggregator class used to declare specialized structures with derivatives computations,...
Aggregator class used to declare specialized structures using CRTP.
Weight neighbors according to the Euclidean distance between a query and a reference position.
Differentiation of GLSParam.
Compute a Weingarten map from the spatial derivatives of the normal field .
Point data type containing the position and normal vectors.
KdTreeRangePointQuery< Traits > rangeNeighbors(const VectorType &point, Scalar r) const
Computes a Query object to iterate over the neighbors that are inside a given radius....
PointContainer & points()
Get the internal point container.
This Source Code Form is subject to the terms of the Mozilla Public License, v.
DataPoint getRandomPoint()
Generate a random points.
@ FitSpaceDer
Flag indicating a space differentiation.
OrientedSphereDerImpl< DataPoint, _NFilter, DiffType, MeanPositionDer< DataPoint, _NFilter, DiffType, T > > OrientedSphereDer
Helper alias for Oriented Sphere fitting on 3D points using OrientedSphereDerImpl.
Public interface for dense KdTree datastructure.
Abstract KdTree type with KdTreeDefaultTraits.
Compute principal curvatures from a base class providing fundamental forms.