diff --git a/src/dataManager.cpp b/src/dataManager.cpp index 1fc23c4..8f74bf1 100644 --- a/src/dataManager.cpp +++ b/src/dataManager.cpp @@ -77,17 +77,16 @@ DataManager::loadPointCloud(const std::string& path){ void DataManager::computeNormals(int k){ - using WeightFunc = Ponca::DistWeightFunc >; - using PlaneFit = Ponca::Basket; + using NeighborFilter = Ponca::DistWeightFunc >; + using PlaneFit = Ponca::Basket; std::cout << "Recompute normals" << std::endl; for (auto& pp : m_points){ VectorType p {pp.x(),pp.y()}; PlaneFit fit; - fit.setWeightFunc(WeightFunc()); // Set the evaluation position - fit.init(p); + fit.setNeighborFilter(NeighborFilter(p)); // Fit plane (method compute handles multipass fitting if (fit.computeWithIds(m_tree.k_nearest_neighbors(p, k), m_tree.points()) == Ponca::STABLE) { pp.z() = std::acos(fit.primitiveGradient().normalized().x()); diff --git a/src/drawingPasses/bestFieldFit.h b/src/drawingPasses/bestFieldFit.h index a829020..172dd2b 100644 --- a/src/drawingPasses/bestFieldFit.h +++ b/src/drawingPasses/bestFieldFit.h @@ -10,7 +10,7 @@ struct SingleFitField : public _Base { using Base = _Base; using FitType = _FitType; - using WeightFunc = typename FitType::WeightFunction; + using NeighborFilter = typename FitType::NeighborFilter; virtual float configureAndFit(const KdTree& points, FitType& fit, RenderingContext ctx) = 0; @@ -71,7 +71,7 @@ struct BestFitField : public SingleFitField<_FitType, DrawingPass> { ~BestFitField() override = default; using FitType = _FitType; - using WeightFunc = typename FitType::WeightFunction; + using NeighborFilter = typename FitType::NeighborFilter; /// Method called at the end of the fitting process, only for stable fits virtual void postProcess(FitType& /*fit*/){}; @@ -79,8 +79,7 @@ struct BestFitField : public SingleFitField<_FitType, DrawingPass> { inline float configureAndFit(const KdTree& points, FitType& fit, RenderingContext ctx) override { // Configure computation to be centered on the point cloud coordinates float scale = points.nodes()[0].getAabb()->diagonal().norm(); - fit.setWeightFunc(WeightFunc(scale)); - fit.init(points.nodes()[0].getAabb()->center()); + fit.setNeighborFilter(NeighborFilter(points.nodes()[0].getAabb()->center(), scale)); // Compute fit fit.compute(points.points()); postProcess(fit); @@ -106,19 +105,18 @@ struct OnePointFitField : public SingleFitField<_FitType, BaseFitField>, public ~OnePointFitField() override = default; using FitType = _FitType; - using WeightFunc = typename FitType::WeightFunction; + using NeighborFilter = typename FitType::NeighborFilter; using Scalar = typename FitType::Scalar; /// Method called at the end of the fitting process, only for stable fits virtual void postProcess(FitType& /*fit*/){}; inline float configureAndFit(const KdTree& points, FitType& fit, RenderingContext ctx) override { - // Configure computation to be centered on the point cloud coordinates - fit.setWeightFunc(WeightFunc(BaseFitField::params.m_scale)); auto query = points.points()[pointId].pos(); // Compute fit for (int iter = 0; iter != BaseFitField::params.m_iter; ++iter) { - fit.init(query); + // Configure computation to be centered on the point cloud coordinates + fit.setNeighborFilter(NeighborFilter(query, BaseFitField::params.m_scale)); if (fit.computeWithIds(points.range_neighbors(query, BaseFitField::params.m_scale), points.points()) == Ponca::STABLE) { postProcess(fit); diff --git a/src/drawingPasses/poncaFitField.h b/src/drawingPasses/poncaFitField.h index 78b51ec..e78e294 100644 --- a/src/drawingPasses/poncaFitField.h +++ b/src/drawingPasses/poncaFitField.h @@ -10,7 +10,7 @@ struct FitField : public BaseFitField { ~FitField() override = default; using FitType = _FitType; - using WeightFunc = typename FitType::WeightFunction; + using NeighborFilter = typename FitType::NeighborFilter; /// Method called at the end of the fitting process, only for stable fits virtual void postProcess(FitType& /*fit*/){}; @@ -36,11 +36,10 @@ struct FitField : public BaseFitField { DataPoint::VectorType query (coord.first, coord.second); FitType fit; - // Set a weighting function instance - fit.setWeightFunc(WeightFunc(params.m_scale)); // Set the evaluation position for (int iter = 0; iter != params.m_iter; ++iter) { - fit.init(query); + // Set a weighting function instance + fit.setNeighborFilter(NeighborFilter(query, params.m_scale)); // Fit plane (method compute handles multipass fitting if (fit.computeWithIds(points.range_neighbors(query, params.m_scale), points.points()) == Ponca::STABLE) { @@ -81,15 +80,13 @@ struct FitField : public BaseFitField { float potential {0.f}; do { FitType fit; - // Set a weighting function instance - fit.setWeightFunc(WeightFunc(params.m_scale)); // Set the evaluation position for (int iter = 0; iter != params.m_iter; ++iter) { x = nextx; - // project to next location and draw - fit.init(x); + // Set a weighting function instance + fit.setNeighborFilter(NeighborFilter(x, params.m_scale)); if (fit.computeWithIds(points.range_neighbors(x, params.m_scale), points.points()) == Ponca::STABLE) { postProcess(fit); @@ -97,7 +94,7 @@ struct FitField : public BaseFitField { potential = fit.potential(nextx); // ask to stop the projection procedure if motion is below one pixel - int nbPix = bresenham(ctx.pointToPix( x ) , ctx.pointToPix( nextx ), + int nbPix = bresenham(ctx.pointToPix( x ), ctx.pointToPix( nextx ), {ctx.w, ctx.h}, [buffer, ctx](int x, int y){ auto *b = buffer + (x + y * ctx.w) * 4; diff --git a/src/poncaTypes.h b/src/poncaTypes.h index 118fc2c..39ad06a 100644 --- a/src/poncaTypes.h +++ b/src/poncaTypes.h @@ -20,16 +20,16 @@ class DataPoint VectorType m_pos, m_normal; }; -using WeightFunc = Ponca::DistWeightFunc >; -using ConstWeightFunc = Ponca::DistWeightFunc >; +using WeightFunc = Ponca::DistWeightFunc >; +using ConstWeightFunc = Ponca::DistWeightFunc >; -using PlaneFit = Ponca::Basket; -using ConstPlaneFit = Ponca::Basket; -using SphereFit = Ponca::Basket; -using ConstSphereFit = Ponca::Basket; -using OrientedSphereFit= Ponca::Basket; -using ConstOrientedSphereFit= Ponca::Basket; -using UnorientedSphereFit = Ponca::Basket; +using PlaneFit = Ponca::Basket; +using ConstPlaneFit = Ponca::Basket; +using SphereFit = Ponca::Basket; +using ConstSphereFit = Ponca::Basket; +using OrientedSphereFit= Ponca::Basket; +using ConstOrientedSphereFit= Ponca::Basket; +using UnorientedSphereFit = Ponca::Basket;