]> OCCT Git - occt-copy.git/commitdiff
0027317: Some visualisation tests failed because of exceptions generated by FP signals.
authorvpa <vpa@opencascade.com>
Fri, 20 May 2016 16:42:09 +0000 (19:42 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 27 May 2016 08:57:44 +0000 (11:57 +0300)
- 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
src/MeshVS/MeshVS_CommonSensitiveEntity.hxx
src/OpenGl/OpenGl_BVHClipPrimitiveSet.cxx

index 9438498af0e50ed37023defa42b51db41cdab924..ebe36dd52199bf6bc8abedfd649036f6cc0a8aac 100644 (file)
@@ -321,3 +321,12 @@ Select3D_BndBox3d MeshVS_CommonSensitiveEntity::BoundingBox()
 {
   return myBndBox;
 }
+
+//=======================================================================
+//function : CenterOfGeometry
+//purpose  :
+//=======================================================================
+gp_Pnt MeshVS_CommonSensitiveEntity::CenterOfGeometry() const
+{
+  return myCOG;
+}
index 90bf52423452fc75830467c8bc3d23cb422f211a..5f36d6816359cf0c53ff0318526fd8a73195c45a 100644 (file)
@@ -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)
index a249664143b81f62016a1860e57777559c939c63..a21840f98f86a37609e46f73532d2aab60cc9705 100644 (file)
@@ -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);
 }
 
 // =======================================================================