Ponca  7d8ac87a7de01d881c9fde3c42e397b44bffb901
Point Cloud Analysis library
Loading...
Searching...
No Matches
Ponca basic CPU

This is an example of how to use Ponca to compute the GLS Geometric variation on random data.

/*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#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;
using namespace Ponca;
using Scalar = MyPoint::Scalar;
using VectorType = MyPoint::VectorType;
// Define related structure
template <typename Fit>
void test_fit(Fit& _fit, const KdTree<MyPoint>& tree, const VectorType& _p)
{
constexpr Scalar tmax = Scalar(100.0);
// Set a weighting function instance
_fit.setNeighborFilter({_p, tmax});
_fit.init();
// Iterate over samples and _fit the primitive
for (const int i : tree.rangeNeighbors(_p, tmax))
{
_fit.addNeighbor(tree.points()[i]);
}
// finalize fitting
_fit.finalize();
// Test if the fitting ended without errors
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;
// Play with fitting output
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()
{
// set evaluation point and scale
VectorType p = VectorType::Random();
// init input data
constexpr int n = 10000;
std::generate(vecs.begin(), vecs.end(), getRandomPoint<MyPoint>);
p = vecs.at(0).pos();
std::cout << "====================\nOrientedSphereFit:\n";
std::cout << "\n\n====================\nUnorientedSphereFit:\n";
std::cout << "\n\n====================\nUnorientedSphereFit:\n";
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";
return 0;
}
Aggregator class used to declare specialized structures with derivatives computations,...
Definition basket.h:276
Aggregator class used to declare specialized structures using CRTP.
Definition basket.h:318
bool addNeighbor(const DataPoint &_nei)
Add a neighbor to perform the fit.
Definition basket.h:341
Make CurvatureEstimatorBase available to BasketDiff object.
Definition curvature.h:98
Differentiation of GLSParam.
Definition gls.h:122
Compute a Weingarten map from the spatial derivatives of the normal field .
Definition weingarten.h:109
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Compute principal curvatures from a base class providing fundamental forms.
Definition weingarten.h:202