From 7ffea96349e3de8ccbee0e8314fd194621421791 Mon Sep 17 00:00:00 2001 From: vbd Date: Wed, 8 Aug 2007 14:37:38 +0000 Subject: [PATCH] staffan : * fixed nasty bug in constructor --- src/INTERP_KERNEL/BoundingBox.cxx | 27 ++++++++++++++++++++++++++- src/INTERP_KERNEL/BoundingBox.hxx | 5 +++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/INTERP_KERNEL/BoundingBox.cxx b/src/INTERP_KERNEL/BoundingBox.cxx index bb4f17fe5..2a43dceb5 100644 --- a/src/INTERP_KERNEL/BoundingBox.cxx +++ b/src/INTERP_KERNEL/BoundingBox.cxx @@ -1,5 +1,6 @@ #include "BoundingBox.hxx" +#include #include namespace INTERP_UTILS @@ -32,14 +33,16 @@ namespace INTERP_UTILS for(BoxCoord c = XMIN ; c <= ZMIN ; c = BoxCoord(c + 1)) { _coords[c] = min(pt1[c], pt2[c]); - _coords[c + 3] = max(pt1[c + 3], pt2[c + 3]); + _coords[c + 3] = max(pt1[c], pt2[c]); } for(int i = 2 ; i < numPts ; ++i) { updateWithPoint(pts[i]); } + assert(isValid()); } + /** * Constructor creating box from union of two boxes * @@ -52,6 +55,7 @@ namespace INTERP_UTILS _coords[c] = min(box1._coords[c], box2._coords[c]); _coords[c + 3] = max(box1._coords[c + 3], box2._coords[c + 3]); } + assert(isValid()); } /** @@ -78,6 +82,12 @@ namespace INTERP_UTILS // boxes are disjoint if there exists a direction in which the // minimum coordinate of one is greater than the maximum coordinate of the other + + //? stable version + /* const double tol = 1.0e-2; + if(_coords[c] > otherMaxCoord + tol + || _coords[c + 3] < otherMinCoord - tol) + */ if(_coords[c] > otherMaxCoord || _coords[c + 3] < otherMinCoord) { @@ -132,4 +142,19 @@ namespace INTERP_UTILS } } + + bool BoundingBox::isValid() const + { + bool valid = true; + for(BoxCoord c = XMIN ; c < ZMIN ; c = BoxCoord(c + 1)) + { + if(_coords[c] >= _coords[c + 3]) + { + std::cout << "BoundingBox |: coordinate " << c << " is invalid : " << _coords[c] << " >= " << _coords[c+3] << std::endl; + valid = false; + } + } + return valid; + } + }; diff --git a/src/INTERP_KERNEL/BoundingBox.hxx b/src/INTERP_KERNEL/BoundingBox.hxx index 64297d906..49640555e 100644 --- a/src/INTERP_KERNEL/BoundingBox.hxx +++ b/src/INTERP_KERNEL/BoundingBox.hxx @@ -72,8 +72,13 @@ namespace INTERP_UTILS void updateWithPoint(const double* pt); private: + + bool isValid() const; + double _coords[6]; + + }; // typedef BoundingBox::BoxCoord BoxCoord; -- 2.39.2