diff --git a/README.md b/README.md index 81136fd..2b17aef 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,28 @@ 2d plot application displaying scalar fields reconstructed using [Ponca](https://poncateam.github.io/ponca/) +## Test different types of fits +image +image + + + +## Test different scales + +image +image +image + +## Change display options + +image +image + + +## Video + +(old version) https://github.com/poncateam/poncaplot/assets/6310221/a1885def-4135-4afa-b833-f2968697586f diff --git a/external/ponca b/external/ponca index 32bffeb..14b4da0 160000 --- a/external/ponca +++ b/external/ponca @@ -1 +1 @@ -Subproject commit 32bffeb82b55c56f82ce9b72b725f91e14d1c66d +Subproject commit 14b4da059d71dd3dc7e1695d75c7005d1f718cb6 diff --git a/src/dataManager.cpp b/src/dataManager.cpp index ad2a9f0..ecec428 100644 --- a/src/dataManager.cpp +++ b/src/dataManager.cpp @@ -13,7 +13,7 @@ DataManager::savePointCloud(const std::string& path) const{ if( ! file.is_open() ) return false; file << "# x y nx ny " << "\n"; - for( const auto & p : m_tree.point_data() ){ + for( const auto & p : m_tree.points() ){ file << p.pos().transpose() << " " << p.normal().transpose() << "\n"; } file.close(); @@ -80,7 +80,7 @@ DataManager::computeNormals(int k){ // Set the evaluation position fit.init(p); // Fit plane (method compute handles multipass fitting - if (fit.computeWithIds(m_tree.k_nearest_neighbors(p, k), m_tree.point_data()) == Ponca::STABLE) { + if (fit.computeWithIds(m_tree.k_nearest_neighbors(p, k), m_tree.points()) == Ponca::STABLE) { pp.z() = std::acos(fit.primitiveGradient().normalized().x()); } else std::cerr << "Something weird happened here..." << std::endl; @@ -92,7 +92,7 @@ void DataManager::fitPointCloudToRange(const std::pair& rangesEnd, const std::pair& rangesStart){ if (m_points.empty()) return; if (m_tree.node_count() == 0) updateKdTree(); - auto aabb = m_tree.node_data()[0].getAabb(); + auto aabb = m_tree.nodes()[0].getAabb(); if (aabb){ VectorType requestedSize {rangesEnd.first - rangesStart.first, rangesEnd.second - rangesStart.second}; VectorType scaleFactors = requestedSize.array() / aabb->diagonal().array(); diff --git a/src/dataManager.h b/src/dataManager.h index 78221b9..7a8e80a 100644 --- a/src/dataManager.h +++ b/src/dataManager.h @@ -57,7 +57,7 @@ struct MyKdTreeNode : Ponca::KdTreeCustomizableNode; - using KdTree = Ponca::KdTreeBase>; + using KdTree = Ponca::KdTreeDenseBase>; using PointContainer = std::vector; // stores x,y,normal angle in radians using VectorType = typename KdTree::VectorType; diff --git a/src/drawingPass.h b/src/drawingPass.h index 2000cd5..2366043 100644 --- a/src/drawingPass.h +++ b/src/drawingPass.h @@ -54,7 +54,7 @@ struct DisplayPoint : public DrawingPass { const auto pLargeSize = 2.f*m_halfSize; #pragma omp parallel for default(none) shared(points, buffer, w, h,pLargeSize) for (int pid = 0; pid< points.point_count(); ++pid){ - const auto& p = points.point_data()[pid]; + const auto& p = points.points()[pid]; // Build vector that is orthogonal to the normal vector const VectorType& tangent {p.normal().y(), -p.normal().x()}; int i (std::floor(p.pos().x())); diff --git a/src/drawingPasses/distanceField.h b/src/drawingPasses/distanceField.h index d24b8b6..f4f25f3 100644 --- a/src/drawingPasses/distanceField.h +++ b/src/drawingPasses/distanceField.h @@ -5,7 +5,7 @@ struct DistanceField : public DrawingPass { inline explicit DistanceField() : DrawingPass() {} void render(const DataManager::KdTree& points, float*buffer, int w, int h) override { - if(points.point_data().empty()) + if(points.points().empty()) { buffer[1] = ColorMap::NO_FIELD; return; @@ -17,7 +17,7 @@ struct DistanceField : public DrawingPass { for (int i = 0; i < w; ++i) { auto *b = buffer + (i + j * w) * 4; float minDist {float(w*h)}; //distance should necessarily be smaller - for (const auto &p : points.point_data()) { + for (const auto &p : points.points()) { int u(std::floor(p.pos().x())); int v(std::floor(p.pos().y())); auto dist = float(std::sqrt((i-u)*(i-u) + (j-v)*(j-v))); @@ -35,7 +35,7 @@ struct DistanceField : public DrawingPass { struct DistanceFieldWithKdTree : public DrawingPass { inline explicit DistanceFieldWithKdTree() : DrawingPass() {} void render(const DataManager::KdTree& points, float*buffer, int w, int h) override{ - if(points.point_data().empty()) + if(points.points().empty()) { buffer[1] = ColorMap::NO_FIELD; return; @@ -49,7 +49,7 @@ struct DistanceFieldWithKdTree : public DrawingPass { DataPoint::VectorType query (i, j); auto res = points.nearest_neighbor( query ); if(res.begin()!=res.end()) { - auto nei = points.point_data()[res.get()].pos(); + auto nei = points.points()[res.get()].pos(); float dist = (nei-query).norm(); b[0] = dist; b[2] = ColorMap::VALUE_IS_VALID; diff --git a/src/drawingPasses/poncaFitField.h b/src/drawingPasses/poncaFitField.h index 8fa3471..777d167 100644 --- a/src/drawingPasses/poncaFitField.h +++ b/src/drawingPasses/poncaFitField.h @@ -22,7 +22,7 @@ struct FitField : public BaseFitField { virtual void postProcess(FitType& /*fit*/){}; void render(const DataManager::KdTree& points, float*buffer, int w, int h) override{ - if(points.point_data().empty()) return; + if(points.points().empty()) return; float maxVal = 0; #pragma omp parallel for collapse(2) default(none) shared(points, buffer, w, h) reduction(max : maxVal) @@ -38,7 +38,7 @@ struct FitField : public BaseFitField { for (int iter = 0; iter != m_iter; ++iter) { fit.init(query); // Fit plane (method compute handles multipass fitting - if (fit.computeWithIds(points.range_neighbors(query, m_scale), points.point_data()) == + if (fit.computeWithIds(points.range_neighbors(query, m_scale), points.points()) == Ponca::STABLE) { query = fit.project(query); } @@ -49,8 +49,8 @@ struct FitField : public BaseFitField { float dist = fit.potential({i,j}); if (std::abs(dist)> maxVal) maxVal = std::abs(dist); - b[0] = dist; // set pixel value - b[3] = ColorMap::SCALAR_FIELD; // set field type + b[0] = fit.isSigned() ? dist : std::abs(dist); // set pixel value + b[3] = ColorMap::SCALAR_FIELD; // set field type } } }