From 41e08b4df852620444707084f3bf33fce92bcf25 Mon Sep 17 00:00:00 2001 From: vpa Date: Fri, 20 May 2016 19:42:09 +0300 Subject: [PATCH] 0027317: Some visualisation tests failed because of exceptions generated by FP signals. - missing implementation of CenterOfGeometry method was added in MeshVS_CommonSensitiveEntity; - a check to prevent float overflow was added to OpenGl_BVHClipPrimitiveSet::Center. --- src/MeshVS/MeshVS_CommonSensitiveEntity.cxx | 9 +++++++++ src/MeshVS/MeshVS_CommonSensitiveEntity.hxx | 3 +++ src/OpenGl/OpenGl_BVHClipPrimitiveSet.cxx | 13 +++++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/MeshVS/MeshVS_CommonSensitiveEntity.cxx b/src/MeshVS/MeshVS_CommonSensitiveEntity.cxx index 9438498af0..ebe36dd521 100644 --- a/src/MeshVS/MeshVS_CommonSensitiveEntity.cxx +++ b/src/MeshVS/MeshVS_CommonSensitiveEntity.cxx @@ -321,3 +321,12 @@ Select3D_BndBox3d MeshVS_CommonSensitiveEntity::BoundingBox() { return myBndBox; } + +//======================================================================= +//function : CenterOfGeometry +//purpose : +//======================================================================= +gp_Pnt MeshVS_CommonSensitiveEntity::CenterOfGeometry() const +{ + return myCOG; +} diff --git a/src/MeshVS/MeshVS_CommonSensitiveEntity.hxx b/src/MeshVS/MeshVS_CommonSensitiveEntity.hxx index 90bf524234..5f36d68163 100644 --- a/src/MeshVS/MeshVS_CommonSensitiveEntity.hxx +++ b/src/MeshVS/MeshVS_CommonSensitiveEntity.hxx @@ -55,6 +55,9 @@ public: //! transformation is set, it will be applied Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE; + //! Returns center of a mesh + Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE; + public: DEFINE_STANDARD_RTTIEXT (MeshVS_CommonSensitiveEntity, Select3D_SensitiveSet) diff --git a/src/OpenGl/OpenGl_BVHClipPrimitiveSet.cxx b/src/OpenGl/OpenGl_BVHClipPrimitiveSet.cxx index a249664143..a21840f98f 100644 --- a/src/OpenGl/OpenGl_BVHClipPrimitiveSet.cxx +++ b/src/OpenGl/OpenGl_BVHClipPrimitiveSet.cxx @@ -54,8 +54,17 @@ Standard_ShortReal OpenGl_BVHClipPrimitiveSet::Center (const Standard_Integer th { Graphic3d_BndBox4f aBndBox = myStructs.FindKey (theIdx + 1)->BoundingBox(); - return (aBndBox.CornerMin()[theAxis] + - aBndBox.CornerMax()[theAxis]) * 0.5f; + // to prevent float overflow + const Standard_Real aMin = Standard_Real (aBndBox.CornerMin()[theAxis]); + const Standard_Real aMax = Standard_Real (aBndBox.CornerMax()[theAxis]); + const Standard_Real aCenter = (aMin + aMax) * 0.5; + + if (aCenter <= Standard_Real (-ShortRealLast())) + return -ShortRealLast(); + if (aCenter >= Standard_Real (ShortRealLast())) + return ShortRealLast(); + + return Standard_ShortReal (aCenter); } // ======================================================================= -- 2.39.5