From 71d9708c331cf102489693b77ac379858efb81b5 Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Wed, 7 Jan 2015 18:57:20 +0000 Subject: [PATCH] precision auto --- src/HYDROData/HYDROData_Bathymetry.cxx | 15 +++++++++++++-- src/HYDROData/HYDROData_QuadtreeNode.cxx | 7 +++---- src/HYDROData/HYDROData_QuadtreeNode.hxx | 6 ++++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index 202ffe33..623f2eef 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -246,12 +246,23 @@ double HYDROData_Bathymetry::GetAltitudeForPoint(const gp_XY& thePoint) const } std::map dist2nodes; - aQuadtree->NodesAround(thePoint, dist2nodes, 1.0); + aQuadtree->NodesAround(thePoint, dist2nodes, aQuadtree->getPrecision()); + while (dist2nodes.size() == 0) + { + aQuadtree->setPrecision(aQuadtree->getPrecision() *2); + DEBTRACE("adjust precision to: " << aQuadtree->getPrecision()); + aQuadtree->NodesAround(thePoint, dist2nodes, aQuadtree->getPrecision()); + } + aQuadtree->NodesAround(thePoint, dist2nodes, 5.0); if (dist2nodes.size()) { std::map::const_iterator it = dist2nodes.begin(); aResAltitude = it->second->Z(); - //DEBTRACE(" number of points found: " << dist2nodes.size() << " nearest z: " << aResAltitude); + DEBTRACE(" number of points found: " << dist2nodes.size() << " nearest z: " << aResAltitude); + } + else + { + DEBTRACE(" number of points found: 0"); } return aResAltitude; diff --git a/src/HYDROData/HYDROData_QuadtreeNode.cxx b/src/HYDROData/HYDROData_QuadtreeNode.cxx index 64d3ecb0..ba940dad 100644 --- a/src/HYDROData/HYDROData_QuadtreeNode.cxx +++ b/src/HYDROData/HYDROData_QuadtreeNode.cxx @@ -47,7 +47,7 @@ HYDROData_QuadtreeNode::HYDROData_QuadtreeNode(Nodes_3D* theNodes, const int maxLevel, const int maxNbNodes, const double minBoxSize) : - HYDROData_Quadtree(new Limit(maxLevel, minBoxSize, maxNbNodes)), myNodes(theNodes) + HYDROData_Quadtree(new Limit(maxLevel, minBoxSize, maxNbNodes)), myNodes(theNodes), myPrecision(0.25) { DEBTRACE("---------------------------- HYDROData_QuadtreeNode root constructor"); if (myNodes) @@ -62,10 +62,9 @@ HYDROData_QuadtreeNode::HYDROData_QuadtreeNode(Nodes_3D* theNodes, * \brief Constructor used to allocate a child */ HYDROData_QuadtreeNode::HYDROData_QuadtreeNode() : - HYDROData_Quadtree() + HYDROData_Quadtree(), myNodes(0), myPrecision(0.25) { - if (myNodes == 0) - myNodes = new Nodes_3D(); + myNodes = new Nodes_3D(); } /*! diff --git a/src/HYDROData/HYDROData_QuadtreeNode.hxx b/src/HYDROData/HYDROData_QuadtreeNode.hxx index 9dfe0a07..78497ffa 100644 --- a/src/HYDROData/HYDROData_QuadtreeNode.hxx +++ b/src/HYDROData/HYDROData_QuadtreeNode.hxx @@ -93,6 +93,9 @@ public: //! tells us if the tree as already bin computed bool isEmpty() const { return myChildren == 0; } + inline double getPrecision() {return myPrecision; } + inline double setPrecision(double precision) {myPrecision = precision; } + protected: struct Limit: public HYDROData_TreeLimit @@ -117,6 +120,9 @@ protected: //! The set of nodes inside the box of the Quadtree (Empty if Quadtree is not a leaf) Nodes_3D* myNodes; + + //! distance to look for nearest nodes + double myPrecision; }; #endif -- 2.39.2