#include <cmath>
#include <algorithm>
#include <iostream>
#include <Ponca/src/Fitting/basket.h>
#include <Ponca/src/Fitting/gls.h>
#include <Ponca/src/Fitting/orientedSphereFit.h>
#include <Ponca/src/Fitting/unorientedSphereFit.h>
#include <Ponca/src/Fitting/sphereFit.h>
#include <Ponca/src/Fitting/weightFunc.h>
#include <Ponca/src/Fitting/weightKernel.h>
#include <Ponca/src/Fitting/curvature.h>
#include <Ponca/src/Fitting/weingarten.h>
#include <Ponca/SpatialPartitioning>
#include <Ponca/src/Common/pointTypes.h>
#include <Ponca/src/Common/pointGeneration.h>
#include <vector>
using namespace std;
typedef MyPoint::Scalar Scalar;
typedef MyPoint::VectorType VectorType;
template<typename Fit>
void test_fit(Fit& _fit,
const KdTree<MyPoint>& tree,
const VectorType& _p)
{
Scalar tmax = 100.0;
_fit.setNeighborFilter({_p, tmax});
_fit.init();
for(int i : tree.rangeNeighbors(_p, tmax) )
{
}
_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();
int n = 10000;
vector<MyPoint> vecs (n);
std::generate(vecs.begin(), vecs.end(), getRandomPoint<MyPoint>);
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.
bool addNeighbor(const DataPoint &_nei)
Add a neighbor to perform the fit.
Weight neighbors according to the euclidean distance between a query and a reference position.
Point data type containing the position and normal vectors.
PointContainer & points()
Get the internal point container.
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Public interface for dense KdTree datastructure.
Abstract KdTree type with KdTreeDefaultTraits.