0029938: Visualization - SelectMgr_ViewerSelector::PickedPoint() should return point...
authormnv <mnv@opencascade.com>
Mon, 23 Jul 2018 12:08:01 +0000 (15:08 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 2 Aug 2018 15:47:38 +0000 (18:47 +0300)
Extended SelectBasics_PickResult structure by myObjPickedPnt field, which contained the value of the 3d point on the selected object.
Changed all Overlaps methods. Parameter theDepth replaced on object of the structure SelectBasics_PickResult. This approach will be able to add new fields to SelectBasics_PickResult structure without big changes in modules which contained Overlaps method.

39 files changed:
dox/dev_guides/upgrade/upgrade.md
src/MeshVS/MeshVS_CommonSensitiveEntity.cxx
src/MeshVS/MeshVS_CommonSensitiveEntity.hxx
src/MeshVS/MeshVS_SensitivePolyhedron.cxx
src/MeshVS/MeshVS_SensitiveQuad.cxx
src/Select3D/Select3D_InteriorSensitivePointSet.cxx
src/Select3D/Select3D_InteriorSensitivePointSet.hxx
src/Select3D/Select3D_SensitiveBox.cxx
src/Select3D/Select3D_SensitiveCircle.cxx
src/Select3D/Select3D_SensitiveGroup.cxx
src/Select3D/Select3D_SensitiveGroup.hxx
src/Select3D/Select3D_SensitivePoint.cxx
src/Select3D/Select3D_SensitivePoly.cxx
src/Select3D/Select3D_SensitivePoly.hxx
src/Select3D/Select3D_SensitivePrimitiveArray.cxx
src/Select3D/Select3D_SensitivePrimitiveArray.hxx
src/Select3D/Select3D_SensitiveSegment.cxx
src/Select3D/Select3D_SensitiveSet.cxx
src/Select3D/Select3D_SensitiveSet.hxx
src/Select3D/Select3D_SensitiveTriangle.cxx
src/Select3D/Select3D_SensitiveTriangulation.cxx
src/Select3D/Select3D_SensitiveTriangulation.hxx
src/Select3D/Select3D_SensitiveWire.cxx
src/Select3D/Select3D_SensitiveWire.hxx
src/SelectBasics/SelectBasics_PickResult.hxx
src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx
src/SelectMgr/SelectMgr_BaseFrustum.cxx
src/SelectMgr/SelectMgr_BaseFrustum.hxx
src/SelectMgr/SelectMgr_RectangularFrustum.cxx
src/SelectMgr/SelectMgr_RectangularFrustum.hxx
src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx
src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx
src/SelectMgr/SelectMgr_TriangularFrustum.cxx
src/SelectMgr/SelectMgr_TriangularFrustum.hxx
src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx
src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx
src/SelectMgr/SelectMgr_ViewerSelector.cxx
src/SelectMgr/SelectMgr_ViewerSelector.hxx
tests/bugs/vis/bug29938 [new file with mode: 0644]

index f12db99..15c9aa3 100644 (file)
@@ -1610,4 +1610,8 @@ A set of deprecated methods previously related to Local Context and now redirect
 
 @subsection upgrade_740_extremaalgo Changes in behavior of Convert algorithms
 
-Now methods *GeomConvert::ConcatG1*, *GeomConvert::ConcatC1*, *Geom2dConvert::ConcatG1*, *Geom2dConvert::ConcatC1* modify the input argument representing the flag of closedness.
\ No newline at end of file
+Now methods *GeomConvert::ConcatG1*, *GeomConvert::ConcatC1*, *Geom2dConvert::ConcatG1*, *Geom2dConvert::ConcatC1* modify the input argument representing the flag of closedness.
+@subsection upgrade_740_selection Change in selection API and picked point calculation algorithm.
+
+*SelectBasics_PickResult* structure has been extended, so that it now defines 3D point on detected entity in addition to Depth value along picking ray.
+*SelectMgr_SelectingVolumeManager::Overlap()* methods have been corrected to fill in *SelectBasics_PickResult* structure (depth and 3D point) instead of only depth value, so that custom *Select3D_SensitiveEntity* implementation should be updated accordingly (including *Select3D_SensitiveSet* subclasses).
index 6362d8c..c6a445e 100644 (file)
@@ -224,7 +224,7 @@ void MeshVS_CommonSensitiveEntity::Swap (const Standard_Integer theIdx1,
 //=======================================================================
 Standard_Boolean MeshVS_CommonSensitiveEntity::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
                                                                 Standard_Integer theElemIdx,
-                                                                Standard_Real& theMatchDepth)
+                                                                SelectBasics_PickResult& thePickResult)
 {
   const Standard_Integer anItemIdx = myItemIndexes.Value (theElemIdx);
   if (mySelMethod == MeshVS_MSM_PRECISE)
@@ -250,7 +250,7 @@ Standard_Boolean MeshVS_CommonSensitiveEntity::overlapsElement (SelectBasics_Sel
       return theMgr.Overlaps (gp_Pnt (aCoords (1), aCoords (2), aCoords (3)),
                               gp_Pnt (aCoords (4), aCoords (5), aCoords (6)),
                               gp_Pnt (aCoords (7), aCoords (8), aCoords (9)),
-                              Select3D_TOS_INTERIOR, theMatchDepth);
+                              Select3D_TOS_INTERIOR, thePickResult);
     }
 
     MeshVS_Buffer aFacePntsBuf (aNbNodes * 3 * sizeof (Standard_Real));
@@ -261,12 +261,12 @@ Standard_Boolean MeshVS_CommonSensitiveEntity::overlapsElement (SelectBasics_Sel
                                             aCoords (3 * aNodeIdx - 1),
                                             aCoords (3 * aNodeIdx)));
     }
-    return theMgr.Overlaps (aFacePnts, Select3D_TOS_INTERIOR, theMatchDepth);
+    return theMgr.Overlaps (aFacePnts, Select3D_TOS_INTERIOR, thePickResult);
   }
   else if (mySelMethod == MeshVS_MSM_NODES)
   {
     const gp_Pnt aVert = getVertexByIndex (anItemIdx);
-    return theMgr.Overlaps (aVert, theMatchDepth);
+    return theMgr.Overlaps (aVert, thePickResult);
   }
   return Standard_False;
 }
index ef1e07c..6f9bae8 100644 (file)
@@ -67,7 +67,7 @@ protected:
   //! Checks whether the entity with index theIdx overlaps the current selecting volume
   Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
                                                             Standard_Integer theElemIdx,
-                                                            Standard_Real& theMatchDepth) Standard_OVERRIDE;
+                                                            SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! Checks whether the entity with index theIdx is inside the current selecting volume
   Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
index 6da927e..f649641 100644 (file)
@@ -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;
 }
 
 //=======================================================================
index 5f0825d..846a984 100644 (file)
@@ -66,8 +66,6 @@ Handle(Select3D_SensitiveEntity) MeshVS_SensitiveQuad::GetConnected()
 Standard_Boolean MeshVS_SensitiveQuad::Matches (SelectBasics_SelectingVolumeManager& theMgr,
                                                 SelectBasics_PickResult& thePickResult)
 {
-  thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
-
   if (!theMgr.IsOverlapAllowed()) // check for inclusion
   {
     for (Standard_Integer aPntIdx = 0; aPntIdx < 4; ++aPntIdx)
@@ -80,16 +78,15 @@ Standard_Boolean MeshVS_SensitiveQuad::Matches (SelectBasics_SelectingVolumeMana
   }
 
   // check for overlap
-  Standard_Real aDepth1 = std::numeric_limits<Standard_Real>::max();
-  Standard_Real aDepth2 = std::numeric_limits<Standard_Real>::max();
-  if (!theMgr.Overlaps (myVertices[0], myVertices[1], myVertices[2], Select3D_TOS_INTERIOR, aDepth1)
-    && !theMgr.Overlaps (myVertices[0], myVertices[2], myVertices[3], Select3D_TOS_INTERIOR, aDepth2))
+  SelectBasics_PickResult aPickResult1, aPickResult2;
+  if (!theMgr.Overlaps (myVertices[0], myVertices[1], myVertices[2], Select3D_TOS_INTERIOR, aPickResult1)
+   && !theMgr.Overlaps (myVertices[0], myVertices[2], myVertices[3], Select3D_TOS_INTERIOR, aPickResult2))
   {
     return Standard_False;
   }
 
-  thePickResult = SelectBasics_PickResult (Min (aDepth1, aDepth2), theMgr.DistToGeometryCenter (CenterOfGeometry()));
-
+  thePickResult = SelectBasics_PickResult::Min (aPickResult1, aPickResult2);
+  thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter(CenterOfGeometry()));
   return Standard_True;
 }
 
index 708e412..553ddcb 100644 (file)
@@ -264,13 +264,13 @@ void Select3D_InteriorSensitivePointSet::Swap (const Standard_Integer theIdx1,
 // =======================================================================
 Standard_Boolean Select3D_InteriorSensitivePointSet::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
                                                                       Standard_Integer theElemIdx,
-                                                                      Standard_Real& theMatchDepth)
+                                                                      SelectBasics_PickResult& thePickResult)
 {
   Standard_Integer aPolygIdx = myPolygonsIdxs->Value (theElemIdx);
   const Handle(Select3D_SensitivePoly)& aPolygon = myPlanarPolygons.Value (aPolygIdx);
   Handle(TColgp_HArray1OfPnt) aPoints;
   aPolygon->Points3D (aPoints);
-  return theMgr.Overlaps (aPoints, Select3D_TOS_INTERIOR, theMatchDepth);
+  return theMgr.Overlaps (aPoints, Select3D_TOS_INTERIOR, thePickResult);
 }
 
 // =======================================================================
@@ -280,7 +280,7 @@ Standard_Boolean Select3D_InteriorSensitivePointSet::overlapsElement (SelectBasi
 Standard_Boolean Select3D_InteriorSensitivePointSet::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
                                                                       const Standard_Integer               theElemIdx)
 {
-  Standard_Real aDummy;
+  SelectBasics_PickResult aDummy;
   return overlapsElement (theMgr, theElemIdx, aDummy);
 }
 
index 6fb4689..cfaca92 100644 (file)
@@ -78,7 +78,7 @@ protected:
   //! in myPlanarPolygons overlaps the current selecting volume
   Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
                                                             Standard_Integer theElemIdx,
-                                                            Standard_Real& theMatchDepth) Standard_OVERRIDE;
+                                                            SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! Checks whether the entity with index theIdx is inside the current selecting volume
   Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
index c363c1e..526ee3f 100644 (file)
@@ -86,23 +86,18 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveBox::GetConnected()
 Standard_Boolean Select3D_SensitiveBox::Matches (SelectBasics_SelectingVolumeManager& theMgr,
                                                  SelectBasics_PickResult& thePickResult)
 {
-  thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
-
   if (!theMgr.IsOverlapAllowed()) // check for inclusion
   {
     Standard_Boolean isInside = Standard_True;
     return theMgr.Overlaps (myBox.CornerMin(), myBox.CornerMax(), &isInside) && isInside;
   }
 
-  Standard_Real aDepth;
-  if (!theMgr.Overlaps (myBox.CornerMin(), myBox.CornerMax(), aDepth)) // check for overlap
+  if (!theMgr.Overlaps (myBox.CornerMin(), myBox.CornerMax(), thePickResult)) // check for overlap
   {
     return Standard_False;
   }
 
-  thePickResult = SelectBasics_PickResult (
-    aDepth, theMgr.DistToGeometryCenter (myCenter3d));
-
+  thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter(myCenter3d));
   return Standard_True;
 }
 
index 0682950..3048abc 100644 (file)
@@ -238,14 +238,10 @@ void Select3D_SensitiveCircle::BVH()
 Standard_Boolean Select3D_SensitiveCircle::Matches (SelectBasics_SelectingVolumeManager& theMgr,
                                                     SelectBasics_PickResult& thePickResult)
 {
-  Standard_Real aDepth     = RealLast();
-  Standard_Real aDistToCOG = RealLast();
-
   if (mySensType == Select3D_TOS_BOUNDARY)
   {
     if (!Select3D_SensitivePoly::Matches (theMgr, thePickResult))
     {
-      thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
       return Standard_False;
     }
   }
@@ -255,24 +251,21 @@ Standard_Boolean Select3D_SensitiveCircle::Matches (SelectBasics_SelectingVolume
     Points3D (anArrayOfPnt);
     if (!theMgr.IsOverlapAllowed())
     {
-      thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
       for (Standard_Integer aPntIdx = anArrayOfPnt->Lower(); aPntIdx <= anArrayOfPnt->Upper(); ++aPntIdx)
       {
-        if (!theMgr.Overlaps (anArrayOfPnt->Value (aPntIdx)))
+        if (!theMgr.Overlaps (anArrayOfPnt->Value(aPntIdx)))
+        {
           return Standard_False;
+        }
       }
       return Standard_True;
     }
 
-    if (!theMgr.Overlaps (anArrayOfPnt, Select3D_TOS_INTERIOR, aDepth))
+    if (!theMgr.Overlaps (anArrayOfPnt, Select3D_TOS_INTERIOR, thePickResult))
     {
-      thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
       return Standard_False;
     }
-    else
-    {
-      thePickResult = SelectBasics_PickResult (aDepth, theMgr.DistToGeometryCenter (myCenter3D));
-    }
+    thePickResult.SetDistToGeomCenter(distanceToCOG(theMgr));
   }
 
   return Standard_True;
index 2b6aad8..edf866c 100644 (file)
@@ -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;
 }
 
@@ -332,14 +328,11 @@ Standard_Integer Select3D_SensitiveGroup::Size() const
 // =======================================================================
 Standard_Boolean Select3D_SensitiveGroup::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
                                                            Standard_Integer theElemIdx,
-                                                           Standard_Real& theMatchDepth)
+                                                           SelectBasics_PickResult& thePickResult)
 {
-  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;
   }
 
@@ -353,7 +346,7 @@ Standard_Boolean Select3D_SensitiveGroup::overlapsElement (SelectBasics_Selectin
 Standard_Boolean Select3D_SensitiveGroup::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
                                                            const Standard_Integer               theElemIdx)
 {
-  Standard_Real aDummy;
+  SelectBasics_PickResult aDummy;
   return overlapsElement(theMgr, theElemIdx, aDummy);
 }
 
index a7d3da9..7b7380f 100644 (file)
@@ -148,7 +148,7 @@ private:
   //! Checks whether the entity with index theIdx overlaps the current selecting volume
   virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
                                             Standard_Integer theElemIdx,
-                                            Standard_Real& theMatchDepth) Standard_OVERRIDE;
+                                            SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! Checks whether the entity with index theIdx is inside the current selecting volume
   virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
index 18941fa..b545609 100644 (file)
@@ -37,16 +37,12 @@ Select3D_SensitivePoint::Select3D_SensitivePoint (const Handle(SelectBasics_Enti
 Standard_Boolean Select3D_SensitivePoint::Matches (SelectBasics_SelectingVolumeManager& theMgr,
                                                    SelectBasics_PickResult& thePickResult)
 {
-  Standard_Real aDepth      = RealLast();
-  Standard_Real aDistToCOG  = RealLast();
-  if (!theMgr.Overlaps (myPoint, aDepth))
+  if (!theMgr.Overlaps (myPoint, thePickResult))
   {
-    thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
     return Standard_False;
   }
 
-  aDistToCOG = aDepth;
-  thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
+  thePickResult.SetDistToGeomCenter (thePickResult.Depth());
   return Standard_True;
 }
 
index c7f625e..5c19d68 100644 (file)
@@ -222,7 +222,7 @@ void Select3D_SensitivePoly::Swap (const Standard_Integer theIdx1,
 //==================================================
 Standard_Boolean Select3D_SensitivePoly::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
                                                           Standard_Integer theElemIdx,
-                                                          Standard_Real& theMatchDepth)
+                                                          SelectBasics_PickResult& thePickResult)
 {
   if (mySegmentIndexes.IsNull())
     return Standard_False;
@@ -231,7 +231,7 @@ Standard_Boolean Select3D_SensitivePoly::overlapsElement (SelectBasics_Selecting
   gp_Pnt aPnt1 = myPolyg.Pnt3d (aSegmentIdx);
   gp_Pnt aPnt2 = myPolyg.Pnt3d (aSegmentIdx + 1);
 
-  return theMgr.Overlaps (aPnt1, aPnt2, theMatchDepth);
+  return theMgr.Overlaps (aPnt1, aPnt2, thePickResult);
 }
 
 //==================================================
index 0e3eb81..aaa7429 100644 (file)
@@ -97,7 +97,7 @@ private:
   //! Checks whether the segment with index theIdx overlaps the current selecting volume
   virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
                                             Standard_Integer theElemIdx,
-                                            Standard_Real& theMatchDepth) Standard_OVERRIDE;
+                                            SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! Checks whether the entity with index theIdx is inside the current selecting volume
   virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
index 9fb5716..eb3dcf5 100644 (file)
@@ -928,15 +928,14 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::Matches (SelectBasics_Selecti
     return Standard_True;
   }
 
-  Standard_Real aDepth = RealLast();
+  SelectBasics_PickResult aPickResult;
   bool isFailed = false;
   const bool toMatchAll = !theMgr.IsOverlapAllowed();
   for (Standard_Integer aGroupIter = 0; aGroupIter < myBvhIndices.NbElements; ++aGroupIter)
   {
     const Standard_Integer anElemIdx = myBvhIndices.Index (aGroupIter);
-    SelectBasics_PickResult aMatchResult;
     Handle(Select3D_SensitivePrimitiveArray)& aChild = myGroups->ChangeValue (anElemIdx);
-    const bool isMatched = aChild->Matches (theMgr, aMatchResult);
+    const bool isMatched = aChild->Matches (theMgr, aPickResult);
     if (!myDetectedElemMap.IsNull())
     {
       myDetectedElemMap->ChangeMap().Unite (aChild->myDetectedElemMap->Map());
@@ -959,20 +958,18 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::Matches (SelectBasics_Selecti
     }
     else
     {
-      if (aDepth > aMatchResult.Depth())
+      if (thePickResult.Depth() > aPickResult.Depth())
       {
         myDetectedIdx = aGroupIter;
-        aDepth = aMatchResult.Depth();
+        thePickResult = aPickResult;
       }
     }
   }
   if (isFailed)
   {
-    thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
     return Standard_False;
   }
-
-  thePickResult = SelectBasics_PickResult (aDepth, theMgr.DistToGeometryCenter (CenterOfGeometry()));
+  thePickResult.SetDistToGeomCenter(theMgr.DistToGeometryCenter(CenterOfGeometry()));
   return Standard_True;
 }
 
@@ -982,25 +979,23 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::Matches (SelectBasics_Selecti
 // =======================================================================
 Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
                                                                     Standard_Integer theElemIdx,
-                                                                    Standard_Real& theMatchDepth)
+                                                                    SelectBasics_PickResult& thePickResult)
 {
   const Standard_Integer anElemIdx = myBvhIndices.Index (theElemIdx);
   if (!myGroups.IsNull())
   {
-    SelectBasics_PickResult aResult;
-    if (myGroups->Value (anElemIdx)->Matches (theMgr, aResult))
+    if (myGroups->Value (anElemIdx)->Matches (theMgr, thePickResult))
     {
-      theMatchDepth = aResult.Depth();
       return Standard_True;
     }
-    theMatchDepth = RealLast();
+
     return Standard_False;
   }
 
   const Standard_Integer aPatchSize = myBvhIndices.PatchSize (theElemIdx);
   Select3D_BndBox3d aBox;
   Standard_Boolean aResult = Standard_False;
-  Standard_Real aMinDepth  = RealLast();
+  SelectBasics_PickResult aPickResult;
   switch (myPrimType)
   {
     case Graphic3d_TOPA_POINTS:
@@ -1021,16 +1016,15 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics
           aPoint = vecToPnt (getPosVec2 (aPointIndex));
         }
 
-        Standard_Real aCurrentDepth = RealLast();
         if (myToDetectNode
          || myToDetectElem)
         {
-          if (theMgr.Overlaps (aPoint, aCurrentDepth))
+          if (theMgr.Overlaps (aPoint, aPickResult))
           {
-            if (aCurrentDepth <= myMinDepthNode)
+            if (aPickResult.Depth() <= myMinDepthNode)
             {
               myDetectedElem = myDetectedNode = aPointIndex;
-              myMinDepthElem = myMinDepthNode = aCurrentDepth;
+              myMinDepthElem = myMinDepthNode = aPickResult.Depth();
             }
             if (theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Point)
             {
@@ -1046,7 +1040,7 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics
             aResult = Standard_True;
           }
         }
-        aMinDepth = Min (aMinDepth, aCurrentDepth);
+        thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
       }
       break;
     }
@@ -1072,15 +1066,14 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics
           aPnts[2] = vecToPnt (getPosVec2 (aTriNodes[2]));
         }
 
-        Standard_Real aCurrentDepth = RealLast();
         if (myToDetectElem)
         {
-          if (theMgr.Overlaps (aPnts[0], aPnts[1], aPnts[2], Select3D_TOS_INTERIOR, aCurrentDepth))
+          if (theMgr.Overlaps (aPnts[0], aPnts[1], aPnts[2], Select3D_TOS_INTERIOR, aPickResult))
           {
-            if (aCurrentDepth <= myMinDepthElem)
+            if (aPickResult.Depth() <= myMinDepthElem)
             {
               myDetectedElem = aTriIndex;
-              myMinDepthElem = aCurrentDepth;
+              myMinDepthElem = aPickResult.Depth();
             }
             aResult = Standard_True;
           }
@@ -1094,12 +1087,12 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics
         {
           for (int aNodeIter = 0; aNodeIter < 3; ++aNodeIter)
           {
-            if (theMgr.Overlaps (aPnts[aNodeIter], aCurrentDepth))
+            if (theMgr.Overlaps (aPnts[aNodeIter], aPickResult))
             {
-              if (aCurrentDepth <= myMinDepthNode)
+              if (aPickResult.Depth() <= myMinDepthNode)
               {
                 myDetectedNode = aTriNodes[aNodeIter];
-                myMinDepthNode = aCurrentDepth;
+                myMinDepthNode = aPickResult.Depth();
               }
               if (!myDetectedNodeMap.IsNull()
                 && theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Point)
@@ -1116,19 +1109,19 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics
           {
             int aNode1 = aNodeIter == 0 ? 2 : (aNodeIter - 1);
             int aNode2 = aNodeIter;
-            if (theMgr.Overlaps (aPnts[aNode1], aPnts[aNode2], aCurrentDepth))
+            if (theMgr.Overlaps (aPnts[aNode1], aPnts[aNode2], aPickResult))
             {
-              if (aCurrentDepth <= myMinDepthEdge)
+              if (aPickResult.Depth() <= myMinDepthEdge)
               {
                 myDetectedEdgeNode1 = aTriNodes[aNode1];
                 myDetectedEdgeNode2 = aTriNodes[aNode2];
-                myMinDepthEdge = aCurrentDepth;
+                myMinDepthEdge = aPickResult.Depth();
               }
               aResult = Standard_True;
             }
           }
         }
-        aMinDepth = Min (aMinDepth, aCurrentDepth);
+        thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
       }
       break;
     }
@@ -1138,7 +1131,6 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics
     }
   }
 
-  theMatchDepth = aMinDepth;
   return aResult;
 }
 
@@ -1161,7 +1153,7 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::elementIsInside (SelectBasics
   const Standard_Integer anElemIdx = myBvhIndices.Index (theElemIdx);
   if (!myGroups.IsNull())
   {
-    Standard_Real aDummy;
+    SelectBasics_PickResult aDummy;
     return overlapsElement (theMgr, theElemIdx, aDummy);
   }
 
index 599ff82..c36cd3e 100644 (file)
@@ -280,7 +280,7 @@ protected:
   //! Checks whether the element with index theIdx overlaps the current selecting volume
   Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
                                                             Standard_Integer theElemIdx,
-                                                            Standard_Real& theMatchDepth) Standard_OVERRIDE;
+                                                            SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! Calculates distance from the 3d projection of used-picked screen point to center of the geometry
   Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
index 640e328..ef14661 100644 (file)
@@ -42,22 +42,17 @@ Select3D_SensitiveSegment::Select3D_SensitiveSegment (const Handle(SelectBasics_
 Standard_Boolean Select3D_SensitiveSegment::Matches (SelectBasics_SelectingVolumeManager& theMgr,
                                                      SelectBasics_PickResult& thePickResult)
 {
-  thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
-
-  Standard_Real aDepth;
   if (!theMgr.IsOverlapAllowed()) // check for inclusion
   {
-    return theMgr.Overlaps (myStart, aDepth) && theMgr.Overlaps (myEnd, aDepth);
+    return theMgr.Overlaps (myStart, thePickResult) && theMgr.Overlaps (myEnd, thePickResult);
   }
 
-  if (!theMgr.Overlaps (myStart, myEnd, aDepth)) // check for overlap
+  if (!theMgr.Overlaps (myStart, myEnd, thePickResult)) // check for overlap
   {
     return Standard_False;
   }
 
-  thePickResult = SelectBasics_PickResult (aDepth,
-    theMgr.DistToGeometryCenter (CenterOfGeometry()));
-
+  thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter(CenterOfGeometry()));
   return Standard_True;
 }
 
index 88d3ded..df7f996 100644 (file)
@@ -76,7 +76,6 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan
 {
   myDetectedIdx = -1;
   const BVH_Tree<Standard_Real, 3, BVH_BinaryTree>* aBVH = myContent.GetBVH().get();
-  thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
   if (myContent.Size() < 1 || !theMgr.Overlaps (aBVH->MinPoint (0),
                                                 aBVH->MaxPoint (0)))
   {
@@ -88,7 +87,7 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan
   Standard_Integer aHead = -1;
 
   Standard_Integer aMatchesNb = -1;
-  Standard_Real    aMinDepth  = RealLast();
+  SelectBasics_PickResult aPickResult;
   for (;;)
   {
     const BVH_Vec4i& aData = aBVH->NodeInfoBuffer()[aNode];
@@ -150,16 +149,14 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan
         }
         else // overlap test
         {
-          Standard_Real aCurrentDepth = aMinDepth;
-
-          if (!overlapsElement (theMgr, anElemIdx, aCurrentDepth))
+          if (!overlapsElement (theMgr, anElemIdx, aPickResult))
           {
             continue;
           }
 
-          if (aMinDepth > aCurrentDepth)
+          if (thePickResult.Depth() > aPickResult.Depth())
           {
-            aMinDepth = aCurrentDepth;
+            thePickResult = aPickResult;
             myDetectedIdx = anElemIdx;
           }
 
@@ -176,7 +173,7 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan
 
   if (aMatchesNb != -1)
   {
-    thePickResult = SelectBasics_PickResult (aMinDepth, distanceToCOG (theMgr));
+    thePickResult.SetDistToGeomCenter(distanceToCOG(theMgr));
   }
 
   return !theMgr.IsOverlapAllowed() || aMatchesNb != -1;
index c64c84c..13ad6ba 100644 (file)
@@ -100,7 +100,7 @@ protected:
   //! @param theMatchDepth set to the current minimum depth by Select3D_SensitiveSet; should be set to the new depth when overlapping is detected
   virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
                                             Standard_Integer theElemIdx,
-                                            Standard_Real& theMatchDepth) = 0;
+                                            SelectBasics_PickResult& thePickResult) = 0;
 
   //! Checks whether the entity with index theIdx is inside the current selecting volume
   virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
index d07f418..fc24675 100644 (file)
@@ -48,8 +48,6 @@ Select3D_SensitiveTriangle::Select3D_SensitiveTriangle (const Handle(SelectBasic
 Standard_Boolean Select3D_SensitiveTriangle::Matches (SelectBasics_SelectingVolumeManager& theMgr,
                                                       SelectBasics_PickResult& thePickResult)
 {
-  Standard_Real aDepth     = RealLast();
-  Standard_Real aDistToCOG = RealLast();
   if (!theMgr.IsOverlapAllowed())
   {
     return theMgr.Overlaps (myPoints[0])
@@ -57,14 +55,12 @@ Standard_Boolean Select3D_SensitiveTriangle::Matches (SelectBasics_SelectingVolu
         && theMgr.Overlaps (myPoints[2]);
   }
 
-  if (!theMgr.Overlaps (myPoints[0], myPoints[1], myPoints[2], mySensType, aDepth))
+  if (!theMgr.Overlaps (myPoints[0], myPoints[1], myPoints[2], mySensType, thePickResult))
   {
-    thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
     return Standard_False;
   }
 
-  aDistToCOG = theMgr.DistToGeometryCenter (myCentroid);
-  thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
+  thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter(myCentroid));
   return Standard_True;
 }
 
index 21ccbc2..b8109e5 100644 (file)
@@ -198,9 +198,9 @@ Select3D_BndBox3d Select3D_SensitiveTriangulation::Box (const Standard_Integer t
     Standard_Integer aNode1, aNode2, aNode3;
     myTriangul->Triangles() (aPrimIdx + 1).Get (aNode1, aNode2, aNode3);
 
-    gp_Pnt aPnt1 = myTriangul->Nodes().Value (aNode1);
-    gp_Pnt aPnt2 = myTriangul->Nodes().Value (aNode2);
-    gp_Pnt aPnt3 = myTriangul->Nodes().Value (aNode3);
+    const gp_Pnt& aPnt1 = myTriangul->Nodes().Value (aNode1);
+    const gp_Pnt& aPnt2 = myTriangul->Nodes().Value (aNode2);
+    const gp_Pnt& aPnt3 = myTriangul->Nodes().Value (aNode3);
 
     aMinPnt = SelectMgr_Vec3 (Min (aPnt1.X(), Min (aPnt2.X(), aPnt3.X())),
                               Min (aPnt1.Y(), Min (aPnt2.Y(), aPnt3.Y())),
@@ -213,8 +213,8 @@ Select3D_BndBox3d Select3D_SensitiveTriangulation::Box (const Standard_Integer t
   {
     Standard_Integer aNodeIdx1 = myFreeEdges->Value (myFreeEdges->Lower() + aPrimIdx);
     Standard_Integer aNodeIdx2 = myFreeEdges->Value (myFreeEdges->Lower() + aPrimIdx + 1);
-    gp_Pnt aNode1 = myTriangul->Nodes().Value (aNodeIdx1);
-    gp_Pnt aNode2 = myTriangul->Nodes().Value (aNodeIdx2);
+    const gp_Pnt& aNode1 = myTriangul->Nodes().Value (aNodeIdx1);
+    const gp_Pnt& aNode2 = myTriangul->Nodes().Value (aNodeIdx2);
 
     aMinPnt = SelectMgr_Vec3 (Min (aNode1.X(), aNode2.X()),
                               Min (aNode1.Y(), aNode2.Y()),
@@ -236,9 +236,8 @@ Standard_Real Select3D_SensitiveTriangulation::Center (const Standard_Integer th
                                                        const Standard_Integer theAxis) const
 {
   const Select3D_BndBox3d& aBox = Box (theIdx);
-  SelectMgr_Vec3 aCenter = (aBox.CornerMin () + aBox.CornerMax ()) * 0.5;
-  
-  return theAxis == 0 ? aCenter.x() : (theAxis == 1 ? aCenter.y() : aCenter.z());
+  const SelectMgr_Vec3 aCenter = (aBox.CornerMin () + aBox.CornerMax ()) * 0.5;
+  return aCenter[theAxis];
 }
 
 //=======================================================================
@@ -262,7 +261,7 @@ void Select3D_SensitiveTriangulation::Swap (const Standard_Integer theIdx1,
 //=======================================================================
 Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
                                                                    Standard_Integer theElemIdx,
-                                                                   Standard_Real& theMatchDepth)
+                                                                   SelectBasics_PickResult& thePickResult)
 {
   const Standard_Integer& aPrimitiveIdx = myBVHPrimIndexes->Value (theElemIdx);
 
@@ -270,13 +269,14 @@ Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_
   {
     Standard_Integer aSegmStartIdx = myFreeEdges->Value (aPrimitiveIdx * 2 + 1);
     Standard_Integer aSegmEndIdx = myFreeEdges->Value (aPrimitiveIdx * 2 + 2);
-    Handle(TColgp_HArray1OfPnt) anEdgePnts = new TColgp_HArray1OfPnt (1, 2);
-    gp_Pnt aSegmStart = myTriangul->Nodes().Value (aSegmStartIdx);
-    gp_Pnt aSegmEnd   = myTriangul->Nodes().Value (aSegmEndIdx);
-    anEdgePnts->SetValue (1, aSegmStart);
-    anEdgePnts->SetValue (2, aSegmEnd);
-    Standard_Boolean isMatched = theMgr.Overlaps (anEdgePnts, Select3D_TOS_BOUNDARY, theMatchDepth);
-    anEdgePnts.Nullify();
+
+    const gp_Pnt anEdgePnts[2] =
+    {
+      myTriangul->Nodes().Value (aSegmStartIdx),
+      myTriangul->Nodes().Value (aSegmEndIdx)
+    };
+    TColgp_Array1OfPnt anEdgePntsArr (anEdgePnts[0], 1, 2);
+    Standard_Boolean isMatched = theMgr.Overlaps (anEdgePntsArr, Select3D_TOS_BOUNDARY, thePickResult);
     return isMatched;
   }
   else
@@ -284,10 +284,10 @@ Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_
     const Poly_Array1OfTriangle& aTriangles = myTriangul->Triangles();
     Standard_Integer aNode1, aNode2, aNode3;
     aTriangles (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3);
-    gp_Pnt aPnt1 = myTriangul->Nodes().Value (aNode1);
-    gp_Pnt aPnt2 = myTriangul->Nodes().Value (aNode2);
-    gp_Pnt aPnt3 = myTriangul->Nodes().Value (aNode3);
-    return theMgr.Overlaps (aPnt1, aPnt2, aPnt3, Select3D_TOS_INTERIOR, theMatchDepth);
+    const gp_Pnt& aPnt1 = myTriangul->Nodes().Value (aNode1);
+    const gp_Pnt& aPnt2 = myTriangul->Nodes().Value (aNode2);
+    const gp_Pnt& aPnt3 = myTriangul->Nodes().Value (aNode3);
+    return theMgr.Overlaps (aPnt1, aPnt2, aPnt3, Select3D_TOS_INTERIOR, thePickResult);
   }
 }
 
@@ -302,23 +302,18 @@ Standard_Boolean Select3D_SensitiveTriangulation::elementIsInside (SelectBasics_
 
   if (mySensType == Select3D_TOS_BOUNDARY)
   {
-    gp_Pnt aSegmPnt1 = myTriangul->Nodes().Value (myFreeEdges->Value (aPrimitiveIdx * 2 + 1));
-    gp_Pnt aSegmPnt2 = myTriangul->Nodes().Value (myFreeEdges->Value (aPrimitiveIdx * 2 + 2));
-
+    const gp_Pnt& aSegmPnt1 = myTriangul->Nodes().Value (myFreeEdges->Value (aPrimitiveIdx * 2 + 1));
+    const gp_Pnt& aSegmPnt2 = myTriangul->Nodes().Value (myFreeEdges->Value (aPrimitiveIdx * 2 + 2));
     return theMgr.Overlaps (aSegmPnt1) && theMgr.Overlaps (aSegmPnt2);
   }
   else
   {
-    Standard_Integer aNode1;
-    Standard_Integer aNode2;
-    Standard_Integer aNode3;
-
+    Standard_Integer aNode1, aNode2, aNode3;
     myTriangul->Triangles() (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3);
 
-    gp_Pnt aPnt1 = myTriangul->Nodes().Value (aNode1);
-    gp_Pnt aPnt2 = myTriangul->Nodes().Value (aNode2);
-    gp_Pnt aPnt3 = myTriangul->Nodes().Value (aNode3);
-
+    const gp_Pnt& aPnt1 = myTriangul->Nodes().Value (aNode1);
+    const gp_Pnt& aPnt2 = myTriangul->Nodes().Value (aNode2);
+    const gp_Pnt& aPnt3 = myTriangul->Nodes().Value (aNode3);
     return theMgr.Overlaps (aPnt1)
         && theMgr.Overlaps (aPnt2)
         && theMgr.Overlaps (aPnt3);
index 7950ced..cbd7a4c 100644 (file)
@@ -104,7 +104,7 @@ private:
   //! Checks whether the element with index theIdx overlaps the current selecting volume
   virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
                                             Standard_Integer theElemIdx,
-                                            Standard_Real& theMatchDepth) Standard_OVERRIDE;
+                                            SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! Calculates distance from the 3d projection of used-picked screen point to center of the geometry
   virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
index ac12150..fd235fc 100644 (file)
@@ -114,18 +114,11 @@ void Select3D_SensitiveWire::Swap (const Standard_Integer theIdx1,
 // =======================================================================
 Standard_Boolean Select3D_SensitiveWire::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
                                                           Standard_Integer theElemIdx,
-                                                          Standard_Real& theMatchDepth)
+                                                          SelectBasics_PickResult& thePickResult)
 {
   const Standard_Integer aSensitiveIdx = myEntityIndexes.Value (theElemIdx);
   const Handle(SelectBasics_SensitiveEntity)& aSeg = myEntities.Value (aSensitiveIdx);
-  SelectBasics_PickResult aMatchResult;
-  if (aSeg->Matches (theMgr, aMatchResult))
-  {
-    theMatchDepth = aMatchResult.Depth();
-    return Standard_True;
-  }
-
-  return Standard_False;
+  return aSeg->Matches (theMgr, thePickResult);
 }
 
 // =======================================================================
index df778d0..ac85ffd 100644 (file)
@@ -75,7 +75,7 @@ protected:
   //! Checks whether the entity with index theIdx overlaps the current selecting volume
   Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
                                                             Standard_Integer theElemIdx,
-                                                            Standard_Real& theMatchDepth) Standard_OVERRIDE;
+                                                            SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! Checks whether the entity with index theIdx is inside the current selecting volume
   Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
index bf72fab..03bcc16 100644 (file)
 #include <Standard.hxx>
 #include <NCollection_Vec4.hxx>
 
-//! This structure provides unified access to the results of
-//! Matches() method in all sensitive entities.
+//! This structure provides unified access to the results of Matches() method in all sensitive entities,
+//! so that it defines a Depth (distance to the entity along picking ray) and a closest Point on entity.
 struct SelectBasics_PickResult
 {
 public:
+  //! Return closest result between two Pick Results according to Depth value.
+  static const SelectBasics_PickResult& Min (const SelectBasics_PickResult& thePickResult1,
+                                             const SelectBasics_PickResult& thePickResult2)
+  {
+    return thePickResult1.Depth() <= thePickResult2.Depth() ? thePickResult1 : thePickResult2;
+  }
 
+public:
+  //! Empty constructor defining an invalid result.
   SelectBasics_PickResult()
-  : myDepth (DBL_MAX),
-    myDistToCenter (DBL_MAX) {}
+  : myObjPickedPnt (RealLast(), 0.0, 0.0),
+    myDepth (RealLast()),
+    myDistToCenter (RealLast()) {}
 
-  SelectBasics_PickResult (const Standard_Real theDepth,
-                           const Standard_Real theDistToCenter)
-  : myDepth (theDepth),
+  //! Constructor with initialization.
+  SelectBasics_PickResult (Standard_Real theDepth,
+                           Standard_Real theDistToCenter,
+                           const gp_Pnt& theObjPickedPnt)
+  : myObjPickedPnt (theObjPickedPnt),
+    myDepth (theDepth),
     myDistToCenter (theDistToCenter) {}
 
 public:
-  inline Standard_Real Depth() const
-  {
-    return myDepth;
-  }
 
-  inline Standard_Real DistToGeomCenter() const
+  //! Return TRUE if result was been defined.
+  Standard_Boolean IsValid() const { return myDepth != RealLast(); }
+
+  //! Reset depth value.
+  void Invalidate()
   {
-    return myDistToCenter;
+    myDepth = RealLast();
+    myObjPickedPnt = gp_Pnt (RealLast(), 0.0, 0.0);
   }
 
+  //! Return depth along picking ray.
+  Standard_Real Depth() const { return myDepth; }
+
+  //! Set depth along picking ray.
+  void SetDepth (Standard_Real theDepth) { myDepth = theDepth; }
+
+  //! Return TRUE if Picked Point lying on detected entity was set.
+  Standard_Boolean HasPickedPoint() const { return myObjPickedPnt.X() != RealLast(); }
+
+  //! Return picked point lying on detected entity.
+  //! WARNING! Point is defined in local coordinate system and should be translated into World System before usage!
+  const gp_Pnt& PickedPoint() const { return myObjPickedPnt; }
+
+  //! Set picked point.
+  void SetPickedPoint (const gp_Pnt& theObjPickedPnt) { myObjPickedPnt = theObjPickedPnt; }
+
+  //! Return distance to geometry center (auxiliary value for comparing results).
+  Standard_Real DistToGeomCenter() const { return myDistToCenter; }
+
+  //! Set distance to geometry center.
+  void SetDistToGeomCenter (Standard_Real theDistToCenter) { myDistToCenter = theDistToCenter; }
+
 private:
-  //!< Depth to detected point
-  Standard_Real                   myDepth;
-  //!< Distance from 3d projection user-picked selection point to entity's geometry center
-  Standard_Real                   myDistToCenter;
+  gp_Pnt        myObjPickedPnt; //!< User-picked selection point onto object
+  Standard_Real myDepth;        //!< Depth to detected point
+  Standard_Real myDistToCenter; //!< Distance from 3d projection user-picked selection point to entity's geometry center
 };
 
 #endif // _SelectBasics_PickResult_HeaderFile
index ebbe1e8..7ebf8a6 100644 (file)
@@ -19,6 +19,7 @@
 #include <BVH_Box.hxx>
 #include <gp_Pnt.hxx>
 #include <TColgp_HArray1OfPnt.hxx>
+#include <SelectBasics_PickResult.hxx>
 
 class Bnd_Box;
 class gp_Pnt;
@@ -45,7 +46,7 @@ public:
   //! Returns true if selecting volume is overlapped by box theBox
   virtual Standard_Boolean Overlaps (const NCollection_Vec3<Standard_Real>& theBoxMin,
                                      const NCollection_Vec3<Standard_Real>& theBoxMax,
-                                     Standard_Real& theDepth) = 0;
+                                     SelectBasics_PickResult& thePickResult) = 0;
 
   //! Returns true if selecting volume is overlapped by axis-aligned bounding box with minimum
   //! corner at point theMinPt and maximum at point theMaxPt
@@ -55,7 +56,7 @@ public:
 
   //! Returns true if selecting volume is overlapped by point thePnt
   virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
-                                     Standard_Real& theDepth) = 0;
+                                     SelectBasics_PickResult& thePickResult) = 0;
 
   //! Returns true if selecting volume is overlapped by point thePnt.
   //! Does not perform depth calculation, so this method is defined as
@@ -66,19 +67,19 @@ public:
   //! are stored in theArrayOfPts, taking into account sensitivity type theSensType
   virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts,
                                      Standard_Integer theSensType,
-                                     Standard_Real& theDepth) = 0;
+                                     SelectBasics_PickResult& thePickResult) = 0;
 
   //! Returns true if selecting volume is overlapped by planar convex polygon, which points
   //! are stored in theArrayOfPts, taking into account sensitivity type theSensType
   virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPts,
                                      Standard_Integer theSensType,
-                                     Standard_Real& theDepth) = 0;
+                                     SelectBasics_PickResult& thePickResult) = 0;
 
   //! Returns true if selecting volume is overlapped by line segment with start point at thePt1
   //! and end point at thePt2
   virtual Standard_Boolean Overlaps (const gp_Pnt& thePt1,
                                      const gp_Pnt& thePt2,
-                                     Standard_Real& theDepth) = 0;
+                                     SelectBasics_PickResult& thePickResult) = 0;
 
   //! Returns true if selecting volume is overlapped by triangle with vertices thePt1,
   //! thePt2 and thePt3, taking into account sensitivity type theSensType
@@ -86,7 +87,7 @@ public:
                                      const gp_Pnt& thePt2,
                                      const gp_Pnt& thePt3,
                                      Standard_Integer theSensType,
-                                     Standard_Real& theDepth) = 0;
+                                     SelectBasics_PickResult& thePickResult) = 0;
 
   //! Calculates distance from 3d projection of user-defined selection point
   //! to the given point theCOG
index a70b9f4..d9b4484 100644 (file)
@@ -146,7 +146,7 @@ void SelectMgr_BaseFrustum::SetBuilder (const Handle(SelectMgr_FrustumBuilder)&
 //=======================================================================
 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/,
                                                   const SelectMgr_Vec3& /*theBoxMax*/,
-                                                  Standard_Real& /*theDepth*/)
+                                                  SelectBasics_PickResult& /*thePickResult*/)
 {
   return Standard_False;
 }
@@ -167,7 +167,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBox
 // purpose  : Intersection test between defined volume and given point
 //=======================================================================
 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/,
-                                                  Standard_Real& /*theDepth*/)
+                                                  SelectBasics_PickResult& )
 {
   return Standard_False;
 }
@@ -190,7 +190,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/)
 //=======================================================================
 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const TColgp_Array1OfPnt& /*theArrayOfPnts*/,
                                                   Select3D_TypeOfSensitivity /*theSensType*/,
-                                                  Standard_Real& /*theDepth*/)
+                                                  SelectBasics_PickResult& )
 {
   return Standard_False;
 }
@@ -206,7 +206,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/,
                                                   const gp_Pnt& /*thePt2*/,
                                                   const gp_Pnt& /*thePt3*/,
                                                   Select3D_TypeOfSensitivity /*theSensType*/,
-                                                  Standard_Real& /*theDepth*/)
+                                                  SelectBasics_PickResult& )
 {
   return Standard_False;
 }
@@ -217,7 +217,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/,
 //=======================================================================
 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt1*/,
                                                   const gp_Pnt& /*thePnt2*/,
-                                                  Standard_Real& /*theDepth*/)
+                                                  SelectBasics_PickResult& )
 {
   return Standard_False;
 }
index f5217bd..a7890c5 100644 (file)
@@ -33,6 +33,8 @@
 #include <Select3D_TypeOfSensitivity.hxx>
 #include <SelectMgr_VectorTypes.hxx>
 
+#include <SelectBasics_PickResult.hxx>
+
 //! This class is an interface for different types of selecting frustums,
 //! defining different selection types, like point, box or polyline
 //! selection. It contains signatures of functions for detection of
@@ -118,7 +120,7 @@ public:
   //! SAT intersection test between defined volume and given axis-aligned box
   Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin,
                                                      const SelectMgr_Vec3& theBoxMax,
-                                                     Standard_Real& theDepth);
+                                                     SelectBasics_PickResult& thePickResult);
 
   //! Returns true if selecting volume is overlapped by axis-aligned bounding box
   //! with minimum corner at point theMinPt and maximum at point theMaxPt
@@ -128,7 +130,7 @@ public:
 
   //! Intersection test between defined volume and given point
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
-                                                     Standard_Real& theDepth);
+                                                     SelectBasics_PickResult& thePickResult);
 
   //! Intersection test between defined volume and given point
   //! Does not perform depth calculation, so this method is defined as
@@ -141,12 +143,12 @@ public:
   //! boundary line defined by segments depending on given sensitivity type
   Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
                                                      Select3D_TypeOfSensitivity theSensType,
-                                                     Standard_Real& theDepth);
+                                                     SelectBasics_PickResult& thePickResult);
 
   //! Checks if line segment overlaps selecting frustum
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
                                                      const gp_Pnt& thePnt2,
-                                                     Standard_Real& theDepth);
+                                                     SelectBasics_PickResult& thePickResult);
 
   //! SAT intersection test between defined volume and given triangle. The test may
   //! be considered of interior part or boundary line defined by triangle vertices
@@ -155,7 +157,7 @@ public:
                                                      const gp_Pnt& thePt2,
                                                      const gp_Pnt& thePt3,
                                                      Select3D_TypeOfSensitivity theSensType,
-                                                     Standard_Real& theDepth);
+                                                     SelectBasics_PickResult& thePickResult);
 
   //! Measures distance between 3d projection of user-picked
   //! screen point and given point theCOG
index ccc4868..8d1b856 100644 (file)
@@ -24,7 +24,7 @@
 // =======================================================================
 void SelectMgr_RectangularFrustum::segmentSegmentDistance (const gp_Pnt& theSegPnt1,
                                                            const gp_Pnt& theSegPnt2,
-                                                           Standard_Real& theDepth)
+                                                           SelectBasics_PickResult& thePickResult)
 {
   gp_XYZ anU = theSegPnt2.XYZ() - theSegPnt1.XYZ();
   gp_XYZ aV = myViewRayDir.XYZ();
@@ -70,17 +70,32 @@ void SelectMgr_RectangularFrustum::segmentSegmentDistance (const gp_Pnt& theSegP
   }
   aTc = (Abs (aTd) < gp::Resolution() ? 0.0 : aTn / aTd);
 
-  gp_Pnt aClosestPnt = myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * aTc;
-  theDepth = myNearPickedPnt.Distance (aClosestPnt) * myScale;
+  const gp_Pnt aClosestPnt = myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * aTc;
+  thePickResult.SetDepth (myNearPickedPnt.Distance (aClosestPnt) * myScale);
+
+  const gp_Vec aPickedVec = aClosestPnt.XYZ() - theSegPnt1.XYZ();
+  const gp_Vec aFigureVec = theSegPnt2.XYZ()  - theSegPnt1.XYZ();
+  const Standard_Real aPickedVecMod = aPickedVec.Magnitude();
+  const Standard_Real aFigureVecMod = aFigureVec.Magnitude();
+  if (aPickedVecMod <= gp::Resolution()
+   || aFigureVecMod <= gp::Resolution())
+  {
+    thePickResult.SetPickedPoint (aClosestPnt);
+    return;
+  }
+
+  const Standard_Real aCosOfAngle = aFigureVec.Dot (aPickedVec) / (aPickedVecMod * aFigureVecMod);
+  const Standard_Real aSegPntShift = Min(aFigureVecMod, Max(0.0, aCosOfAngle * aPickedVecMod));
+  thePickResult.SetPickedPoint (theSegPnt1.XYZ() + aFigureVec.XYZ() * (aSegPntShift / aFigureVecMod));
 }
 
 // =======================================================================
 // function : segmentPlaneIntersection
 // purpose  :
 // =======================================================================
-void SelectMgr_RectangularFrustum::segmentPlaneIntersection (const gp_Vec& thePlane,
+bool SelectMgr_RectangularFrustum::segmentPlaneIntersection (const gp_Vec& thePlane,
                                                              const gp_Pnt& thePntOnPlane,
-                                                             Standard_Real& theDepth)
+                                                             SelectBasics_PickResult& thePickResult)
 {
   gp_XYZ anU = myViewRayDir.XYZ();
   gp_XYZ aW = myNearPickedPnt.XYZ() - thePntOnPlane.XYZ();
@@ -91,25 +106,26 @@ void SelectMgr_RectangularFrustum::segmentPlaneIntersection (const gp_Vec& thePl
   {
     if (Abs (aN) < Precision::Angular())
     {
-      theDepth = DBL_MAX;
-      return;
+      thePickResult.Invalidate();
+      return false;
     }
     else
     {
-      theDepth = DBL_MAX;
-      return;
+      thePickResult.Invalidate();
+      return false;
     }
   }
 
   Standard_Real aParam = aN / aD;
   if (aParam < 0.0 || aParam > 1.0)
   {
-    theDepth = DBL_MAX;
-    return;
+    thePickResult.Invalidate();
+    return false;
   }
 
   gp_Pnt aClosestPnt = myNearPickedPnt.XYZ() + anU * aParam;
-  theDepth = myNearPickedPnt.Distance (aClosestPnt) * myScale;
+  thePickResult.SetDepth (myNearPickedPnt.Distance (aClosestPnt) * myScale);
+  return true;
 }
 
 namespace
@@ -425,7 +441,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t
 // =======================================================================
 Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& theBoxMin,
                                                          const SelectMgr_Vec3& theBoxMax,
-                                                         Standard_Real& theDepth)
+                                                         SelectBasics_PickResult& thePickResult)
 {
   if (!hasOverlap (theBoxMin, theBoxMax))
     return Standard_False;
@@ -435,9 +451,9 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t
   aNearestPnt.SetY (Max (Min (myNearPickedPnt.Y(), theBoxMax.y()), theBoxMin.y()));
   aNearestPnt.SetZ (Max (Min (myNearPickedPnt.Z(), theBoxMax.z()), theBoxMin.z()));
 
-  theDepth = aNearestPnt.Distance (myNearPickedPnt);
+  thePickResult.SetDepth (aNearestPnt.Distance (myNearPickedPnt));
 
-  return isViewClippingOk (theDepth);
+  return isViewClippingOk (thePickResult);
 }
 
 // =======================================================================
@@ -445,7 +461,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t
 // purpose  : Intersection test between defined volume and given point
 // =======================================================================
 Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt,
-                                                         Standard_Real& theDepth)
+                                                         SelectBasics_PickResult& thePickResult)
 {
   if (!hasOverlap (thePnt))
     return Standard_False;
@@ -454,9 +470,10 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt,
   gp_Pnt aDetectedPnt =
     myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * (aV.Dot (myViewRayDir.XYZ()) / myViewRayDir.Dot (myViewRayDir));
 
-  theDepth = aDetectedPnt.Distance (myNearPickedPnt) * myScale;
+  thePickResult.SetDepth (aDetectedPnt.Distance (myNearPickedPnt) * myScale);
+  thePickResult.SetPickedPoint (thePnt);
 
-  return isViewClippingOk (theDepth);
+  return isViewClippingOk (thePickResult);
 }
 
 // =======================================================================
@@ -474,15 +491,14 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt)
 // =======================================================================
 Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
                                                          const gp_Pnt& thePnt2,
-                                                         Standard_Real& theDepth)
+                                                         SelectBasics_PickResult& thePickResult)
 {
-  theDepth = -DBL_MAX;
   if (!hasOverlap (thePnt1, thePnt2))
     return Standard_False;
 
-  segmentSegmentDistance (thePnt1, thePnt2, theDepth);
+  segmentSegmentDistance (thePnt1, thePnt2, thePickResult);
 
-  return isViewClippingOk (theDepth);
+  return isViewClippingOk (thePickResult);
 }
 
 // =======================================================================
@@ -494,12 +510,13 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
 // =======================================================================
 Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
                                                          Select3D_TypeOfSensitivity theSensType,
-                                                         Standard_Real& theDepth)
+                                                         SelectBasics_PickResult& thePickResult)
 {
   if (theSensType == Select3D_TOS_BOUNDARY)
   {
     Standard_Integer aMatchingSegmentsNb = -1;
-    theDepth = DBL_MAX;
+    SelectBasics_PickResult aPickResult;
+    thePickResult.Invalidate();
     const Standard_Integer aLower  = theArrayOfPnts.Lower();
     const Standard_Integer anUpper = theArrayOfPnts.Upper();
     for (Standard_Integer aPntIter = aLower; aPntIter <= anUpper; ++aPntIter)
@@ -509,9 +526,8 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPn
       if (hasOverlap (aStartPnt, aEndPnt))
       {
         aMatchingSegmentsNb++;
-        Standard_Real aSegmentDepth = RealLast();
-        segmentSegmentDistance (aStartPnt, aEndPnt, aSegmentDepth);
-        theDepth = Min (theDepth, aSegmentDepth);
+        segmentSegmentDistance (aStartPnt, aEndPnt, aPickResult);
+        thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
       }
     }
 
@@ -521,15 +537,16 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPn
   else if (theSensType == Select3D_TOS_INTERIOR)
   {
     gp_Vec aPolyNorm (gp_XYZ (RealLast(), RealLast(), RealLast()));
-    if (!hasOverlap (theArrayOfPnts, aPolyNorm))
+    if (!hasOverlap (theArrayOfPnts, aPolyNorm)
+     || !segmentPlaneIntersection (aPolyNorm,
+                                   theArrayOfPnts.First(),
+                                   thePickResult))
+    {
       return Standard_False;
-
-    segmentPlaneIntersection (aPolyNorm,
-                              theArrayOfPnts.Value (theArrayOfPnts.Lower()),
-                              theDepth);
+    }
   }
 
-  return isViewClippingOk (theDepth);
+  return isViewClippingOk (thePickResult);
 }
 
 // =======================================================================
@@ -543,13 +560,13 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
                                                          const gp_Pnt& thePnt2,
                                                          const gp_Pnt& thePnt3,
                                                          Select3D_TypeOfSensitivity theSensType,
-                                                         Standard_Real& theDepth)
+                                                         SelectBasics_PickResult& thePickResult)
 {
   if (theSensType == Select3D_TOS_BOUNDARY)
   {
     const gp_Pnt aPntsArrayBuf[4] = { thePnt1, thePnt2, thePnt3, thePnt1 };
     const TColgp_Array1OfPnt aPntsArray (aPntsArrayBuf[0], 1, 4);
-    return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, theDepth);
+    return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, thePickResult);
   }
   else if (theSensType == Select3D_TOS_INTERIOR)
   {
@@ -568,16 +585,15 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
       // handle degenerated triangles: in this case, there is no possible way to detect overlap correctly.
       if (aTriangleNormal.SquareMagnitude() < gp::Resolution())
       {
-        theDepth = std::numeric_limits<Standard_Real>::max();
         return Standard_False;
       }
 
       // handle the case when triangle normal and selecting frustum direction are orthogonal: for this case, overlap
       // is detected correctly, and distance to triangle's plane can be measured as distance to its arbitrary vertex.
       const gp_XYZ aDiff = myNearPickedPnt.XYZ() - thePnt1.XYZ();
-      theDepth = aTriangleNormal.Dot (aDiff) * myScale;
-
-      return isViewClippingOk (theDepth);
+      thePickResult.SetDepth (aTriangleNormal.Dot (aDiff) * myScale);
+      thePickResult.SetPickedPoint (thePnt1);
+      return isViewClippingOk (thePickResult);
     }
 
     gp_XYZ anEdge = (thePnt1.XYZ() - myNearPickedPnt.XYZ()) * (1.0 / anAlpha);
@@ -589,20 +605,18 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
     Standard_Real anU = aVec.Dot (aTrEdges[2]);
     Standard_Real aV  = aVec.Dot (aTrEdges[0]);
 
-    Standard_Boolean isInterior = (aTime >= 0.0) && (anU >= 0.0) && (aV >= 0.0) && (anU + aV <= 1.0);
-
+    const Standard_Boolean isInterior = (aTime >= 0.0) && (anU >= 0.0) && (aV >= 0.0) && (anU + aV <= 1.0);
+    const gp_Pnt aPtOnPlane = myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * aTime;
     if (isInterior)
     {
-      gp_Pnt aDetectedPnt = myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * aTime;
-      theDepth = myNearPickedPnt.Distance (aDetectedPnt) * myScale;
-
-      return isViewClippingOk (theDepth);
+      thePickResult.SetDepth (myNearPickedPnt.Distance (aPtOnPlane) * myScale);
+      thePickResult.SetPickedPoint (aPtOnPlane);
+      return isViewClippingOk (thePickResult);
     }
 
     gp_Pnt aPnts[3] = {thePnt1, thePnt2, thePnt3};
     Standard_Real aMinDist = RealLast();
     Standard_Integer aNearestEdgeIdx = -1;
-    gp_Pnt aPtOnPlane = myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * aTime;
     for (Standard_Integer anEdgeIdx = 0; anEdgeIdx < 3; ++anEdgeIdx)
     {
       gp_XYZ aW = aPtOnPlane.XYZ() - aPnts[anEdgeIdx].XYZ();
@@ -614,10 +628,10 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
         aNearestEdgeIdx = anEdgeIdx;
       }
     }
-    segmentSegmentDistance (aPnts[aNearestEdgeIdx], aPnts[(aNearestEdgeIdx + 1) % 3], theDepth);
+    segmentSegmentDistance (aPnts[aNearestEdgeIdx], aPnts[(aNearestEdgeIdx + 1) % 3], thePickResult);
   }
 
-  return isViewClippingOk (theDepth);
+  return isViewClippingOk (thePickResult);
 }
 
 // =======================================================================
@@ -757,10 +771,10 @@ void SelectMgr_RectangularFrustum::SetViewClipping (const Handle(Graphic3d_Seque
 // function : isViewClippingOk
 // purpose  :
 // =======================================================================
-Standard_Boolean SelectMgr_RectangularFrustum::isViewClippingOk (const Standard_Real theDepth) const
+Standard_Boolean SelectMgr_RectangularFrustum::isViewClippingOk (const SelectBasics_PickResult& thePickResult) const
 {
   return !myIsViewClipEnabled
-      || !myViewClipRange.IsClipped (theDepth);
+      || !myViewClipRange.IsClipped (thePickResult.Depth());
 }
 
 // =======================================================================
index 5d5713a..f2413a9 100644 (file)
@@ -59,7 +59,7 @@ public:
   //! SAT intersection test between defined volume and given axis-aligned box
   Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin,
                                                      const SelectMgr_Vec3& theBoxMax,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! Returns true if selecting volume is overlapped by axis-aligned bounding box
   //! with minimum corner at point theMinPt and maximum at point theMaxPt
@@ -69,7 +69,7 @@ public:
 
   //! Intersection test between defined volume and given point
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! Intersection test between defined volume and given point
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt) Standard_OVERRIDE;
@@ -79,12 +79,12 @@ public:
   //! boundary line defined by segments depending on given sensitivity type
   Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
                                                      Select3D_TypeOfSensitivity theSensType,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! Checks if line segment overlaps selecting frustum
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
                                                      const gp_Pnt& thePnt2,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! SAT intersection test between defined volume and given triangle. The test may
   //! be considered of interior part or boundary line defined by triangle vertices
@@ -93,7 +93,7 @@ public:
                                                      const gp_Pnt& thePnt2,
                                                      const gp_Pnt& thePnt3,
                                                      Select3D_TypeOfSensitivity theSensType,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! Measures distance between 3d projection of user-picked
   //! screen point and given point theCOG
@@ -141,18 +141,18 @@ protected:
 
   Standard_EXPORT void segmentSegmentDistance (const gp_Pnt& theSegPnt1,
                                                const gp_Pnt& theSegPnt2,
-                                               Standard_Real& theDepth);
+                                               SelectBasics_PickResult& thePickResult);
 
-  Standard_EXPORT void segmentPlaneIntersection (const gp_Vec& thePlane,
+  Standard_EXPORT bool segmentPlaneIntersection (const gp_Vec& thePlane,
                                                  const gp_Pnt& thePntOnPlane,
-                                                 Standard_Real& theDepth);
+                                                 SelectBasics_PickResult& thePickResult);
 
   //! Computes valid depth range for the given clipping planes
   Standard_EXPORT void computeClippingRange (const Graphic3d_SequenceOfHClipPlane& thePlanes,
                                              SelectMgr_ViewClipRange& theRange);
 
   //! Returns false if theDepth must be clipped by current view clip range
-  Standard_EXPORT Standard_Boolean isViewClippingOk (const Standard_Real theDepth) const;
+  Standard_EXPORT Standard_Boolean isViewClippingOk (const SelectBasics_PickResult& thePickResult) const;
 
 private:
 
index 6c5348c..879a632 100644 (file)
@@ -236,12 +236,12 @@ void SelectMgr_SelectingVolumeManager::BuildSelectingVolume (const TColgp_Array1
 //=======================================================================
 Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const SelectMgr_Vec3& theBoxMin,
                                                              const SelectMgr_Vec3& theBoxMax,
-                                                             Standard_Real& theDepth)
+                                                             SelectBasics_PickResult& thePickResult)
 {
   if (myActiveSelectionType == Unknown)
     return Standard_False;
 
-  return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theBoxMin, theBoxMax, theDepth);
+  return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theBoxMin, theBoxMax, thePickResult);
 }
 
 //=======================================================================
@@ -263,13 +263,13 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const SelectMgr_Vec
 // purpose  : Intersection test between defined volume and given point
 //=======================================================================
 Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePnt,
-                                                             Standard_Real& theDepth)
+                                                             SelectBasics_PickResult& thePickResult)
 {
   if (myActiveSelectionType == Unknown)
     return Standard_False;
 
   return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePnt,
-                                                                  theDepth);
+                                                                  thePickResult);
 }
 
 //=======================================================================
@@ -293,14 +293,14 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePn
 //=======================================================================
 Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
                                                              Standard_Integer theSensType,
-                                                             Standard_Real& theDepth)
+                                                             SelectBasics_PickResult& thePickResult)
 {
   if (myActiveSelectionType == Unknown)
     return Standard_False;
 
   return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts->Array1(),
                                                                   (Select3D_TypeOfSensitivity)theSensType,
-                                                                  theDepth);
+                                                                  thePickResult);
 }
 
 //=======================================================================
@@ -312,14 +312,14 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const Handle(TColgp
 //=======================================================================
 Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
                                                              Standard_Integer theSensType,
-                                                             Standard_Real& theDepth)
+                                                             SelectBasics_PickResult& thePickResult)
 {
   if (myActiveSelectionType == Unknown)
     return Standard_False;
 
   return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts,
                                                                   (Select3D_TypeOfSensitivity)theSensType,
-                                                                  theDepth);
+                                                                  thePickResult);
 }
 
 //=======================================================================
@@ -328,12 +328,12 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const TColgp_Array1
 //=======================================================================
 Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePt1,
                                                              const gp_Pnt& thePt2,
-                                                             Standard_Real& theDepth)
+                                                             SelectBasics_PickResult& thePickResult)
 {
   if (myActiveSelectionType == Unknown)
     return Standard_False;
 
-  return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePt1, thePt2, theDepth);
+  return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePt1, thePt2, thePickResult);
 }
 
 //=======================================================================
@@ -347,7 +347,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePt
                                                              const gp_Pnt& thePt2,
                                                              const gp_Pnt& thePt3,
                                                              Standard_Integer theSensType,
-                                                             Standard_Real& theDepth)
+                                                             SelectBasics_PickResult& thePickResult)
 {
   if (myActiveSelectionType == Unknown)
     return Standard_False;
@@ -356,7 +356,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePt
                                                                   thePt2,
                                                                   thePt3,
                                                                   (Select3D_TypeOfSensitivity)theSensType,
-                                                                  theDepth);
+                                                                  thePickResult);
 }
 
 //=======================================================================
index 95bb8f6..263ba50 100644 (file)
@@ -105,8 +105,8 @@ public:
 
   //! SAT intersection test between defined volume and given axis-aligned box
   Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin,
-                                                      const SelectMgr_Vec3& theBoxMax,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     const SelectMgr_Vec3& theBoxMax,
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! Returns true if selecting volume is overlapped by axis-aligned bounding box
   //! with minimum corner at point theMinPt and maximum at point theMaxPt
@@ -116,7 +116,7 @@ public:
 
   //! Intersection test between defined volume and given point
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! Intersection test between defined volume and given point
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt) Standard_OVERRIDE;
@@ -126,19 +126,19 @@ public:
   //! boundary line defined by segments depending on given sensitivity type
   Standard_EXPORT virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts,
                                                      Standard_Integer theSensType,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! SAT intersection test between defined volume and given ordered set of points,
   //! representing line segments. The test may be considered of interior part or
   //! boundary line defined by segments depending on given sensitivity type
   Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPts,
                                                      Standard_Integer theSensType,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! Checks if line segment overlaps selecting frustum
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
                                                      const gp_Pnt& thePnt2,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! SAT intersection test between defined volume and given triangle. The test may
   //! be considered of interior part or boundary line defined by triangle vertices
@@ -147,7 +147,7 @@ public:
                                                       const gp_Pnt& thePnt2,
                                                       const gp_Pnt& thePnt3,
                                                       Standard_Integer theSensType,
-                                                      Standard_Real& theDepth) Standard_OVERRIDE;
+                                                      SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
 
   //! Measures distance between 3d projection of user-picked
index 9a0bc83..488ed90 100644 (file)
@@ -169,7 +169,7 @@ Handle(SelectMgr_BaseFrustum) SelectMgr_TriangularFrustum::ScaleAndTransform (co
 //=======================================================================
 Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const SelectMgr_Vec3& theMinPt,
                                                         const SelectMgr_Vec3& theMaxPt,
-                                                        Standard_Real& /*theDepth*/)
+                                                        SelectBasics_PickResult& /*thePickResult*/)
 {
   return hasOverlap (theMinPt, theMaxPt);
 }
@@ -192,7 +192,7 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const SelectMgr_Vec3& th
 // purpose  : Intersection test between defined volume and given point
 // =======================================================================
 Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt,
-                                                        Standard_Real& /*theDepth*/)
+                                                        SelectBasics_PickResult& /*thePickResult*/)
 {
   return hasOverlap (thePnt);
 }
@@ -206,7 +206,7 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt,
 // =======================================================================
 Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
                                                         Select3D_TypeOfSensitivity theSensType,
-                                                        Standard_Real& /*theDepth*/)
+                                                        SelectBasics_PickResult& /*thePickResult*/)
 {
   if (theSensType == Select3D_TOS_BOUNDARY)
   {
@@ -237,7 +237,7 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const TColgp_Array1OfPnt
 // =======================================================================
 Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt1,
                                                         const gp_Pnt& thePnt2,
-                                                        Standard_Real& /*theDepth*/)
+                                                        SelectBasics_PickResult& /*thePickResult*/)
 {
   return hasOverlap (thePnt1, thePnt2);
 }
@@ -253,13 +253,13 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt1,
                                                         const gp_Pnt& thePnt2,
                                                         const gp_Pnt& thePnt3,
                                                         Select3D_TypeOfSensitivity theSensType,
-                                                        Standard_Real& theDepth)
+                                                        SelectBasics_PickResult& thePickResult)
 {
   if (theSensType == Select3D_TOS_BOUNDARY)
   {
     const gp_Pnt aPntsArrayBuf[3] = { thePnt1, thePnt2, thePnt3 };
     const TColgp_Array1OfPnt aPntsArray (aPntsArrayBuf[0], 1, 3);
-    return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, theDepth);
+    return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, thePickResult);
   }
   else if (theSensType == Select3D_TOS_INTERIOR)
   {
index c7851cc..8be66c0 100644 (file)
@@ -48,7 +48,7 @@ public:
   //! SAT intersection test between defined volume and given axis-aligned box
   Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt,
                                                      const SelectMgr_Vec3& theMaxPnt,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! Returns true if selecting volume is overlapped by axis-aligned bounding box
   //! with minimum corner at point theMinPt and maximum at point theMaxPt
@@ -58,19 +58,19 @@ public:
 
   //! Intersection test between defined volume and given point
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! SAT intersection test between defined volume and given ordered set of points,
   //! representing line segments. The test may be considered of interior part or
   //! boundary line defined by segments depending on given sensitivity type
   Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
                                                      Select3D_TypeOfSensitivity theSensType,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! Checks if line segment overlaps selecting frustum
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
                                                      const gp_Pnt& thePnt2,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! SAT intersection test between defined volume and given triangle. The test may
   //! be considered of interior part or boundary line defined by triangle vertices
@@ -79,7 +79,7 @@ public:
                                                      const gp_Pnt& thePnt2,
                                                      const gp_Pnt& thePnt3,
                                                      Select3D_TypeOfSensitivity theSensType,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! Nullifies the handle to corresponding builder instance to prevent memory leaks
   Standard_EXPORT void Clear();
index 87f7a47..c9cdf2e 100644 (file)
@@ -127,11 +127,11 @@ Handle(SelectMgr_BaseFrustum) SelectMgr_TriangularFrustumSet::ScaleAndTransform
 // =======================================================================
 Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const SelectMgr_Vec3& theMinPnt,
                                                            const SelectMgr_Vec3& theMaxPnt,
-                                                           Standard_Real& theDepth)
+                                                           SelectBasics_PickResult& thePickResult)
 {
   for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
   {
-    if (anIter.Value()->Overlaps (theMinPnt, theMaxPnt, theDepth))
+    if (anIter.Value()->Overlaps (theMinPnt, theMaxPnt, thePickResult))
       return Standard_True;
   }
 
@@ -160,11 +160,11 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const SelectMgr_Vec3&
 // purpose  :
 // =======================================================================
 Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt,
-                                                           Standard_Real& theDepth)
+                                                           SelectBasics_PickResult& thePickResult)
 {
   for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
   {
-    if (anIter.Value()->Overlaps (thePnt, theDepth))
+    if (anIter.Value()->Overlaps (thePnt, thePickResult))
       return Standard_True;
   }
 
@@ -177,11 +177,11 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt,
 // =======================================================================
 Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const TColgp_Array1OfPnt& theArrayOfPts,
                                                            Select3D_TypeOfSensitivity theSensType,
-                                                           Standard_Real& theDepth)
+                                                           SelectBasics_PickResult& thePickResult)
 {
   for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
   {
-    if (anIter.Value()->Overlaps (theArrayOfPts, theSensType, theDepth))
+    if (anIter.Value()->Overlaps (theArrayOfPts, theSensType, thePickResult))
       return Standard_True;
   }
 
@@ -194,11 +194,11 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const TColgp_Array1Of
 // =======================================================================
 Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt1,
                                                            const gp_Pnt& thePnt2,
-                                                           Standard_Real& theDepth)
+                                                           SelectBasics_PickResult& thePickResult)
 {
   for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
   {
-    if (anIter.Value()->Overlaps (thePnt1, thePnt2, theDepth))
+    if (anIter.Value()->Overlaps (thePnt1, thePnt2, thePickResult))
       return Standard_True;
   }
 
@@ -213,11 +213,11 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt1
                                                            const gp_Pnt& thePnt2,
                                                            const gp_Pnt& thePnt3,
                                                            Select3D_TypeOfSensitivity theSensType,
-                                                           Standard_Real& theDepth)
+                                                           SelectBasics_PickResult& thePickResult)
 {
   for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
   {
-    if (anIter.Value()->Overlaps (thePnt1, thePnt2, thePnt3, theSensType, theDepth))
+    if (anIter.Value()->Overlaps (thePnt1, thePnt2, thePnt3, theSensType, thePickResult))
       return Standard_True;
   }
 
index a28baf9..b3d5320 100644 (file)
@@ -52,28 +52,28 @@ public:
 
   Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt,
                                                      const SelectMgr_Vec3& theMaxPnt,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt,
                                                      const SelectMgr_Vec3& theMaxPnt,
                                                      Standard_Boolean* theInside) Standard_OVERRIDE;
 
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
                                                      Select3D_TypeOfSensitivity theSensType,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
                                                      const gp_Pnt& thePnt2,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
                                                      const gp_Pnt& thePnt2,
                                                      const gp_Pnt& thePnt3,
                                                      Select3D_TypeOfSensitivity theSensType,
-                                                     Standard_Real& theDepth) Standard_OVERRIDE;
+                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
 
   //! Stores plane equation coefficients (in the following form:
   //! Ax + By + Cz + D = 0) to the given vector
index 4bfe074..9dbc9f6 100644 (file)
@@ -67,6 +67,7 @@ namespace {
 // purpose  :
 //=======================================================================
 void SelectMgr_ViewerSelector::updatePoint3d (SelectMgr_SortCriterion& theCriterion,
+                                              const SelectBasics_PickResult& thePickResult,
                                               const Handle(SelectBasics_SensitiveEntity)& theEntity,
                                               const gp_GTrsf& theInversedTrsf,
                                               const SelectMgr_SelectingVolumeManager& theMgr) const
@@ -76,7 +77,15 @@ void SelectMgr_ViewerSelector::updatePoint3d (SelectMgr_SortCriterion& theCriter
     return;
   }
 
-  theCriterion.Point = theMgr.DetectedPoint (theCriterion.Depth);
+  if (thePickResult.HasPickedPoint())
+  {
+    theCriterion.Point = thePickResult.PickedPoint();
+  }
+  else
+  {
+    theCriterion.Point = theMgr.DetectedPoint (theCriterion.Depth);
+  }
+
   gp_GTrsf anInvTrsf = theInversedTrsf;
   if (theCriterion.Entity->HasInitLocation())
   {
@@ -277,7 +286,7 @@ void SelectMgr_ViewerSelector::checkOverlap (const Handle(SelectBasics_Sensitive
     {
       if (aCriterion > *aPrevCriterion)
       {
-        updatePoint3d (aCriterion, theEntity, theInversedTrsf, theMgr);
+        updatePoint3d (aCriterion, aPickResult, theEntity, theInversedTrsf, theMgr);
         *aPrevCriterion = aCriterion;
       }
     }
@@ -285,7 +294,7 @@ void SelectMgr_ViewerSelector::checkOverlap (const Handle(SelectBasics_Sensitive
   else
   {
     aCriterion.NbOwnerMatches = 1;
-    updatePoint3d (aCriterion, theEntity, theInversedTrsf, theMgr);
+    updatePoint3d (aCriterion, aPickResult, theEntity, theInversedTrsf, theMgr);
     mystored.Add (anOwner, aCriterion);
   }
 }
index 275e2e9..7869162 100644 (file)
@@ -326,6 +326,7 @@ private: // implementation of deprecated methods
 
   //! Compute 3d position for detected entity.
   void updatePoint3d (SelectMgr_SortCriterion& theCriterion,
+                      const SelectBasics_PickResult& thePickResult,
                       const Handle(SelectBasics_SensitiveEntity)& theEntity,
                       const gp_GTrsf& theInversedTrsf,
                       const SelectMgr_SelectingVolumeManager& theMgr) const;
diff --git a/tests/bugs/vis/bug29938 b/tests/bugs/vis/bug29938
new file mode 100644 (file)
index 0000000..3a91311
--- /dev/null
@@ -0,0 +1,50 @@
+puts "============"
+puts "0029938: Visualization - SelectMgr_ViewerSelector::PickedPoint() should return point lying on an object"
+puts "============"
+puts ""
+
+pload MODELING VISUALIZATION
+box b 1 2 3
+vcaps -core
+vclear
+vinit View1
+vaxo
+vdisplay -dispMode 1 -mutable b
+vfit
+vrotate 0.2 0.0 0.0
+vselmode 0 off
+
+#Check Vertex selection mode case
+vselmode 1 on
+vmoveto 337 45
+set pnt "1 2 3"
+set exp {Point: ([-0-9.+eE]+) ([-0-9.+eE]+) ([-0-9.+eE]+)}
+set match [regexp -all -inline $exp [vstate -entities]]
+foreach {_ x y z} $match {
+  if {$pnt != "$x $y $z"} {
+    puts "Error: Calculate point ($x $y $z) is not equal to target ($pnt)" }
+}
+
+#Check Wire selection mode case
+vselmode 1 off
+vselmode 2 on
+vmoveto 295 317
+set pnt "1 2 0"
+set exp {Point: ([-0-9.+eE]+) ([-0-9.+eE]+) ([-0-9.+eE]+)}
+set match [regexp -all -inline $exp [vstate -entities]]
+foreach {_ x y z} $match {
+  if {$pnt != "$x $y $z"} {
+    puts "Error: Calculate point ($x $y $z) is not equal to target ($pnt)" }
+}
+
+#Check Face selection mode case
+vselmode 2 off
+vselmode 4 on
+vmoveto 284 324
+set pnt "1 1.8383 0"
+set exp {Point: ([-0-9.+eE]+) ([-0-9.+eE]+) ([-0-9.+eE]+)}
+set match [regexp -all -inline $exp [vstate -entities]]
+foreach {_ x y z} $match {
+  if {$pnt != "$x $y $z"} {
+    puts "Error: Calculate point ($x $y $z) is not equal to target ($pnt)" }
+}