From: vbd Date: Wed, 8 Aug 2007 14:37:38 +0000 (+0000) Subject: staffan : X-Git-Tag: trio_trio_coupling~75 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7ffea96349e3de8ccbee0e8314fd194621421791;p=tools%2Fmedcoupling.git staffan : * fixed nasty bug in constructor --- 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;