0030480: Visualization - Clear of Select3D_SensitiveGroup does not update internal...
[occt.git] / src / Select3D / Select3D_SensitiveGroup.cxx
index 2b6aad8..9827b39 100644 (file)
@@ -157,7 +157,7 @@ void Select3D_SensitiveGroup::Clear()
   myEntities.Clear();
   myBndBox.Clear();
   myCenter = gp_Pnt (0.0, 0.0, 0.0);
-  myEntities.Clear();
+  myBVHPrimIndexes.Clear();
 }
 
 //=======================================================================
@@ -202,14 +202,12 @@ Standard_Boolean Select3D_SensitiveGroup::Matches (SelectBasics_SelectingVolumeM
     return Select3D_SensitiveSet::Matches (theMgr, thePickResult);
   }
 
-  Standard_Real aDepth     = RealLast();
-  Standard_Real aDistToCOG = RealLast();
+  SelectBasics_PickResult aPickResult;
   Standard_Boolean isFailed = Standard_False;
   for (Select3D_IndexedMapOfEntity::Iterator anEntityIter (myEntities); anEntityIter.More(); anEntityIter.Next())
   {
-    SelectBasics_PickResult aMatchResult;
     const Handle(Select3D_SensitiveEntity)& aChild = anEntityIter.Value();
-    if (!aChild->Matches (theMgr, aMatchResult))
+    if (!aChild->Matches (theMgr, aPickResult))
     {
       if (toMatchAll)
       {
@@ -222,17 +220,15 @@ Standard_Boolean Select3D_SensitiveGroup::Matches (SelectBasics_SelectingVolumeM
     }
     else
     {
-      aDepth = Min (aMatchResult.Depth(), aDepth);
+      thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
     }
   }
   if (isFailed)
   {
-    thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
     return Standard_False;
   }
 
-  aDistToCOG = theMgr.DistToGeometryCenter (CenterOfGeometry());
-  thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
+  thePickResult.SetDistToGeomCenter(distanceToCOG(theMgr));
   return Standard_True;
 }
 
@@ -330,16 +326,14 @@ Standard_Integer Select3D_SensitiveGroup::Size() const
 // purpose  : Checks whether the entity with index theIdx overlaps the
 //            current selecting volume
 // =======================================================================
-Standard_Boolean Select3D_SensitiveGroup::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
+Standard_Boolean Select3D_SensitiveGroup::overlapsElement (SelectBasics_PickResult& thePickResult,
+                                                           SelectBasics_SelectingVolumeManager& theMgr,
                                                            Standard_Integer theElemIdx,
-                                                           Standard_Real& theMatchDepth)
+                                                           Standard_Boolean )
 {
-  theMatchDepth = RealLast();
   const Standard_Integer aSensitiveIdx = myBVHPrimIndexes.Value (theElemIdx);
-  SelectBasics_PickResult aResult;
-  if (myEntities.FindKey (aSensitiveIdx)->Matches (theMgr, aResult))
+  if (myEntities.FindKey (aSensitiveIdx)->Matches (theMgr, thePickResult))
   {
-    theMatchDepth = aResult.Depth();
     return Standard_True;
   }
 
@@ -351,10 +345,11 @@ Standard_Boolean Select3D_SensitiveGroup::overlapsElement (SelectBasics_Selectin
 // purpose  :
 // =======================================================================
 Standard_Boolean Select3D_SensitiveGroup::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
-                                                           const Standard_Integer               theElemIdx)
+                                                           Standard_Integer theElemIdx,
+                                                           Standard_Boolean theIsFullInside)
 {
-  Standard_Real aDummy;
-  return overlapsElement(theMgr, theElemIdx, aDummy);
+  SelectBasics_PickResult aDummy;
+  return overlapsElement (aDummy, theMgr, theElemIdx, theIsFullInside);
 }
 
 // =======================================================================