0030416: Incorrect implementation of the method Bnd_OBB::SquareExtent
[occt.git] / src / MeshVS / MeshVS_SensitivePolyhedron.cxx
index b2013e5..f649641 100644 (file)
@@ -26,8 +26,8 @@
 #include <TColgp_Array1OfPnt2d.hxx>
 #include <TColStd_SequenceOfInteger.hxx>
 
-IMPLEMENT_STANDARD_HANDLE (MeshVS_SensitivePolyhedron, Select3D_SensitiveEntity)
-IMPLEMENT_STANDARD_RTTIEXT(MeshVS_SensitivePolyhedron, Select3D_SensitiveEntity)
+
+IMPLEMENT_STANDARD_RTTIEXT(MeshVS_SensitivePolyhedron,Select3D_SensitiveEntity)
 
 //================================================================
 // Function : Constructor MeshVS_SensitivePolyhedron
@@ -84,22 +84,21 @@ Handle(Select3D_SensitiveEntity) MeshVS_SensitivePolyhedron::GetConnected()
 Standard_Boolean MeshVS_SensitivePolyhedron::Matches (SelectBasics_SelectingVolumeManager& theMgr,
                                                       SelectBasics_PickResult& thePickResult)
 {
-  Standard_Real aDepthMin = RealLast();
-  Standard_Real aDistToCOG = RealLast();
-
+  SelectBasics_PickResult aPickResult;
   for (MeshVS_PolyhedronVertsIter aIter (myTopology); aIter.More(); aIter.Next())
   {
-    Standard_Real aDepth = RealLast();
-    if (theMgr.Overlaps (aIter.Value(), Select3D_TOS_INTERIOR, aDepth))
+    if (theMgr.Overlaps (aIter.Value(), Select3D_TOS_INTERIOR, aPickResult))
     {
-      aDepthMin = Min (aDepth, aDepthMin);
+      thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
     }
   }
+  if (!thePickResult.IsValid())
+  {
+    return Standard_False;
+  }
 
-  aDistToCOG = aDepthMin == RealLast() ? RealLast() : theMgr.DistToGeometryCenter (myCenter);
-  thePickResult = SelectBasics_PickResult (aDepthMin, aDistToCOG);
-
-  return aDepthMin != RealLast();
+  thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter (CenterOfGeometry()));
+  return Standard_True;
 }
 
 //=======================================================================