From: vpa Date: Fri, 20 May 2016 16:42:09 +0000 (+0300) Subject: 0027317: Some visualisation tests failed because of exceptions generated by FP signals. X-Git-Tag: V7_0_winwerth~36 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=41e08b4df852620444707084f3bf33fce92bcf25;hp=a002d297f7c4ff95e0cabfa5622d2477b6c97edc 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. --- 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); } // =======================================================================