1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-18 14:27:39 +03:00

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.
This commit is contained in:
vpa
2016-05-20 19:42:09 +03:00
committed by bugmaster
parent a002d297f7
commit 41e08b4df8
3 changed files with 23 additions and 2 deletions

View File

@@ -321,3 +321,12 @@ Select3D_BndBox3d MeshVS_CommonSensitiveEntity::BoundingBox()
{ {
return myBndBox; return myBndBox;
} }
//=======================================================================
//function : CenterOfGeometry
//purpose :
//=======================================================================
gp_Pnt MeshVS_CommonSensitiveEntity::CenterOfGeometry() const
{
return myCOG;
}

View File

@@ -55,6 +55,9 @@ public:
//! transformation is set, it will be applied //! transformation is set, it will be applied
Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE; Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
//! Returns center of a mesh
Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
public: public:
DEFINE_STANDARD_RTTIEXT (MeshVS_CommonSensitiveEntity, Select3D_SensitiveSet) DEFINE_STANDARD_RTTIEXT (MeshVS_CommonSensitiveEntity, Select3D_SensitiveSet)

View File

@@ -54,8 +54,17 @@ Standard_ShortReal OpenGl_BVHClipPrimitiveSet::Center (const Standard_Integer th
{ {
Graphic3d_BndBox4f aBndBox = myStructs.FindKey (theIdx + 1)->BoundingBox(); Graphic3d_BndBox4f aBndBox = myStructs.FindKey (theIdx + 1)->BoundingBox();
return (aBndBox.CornerMin()[theAxis] + // to prevent float overflow
aBndBox.CornerMax()[theAxis]) * 0.5f; 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);
} }
// ======================================================================= // =======================================================================