0030906: Visualization, SelectMgr_ViewerSelector - Object clipping planes overrides...
authorkgv <kgv@opencascade.com>
Tue, 20 Aug 2019 13:28:33 +0000 (16:28 +0300)
committerapn <apn@opencascade.com>
Fri, 23 Aug 2019 13:56:37 +0000 (16:56 +0300)
Clipping range has been moved from SelectMgr_RectangularFrustum to SelectMgr_SelectingVolumeManager
and passed to frustum as an argument to Overlap() methods.
This fixes an issue when Clipping is customized per-object within SelectMgr_ViewerSelector::traverseObject()
in case when shallow copy of SelectMgr_SelectingVolumeManager is created
(frustums are copied from global frustum manager by Handle).

15 files changed:
src/SelectMgr/FILES
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_ViewClipRange.cxx [new file with mode: 0644]
src/SelectMgr/SelectMgr_ViewClipRange.hxx
src/SelectMgr/SelectMgr_ViewerSelector.cxx
tests/bugs/vis/bug30906 [new file with mode: 0644]

index 767862f..1978fa8 100755 (executable)
@@ -51,6 +51,7 @@ SelectMgr_TriangularFrustumSet.hxx
 SelectMgr_TypeOfBVHUpdate.hxx
 SelectMgr_TypeOfUpdate.hxx
 SelectMgr_VectorTypes.hxx
+SelectMgr_ViewClipRange.cxx
 SelectMgr_ViewClipRange.hxx
 SelectMgr_ViewerSelector.cxx
 SelectMgr_ViewerSelector.hxx
index e2924dd..f01a825 100644 (file)
@@ -146,6 +146,7 @@ void SelectMgr_BaseFrustum::SetBuilder (const Handle(SelectMgr_FrustumBuilder)&
 //=======================================================================
 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/,
                                                   const SelectMgr_Vec3& /*theBoxMax*/,
+                                                  const SelectMgr_ViewClipRange& /*theClipRange*/,
                                                   SelectBasics_PickResult& /*thePickResult*/) const
 {
   return Standard_False;
@@ -167,6 +168,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*/,
+                                                  const SelectMgr_ViewClipRange& /*theClipRange*/,
                                                   SelectBasics_PickResult& ) const
 {
   return Standard_False;
@@ -190,6 +192,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/) cons
 //=======================================================================
 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const TColgp_Array1OfPnt& /*theArrayOfPnts*/,
                                                   Select3D_TypeOfSensitivity /*theSensType*/,
+                                                  const SelectMgr_ViewClipRange& /*theClipRange*/,
                                                   SelectBasics_PickResult& ) const
 {
   return Standard_False;
@@ -206,6 +209,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/,
                                                   const gp_Pnt& /*thePt2*/,
                                                   const gp_Pnt& /*thePt3*/,
                                                   Select3D_TypeOfSensitivity /*theSensType*/,
+                                                  const SelectMgr_ViewClipRange& /*theClipRange*/,
                                                   SelectBasics_PickResult& ) const
 {
   return Standard_False;
@@ -217,6 +221,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/,
 //=======================================================================
 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt1*/,
                                                   const gp_Pnt& /*thePnt2*/,
+                                                  const SelectMgr_ViewClipRange& /*theClipRange*/,
                                                   SelectBasics_PickResult& ) const
 {
   return Standard_False;
index 1e07c94..9506220 100644 (file)
 #define _SelectMgr_BaseFrustum_HeaderFile
 
 #include <gp_GTrsf.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Pln.hxx>
-
 #include <Graphic3d_Camera.hxx>
-#include <Graphic3d_ClipPlane.hxx>
-#include <Graphic3d_SequenceOfHClipPlane.hxx>
 #include <Graphic3d_WorldViewProjState.hxx>
-
-#include <TColgp_HArray1OfPnt.hxx>
-#include <TColgp_Array1OfPnt2d.hxx>
-
 #include <Select3D_BndBox3d.hxx>
-#include <SelectMgr_FrustumBuilder.hxx>
 #include <Select3D_TypeOfSensitivity.hxx>
+#include <SelectMgr_FrustumBuilder.hxx>
 #include <SelectMgr_VectorTypes.hxx>
-
+#include <SelectMgr_ViewClipRange.hxx>
 #include <SelectBasics_PickResult.hxx>
+#include <TColgp_Array1OfPnt.hxx>
+#include <TColgp_Array1OfPnt2d.hxx>
 
 //! This class is an interface for different types of selecting frustums,
 //! defining different selection types, like point, box or polyline
@@ -120,6 +113,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,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const;
 
   //! Returns true if selecting volume is overlapped by axis-aligned bounding box
@@ -130,6 +124,7 @@ public:
 
   //! Intersection test between defined volume and given point
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const;
 
   //! Intersection test between defined volume and given point
@@ -143,11 +138,13 @@ public:
   //! boundary line defined by segments depending on given sensitivity type
   Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
                                                      Select3D_TypeOfSensitivity theSensType,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const;
 
   //! Checks if line segment overlaps selecting frustum
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
                                                      const gp_Pnt& thePnt2,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const;
 
   //! SAT intersection test between defined volume and given triangle. The test may
@@ -157,6 +154,7 @@ public:
                                                      const gp_Pnt& thePt2,
                                                      const gp_Pnt& thePt3,
                                                      Select3D_TypeOfSensitivity theSensType,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const;
 
   //! Measures distance between 3d projection of user-picked
@@ -165,17 +163,6 @@ public:
 
   Standard_EXPORT virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const;
 
-  //! Valid for point selection only!
-  //! Computes depth range for clipping planes.
-  //! @param theViewPlanes global view planes
-  //! @param theObjPlanes  object planes
-  virtual void SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& theViewPlanes,
-                                const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes)
-  {
-    (void )theViewPlanes;
-    (void )theObjPlanes;
-  }
-
   //! Stores plane equation coefficients (in the following form:
   //! Ax + By + Cz + D = 0) to the given vector
   virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const
index e600e97..a89e7f3 100644 (file)
@@ -342,8 +342,6 @@ void SelectMgr_RectangularFrustum::Build (const gp_Pnt2d &thePoint)
   // {i, j, k} vectors and store them to corresponding class fields
   cacheVertexProjections (this);
 
-  myViewClipRange.SetVoid();
-
   myScale = 1.0;
 }
 
@@ -372,8 +370,6 @@ void SelectMgr_RectangularFrustum::Build (const gp_Pnt2d& theMinPnt,
   // {i, j, k} vectors and store them to corresponding class fields
   cacheVertexProjections (this);
 
-  myViewClipRange.SetVoid();
-
   myScale = 1.0;
 }
 
@@ -464,8 +460,7 @@ Handle(SelectMgr_BaseFrustum) SelectMgr_RectangularFrustum::ScaleAndTransform (c
 
   cacheVertexProjections (aRes.get());
 
-  aRes->myViewClipRange = myViewClipRange;
-  aRes->myMousePos      = myMousePos;
+  aRes->myMousePos = myMousePos;
 
   return aRes;
 }
@@ -490,6 +485,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t
 // =======================================================================
 Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& theBoxMin,
                                                          const SelectMgr_Vec3& theBoxMax,
+                                                         const SelectMgr_ViewClipRange& theClipRange,
                                                          SelectBasics_PickResult& thePickResult) const
 {
   if (!hasOverlap (theBoxMin, theBoxMax))
@@ -512,10 +508,10 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t
 
     aDepth = aNearestPnt.Distance (myNearPickedPnt);
     thePickResult.SetDepth (aDepth);
-    return isViewClippingOk (thePickResult);
+    return !theClipRange.IsClipped (thePickResult.Depth());
   }
 
-  if (!myViewClipRange.GetNearestDepth (aRange, aDepth))
+  if (!theClipRange.GetNearestDepth (aRange, aDepth))
   {
     return Standard_False;
   }
@@ -530,6 +526,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,
+                                                         const SelectMgr_ViewClipRange& theClipRange,
                                                          SelectBasics_PickResult& thePickResult) const
 {
   if (!hasOverlap (thePnt))
@@ -542,7 +539,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt,
   thePickResult.SetDepth (aDetectedPnt.Distance (myNearPickedPnt) * myScale);
   thePickResult.SetPickedPoint (thePnt);
 
-  return isViewClippingOk (thePickResult);
+  return !theClipRange.IsClipped (thePickResult.Depth());
 }
 
 // =======================================================================
@@ -560,6 +557,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt) c
 // =======================================================================
 Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
                                                          const gp_Pnt& thePnt2,
+                                                         const SelectMgr_ViewClipRange& theClipRange,
                                                          SelectBasics_PickResult& thePickResult) const
 {
   if (!hasOverlap (thePnt1, thePnt2))
@@ -567,7 +565,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
 
   segmentSegmentDistance (thePnt1, thePnt2, thePickResult);
 
-  return isViewClippingOk (thePickResult);
+  return !theClipRange.IsClipped (thePickResult.Depth());
 }
 
 // =======================================================================
@@ -579,6 +577,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
 // =======================================================================
 Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
                                                          Select3D_TypeOfSensitivity theSensType,
+                                                         const SelectMgr_ViewClipRange& theClipRange,
                                                          SelectBasics_PickResult& thePickResult) const
 {
   if (theSensType == Select3D_TOS_BOUNDARY)
@@ -614,7 +613,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPn
     if (aPolyNorm.Magnitude() <= Precision::Confusion())
     {
       // treat degenerated polygon as point
-      return Overlaps (theArrayOfPnts.First(), thePickResult);
+      return Overlaps (theArrayOfPnts.First(), theClipRange, thePickResult);
     }
     else if (!segmentPlaneIntersection (aPolyNorm, theArrayOfPnts.First(), thePickResult))
     {
@@ -622,7 +621,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPn
     }
   }
 
-  return isViewClippingOk (thePickResult);
+  return !theClipRange.IsClipped (thePickResult.Depth());
 }
 
 // =======================================================================
@@ -636,13 +635,14 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
                                                          const gp_Pnt& thePnt2,
                                                          const gp_Pnt& thePnt3,
                                                          Select3D_TypeOfSensitivity theSensType,
+                                                         const SelectMgr_ViewClipRange& theClipRange,
                                                          SelectBasics_PickResult& thePickResult) const
 {
   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, thePickResult);
+    return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, theClipRange, thePickResult);
   }
   else if (theSensType == Select3D_TOS_INTERIOR)
   {
@@ -669,7 +669,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
       const gp_XYZ aDiff = myNearPickedPnt.XYZ() - thePnt1.XYZ();
       thePickResult.SetDepth (aTriangleNormal.Dot (aDiff) * myScale);
       thePickResult.SetPickedPoint (thePnt1);
-      return isViewClippingOk (thePickResult);
+      return !theClipRange.IsClipped (thePickResult.Depth());
     }
 
     gp_XYZ anEdge = (thePnt1.XYZ() - myNearPickedPnt.XYZ()) * (1.0 / anAlpha);
@@ -687,7 +687,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
     {
       thePickResult.SetDepth (myNearPickedPnt.Distance (aPtOnPlane) * myScale);
       thePickResult.SetPickedPoint (aPtOnPlane);
-      return isViewClippingOk (thePickResult);
+      return !theClipRange.IsClipped (thePickResult.Depth());
     }
 
     gp_Pnt aPnts[3] = {thePnt1, thePnt2, thePnt3};
@@ -707,7 +707,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
     segmentSegmentDistance (aPnts[aNearestEdgeIdx], aPnts[(aNearestEdgeIdx + 1) % 3], thePickResult);
   }
 
-  return isViewClippingOk (thePickResult);
+  return !theClipRange.IsClipped (thePickResult.Depth());
 }
 
 // =======================================================================
@@ -731,119 +731,6 @@ gp_Pnt SelectMgr_RectangularFrustum::DetectedPoint (const Standard_Real theDepth
 }
 
 // =======================================================================
-// function : computeClippingRange
-// purpose  :
-// =======================================================================
-void SelectMgr_RectangularFrustum::computeClippingRange (const Graphic3d_SequenceOfHClipPlane& thePlanes,
-                                                         SelectMgr_ViewClipRange& theRange) const
-{
-  Standard_Real aPlaneA, aPlaneB, aPlaneC, aPlaneD;
-  for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (thePlanes); aPlaneIt.More(); aPlaneIt.Next())
-  {
-    const Handle(Graphic3d_ClipPlane)& aClipPlane = aPlaneIt.Value();
-    if (!aClipPlane->IsOn())
-    {
-      continue;
-    }
-
-    Bnd_Range aSubRange (RealFirst(), RealLast());
-    for (const Graphic3d_ClipPlane* aSubPlaneIter = aClipPlane.get(); aSubPlaneIter != NULL; aSubPlaneIter = aSubPlaneIter->ChainNextPlane().get())
-    {
-      const gp_Pln aGeomPlane = aSubPlaneIter->ToPlane();
-      aGeomPlane.Coefficients (aPlaneA, aPlaneB, aPlaneC, aPlaneD);
-
-      const gp_XYZ& aPlaneDirXYZ = aGeomPlane.Axis().Direction().XYZ();
-      Standard_Real aDotProduct = myViewRayDir.XYZ().Dot (aPlaneDirXYZ);
-      Standard_Real aDistance   = -myNearPickedPnt.XYZ().Dot (aPlaneDirXYZ) - aPlaneD;
-      Standard_Real aDistToPln  = 0.0;
-
-      // check whether the pick line is parallel to clip plane
-      if (Abs (aDotProduct) < Precision::Angular())
-      {
-        if (aDistance < 0.0)
-        {
-          continue;
-        }
-        aDistToPln  = RealLast();
-        aDotProduct = 1.0;
-      }
-      else
-      {
-        // compute distance to point of pick line intersection with the plane
-        const Standard_Real aParam = aDistance / aDotProduct;
-
-        const gp_Pnt anIntersectionPnt = myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * aParam;
-        aDistToPln = anIntersectionPnt.Distance (myNearPickedPnt);
-        if (aParam < 0.0)
-        {
-          // the plane is "behind" the ray
-          aDistToPln = -aDistToPln;
-        }
-      }
-
-      // change depth limits for case of opposite and directed planes
-      if (!aClipPlane->IsChain())
-      {
-        if (aDotProduct < 0.0)
-        {
-          theRange.ChangeUnclipRange().TrimTo (aDistToPln);
-        }
-        else
-        {
-          theRange.ChangeUnclipRange().TrimFrom (aDistToPln);
-        }
-      }
-      else
-      {
-        if (aDotProduct < 0.0)
-        {
-          aSubRange.TrimFrom (aDistToPln);
-        }
-        else
-        {
-          aSubRange.TrimTo (aDistToPln);
-        }
-      }
-    }
-
-    if (!aSubRange.IsVoid()
-      && aClipPlane->IsChain())
-    {
-      theRange.AddClipSubRange (aSubRange);
-    }
-  }
-}
-
-// =======================================================================
-// function : SetViewClipping
-// purpose  :
-// =======================================================================
-void SelectMgr_RectangularFrustum::SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& theViewPlanes,
-                                                    const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes)
-{
-  myViewClipRange.SetVoid();
-  if (!theViewPlanes.IsNull()
-   && !theViewPlanes->IsEmpty())
-  {
-    computeClippingRange (*theViewPlanes, myViewClipRange);
-  }
-  if (!theObjPlanes.IsNull()
-   && !theObjPlanes->IsEmpty())
-  {
-    computeClippingRange (*theObjPlanes, myViewClipRange);
-  }
-}
-
-// =======================================================================
-// function : isViewClippingOk
-// purpose  :
-// =======================================================================
-Standard_Boolean SelectMgr_RectangularFrustum::isViewClippingOk (const SelectBasics_PickResult& thePickResult) const
-{
-  return !myViewClipRange.IsClipped (thePickResult.Depth());
-}
-
-// =======================================================================
 // function : GetPlanes
 // purpose  :
 // =======================================================================
index 3d8ad31..8141140 100644 (file)
@@ -17,7 +17,6 @@
 #define _SelectMgr_RectangularFrustum_HeaderFile
 
 #include <SelectMgr_Frustum.hxx>
-#include <SelectMgr_ViewClipRange.hxx>
 
 //! This class contains representation of rectangular selecting frustum, created in case
 //! of point and box selection, and algorithms for overlap detection between selecting
@@ -59,6 +58,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,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
 
   //! Returns true if selecting volume is overlapped by axis-aligned bounding box
@@ -69,6 +69,7 @@ public:
 
   //! Intersection test between defined volume and given point
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
 
   //! Intersection test between defined volume and given point
@@ -79,11 +80,13 @@ public:
   //! boundary line defined by segments depending on given sensitivity type
   Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
                                                      Select3D_TypeOfSensitivity theSensType,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
 
   //! Checks if line segment overlaps selecting frustum
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
                                                      const gp_Pnt& thePnt2,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
 
   //! SAT intersection test between defined volume and given triangle. The test may
@@ -93,6 +96,7 @@ public:
                                                      const gp_Pnt& thePnt2,
                                                      const gp_Pnt& thePnt3,
                                                      Select3D_TypeOfSensitivity theSensType,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
 
   //! Measures distance between 3d projection of user-picked
@@ -102,19 +106,6 @@ public:
   //! Calculates the point on a view ray that was detected during the run of selection algo by given depth
   Standard_EXPORT virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const Standard_OVERRIDE;
 
-  //! Valid for point selection only!
-  //! Computes depth range for clipping planes.
-  //! @param theViewPlanes global view planes
-  //! @param theObjPlanes  object planes
-  Standard_EXPORT virtual void SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& theViewPlanes,
-                                                const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes) Standard_OVERRIDE;
-
-  //! Return clipping range.
-  const SelectMgr_ViewClipRange& ViewClipRanges() const { return myViewClipRange; }
-
-  //! Set clipping range.
-  void SetViewClipRanges (const SelectMgr_ViewClipRange& theRange) { myViewClipRange = theRange; }
-
   //! A set of helper functions that return rectangular selecting frustum data
   inline const gp_Pnt* GetVertices() const { return myVertices; }
 
@@ -128,6 +119,9 @@ public:
   //! correspondingly) onto far view frustum plane
   inline const gp_Pnt& GetFarPnt() const { return myFarPickedPnt; }
 
+  //! Return view ray direction.
+  const gp_Vec& GetViewRayDirection() const { return myViewRayDir; }
+
   //! Return mouse coordinates.
   const gp_Pnt2d& GetMousePosition() const { return myMousePos; }
 
@@ -145,13 +139,6 @@ protected:
                                                  const gp_Pnt& thePntOnPlane,
                                                  SelectBasics_PickResult& thePickResult) const;
 
-  //! Computes valid depth range for the given clipping planes
-  Standard_EXPORT void computeClippingRange (const Graphic3d_SequenceOfHClipPlane& thePlanes,
-                                             SelectMgr_ViewClipRange& theRange) const;
-
-  //! Returns false if theDepth must be clipped by current view clip range
-  Standard_EXPORT Standard_Boolean isViewClippingOk (const SelectBasics_PickResult& thePickResult) const;
-
 private:
 
   void cacheVertexProjections (SelectMgr_RectangularFrustum* theFrustum) const;
@@ -169,7 +156,6 @@ private:
   gp_Vec                  myViewRayDir;
   gp_Pnt2d                myMousePos;                  //!< Mouse coordinates
   Standard_Real           myScale;                     //!< Scale factor of applied transformation, if there was any
-  SelectMgr_ViewClipRange myViewClipRange;
 
 };
 
index b98a255..2ef7b60 100644 (file)
@@ -62,6 +62,7 @@ SelectMgr_SelectingVolumeManager SelectMgr_SelectingVolumeManager::ScaleAndTrans
   aMgr.mySelectingVolumes[myActiveSelectionType / 2]->SetBuilder (theBuilder);
   aMgr.myViewClipPlanes = myViewClipPlanes;
   aMgr.myObjectClipPlanes = myObjectClipPlanes;
+  aMgr.myViewClipRange = myViewClipRange;
 
   return aMgr;
 }
@@ -242,7 +243,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const SelectMgr_Vec
   if (myActiveSelectionType == Unknown)
     return Standard_False;
 
-  return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theBoxMin, theBoxMax, thePickResult);
+  return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theBoxMin, theBoxMax, myViewClipRange, thePickResult);
 }
 
 //=======================================================================
@@ -269,8 +270,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePn
   if (myActiveSelectionType == Unknown)
     return Standard_False;
 
-  return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePnt,
-                                                                  thePickResult);
+  return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePnt, myViewClipRange, thePickResult);
 }
 
 //=======================================================================
@@ -299,9 +299,8 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const Handle(TColgp
   if (myActiveSelectionType == Unknown)
     return Standard_False;
 
-  return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts->Array1(),
-                                                                  (Select3D_TypeOfSensitivity)theSensType,
-                                                                  thePickResult);
+  return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts->Array1(), (Select3D_TypeOfSensitivity)theSensType,
+                                                                  myViewClipRange, thePickResult);
 }
 
 //=======================================================================
@@ -318,9 +317,8 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const TColgp_Array1
   if (myActiveSelectionType == Unknown)
     return Standard_False;
 
-  return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts,
-                                                                  (Select3D_TypeOfSensitivity)theSensType,
-                                                                  thePickResult);
+  return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts, (Select3D_TypeOfSensitivity)theSensType,
+                                                                  myViewClipRange, thePickResult);
 }
 
 //=======================================================================
@@ -334,7 +332,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePt
   if (myActiveSelectionType == Unknown)
     return Standard_False;
 
-  return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePt1, thePt2, thePickResult);
+  return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePt1, thePt2, myViewClipRange, thePickResult);
 }
 
 //=======================================================================
@@ -353,11 +351,8 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePt
   if (myActiveSelectionType == Unknown)
     return Standard_False;
 
-  return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePt1,
-                                                                  thePt2,
-                                                                  thePt3,
-                                                                  (Select3D_TypeOfSensitivity)theSensType,
-                                                                  thePickResult);
+  return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePt1, thePt2, thePt3, (Select3D_TypeOfSensitivity)theSensType,
+                                                                  myViewClipRange, thePickResult);
 }
 
 //=======================================================================
@@ -463,7 +458,18 @@ void SelectMgr_SelectingVolumeManager::SetViewClipping (const Handle(Graphic3d_S
   if (myActiveSelectionType != Point)
     return;
 
-  mySelectingVolumes[Frustum]->SetViewClipping (theViewPlanes, theObjPlanes);
+  const SelectMgr_RectangularFrustum* aFrustum = reinterpret_cast<const SelectMgr_RectangularFrustum*>(mySelectingVolumes[Frustum].get());
+  myViewClipRange.SetVoid();
+  if (!theViewPlanes.IsNull()
+   && !theViewPlanes->IsEmpty())
+  {
+    myViewClipRange.AddClippingPlanes (*theViewPlanes, gp_Ax1 (aFrustum->GetNearPnt(), aFrustum->GetViewRayDirection()));
+  }
+  if (!theObjPlanes.IsNull()
+   && !theObjPlanes->IsEmpty())
+  {
+    myViewClipRange.AddClippingPlanes (*theObjPlanes, gp_Ax1 (aFrustum->GetNearPnt(), aFrustum->GetViewRayDirection()));
+  }
 }
 
 //=======================================================================
@@ -472,11 +478,7 @@ void SelectMgr_SelectingVolumeManager::SetViewClipping (const Handle(Graphic3d_S
 //=======================================================================
 void SelectMgr_SelectingVolumeManager::SetViewClipping (const SelectMgr_SelectingVolumeManager& theOther)
 {
-  myViewClipPlanes   = theOther.ViewClipping();
-  myObjectClipPlanes = theOther.ObjectClipping();
-  if (myActiveSelectionType != Point)
-    return;
-
-  const SelectMgr_RectangularFrustum* aFrOther = reinterpret_cast<const SelectMgr_RectangularFrustum*>(theOther.mySelectingVolumes[Frustum].get());
-  reinterpret_cast<SelectMgr_RectangularFrustum*>(mySelectingVolumes[Frustum].get())->SetViewClipRanges (aFrOther->ViewClipRanges());
+  myViewClipPlanes   = theOther.myViewClipPlanes;
+  myObjectClipPlanes = theOther.myObjectClipPlanes;
+  myViewClipRange    = theOther.myViewClipRange;
 }
index 1c8bda3..d0d0ddc 100644 (file)
@@ -181,6 +181,12 @@ public:
   //! Copy clipping planes from another volume manager.
   Standard_EXPORT void SetViewClipping (const SelectMgr_SelectingVolumeManager& theOther);
 
+  //! Return clipping range.
+  const SelectMgr_ViewClipRange& ViewClipRanges() const { return myViewClipRange; }
+
+  //! Set clipping range.
+  void SetViewClipRanges (const SelectMgr_ViewClipRange& theRange) { myViewClipRange = theRange; }
+
   //! A set of helper functions that return rectangular selecting frustum data
   Standard_EXPORT const gp_Pnt* GetVertices() const;
 
@@ -236,6 +242,7 @@ private:
   Handle(SelectMgr_BaseFrustum)          mySelectingVolumes[VolumeTypesNb]; //!< Array of selecting volumes
   Handle(Graphic3d_SequenceOfHClipPlane) myViewClipPlanes;                  //!< view clipping planes
   Handle(Graphic3d_SequenceOfHClipPlane) myObjectClipPlanes;                //!< object clipping planes
+  SelectMgr_ViewClipRange                myViewClipRange;
   Standard_Boolean                       myToAllowOverlap;                  //!< Defines if partially overlapped entities will me detected or not
 };
 
index 3e8b1e9..1de02a4 100644 (file)
@@ -169,6 +169,7 @@ Handle(SelectMgr_BaseFrustum) SelectMgr_TriangularFrustum::ScaleAndTransform (co
 //=======================================================================
 Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const SelectMgr_Vec3& theMinPt,
                                                         const SelectMgr_Vec3& theMaxPt,
+                                                        const SelectMgr_ViewClipRange& /*theClipRange*/,
                                                         SelectBasics_PickResult& /*thePickResult*/) const
 {
   return hasOverlap (theMinPt, theMaxPt);
@@ -192,6 +193,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,
+                                                        const SelectMgr_ViewClipRange& /*theClipRange*/,
                                                         SelectBasics_PickResult& /*thePickResult*/) const
 {
   return hasOverlap (thePnt);
@@ -206,6 +208,7 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt,
 // =======================================================================
 Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
                                                         Select3D_TypeOfSensitivity theSensType,
+                                                        const SelectMgr_ViewClipRange& /*theClipRange*/,
                                                         SelectBasics_PickResult& /*thePickResult*/) const
 {
   if (theSensType == Select3D_TOS_BOUNDARY)
@@ -237,6 +240,7 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const TColgp_Array1OfPnt
 // =======================================================================
 Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt1,
                                                         const gp_Pnt& thePnt2,
+                                                        const SelectMgr_ViewClipRange& /*theClipRange*/,
                                                         SelectBasics_PickResult& /*thePickResult*/) const
 {
   return hasOverlap (thePnt1, thePnt2);
@@ -253,13 +257,14 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt1,
                                                         const gp_Pnt& thePnt2,
                                                         const gp_Pnt& thePnt3,
                                                         Select3D_TypeOfSensitivity theSensType,
+                                                        const SelectMgr_ViewClipRange& theClipRange,
                                                         SelectBasics_PickResult& thePickResult) const
 {
   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, thePickResult);
+    return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, theClipRange, thePickResult);
   }
   else if (theSensType == Select3D_TOS_INTERIOR)
   {
index 4dea1f8..fcebf8e 100644 (file)
@@ -48,6 +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,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
 
   //! Returns true if selecting volume is overlapped by axis-aligned bounding box
@@ -58,6 +59,7 @@ public:
 
   //! Intersection test between defined volume and given point
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
 
   //! SAT intersection test between defined volume and given ordered set of points,
@@ -65,11 +67,13 @@ public:
   //! boundary line defined by segments depending on given sensitivity type
   Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
                                                      Select3D_TypeOfSensitivity theSensType,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
 
   //! Checks if line segment overlaps selecting frustum
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
                                                      const gp_Pnt& thePnt2,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
 
   //! SAT intersection test between defined volume and given triangle. The test may
@@ -79,6 +83,7 @@ public:
                                                      const gp_Pnt& thePnt2,
                                                      const gp_Pnt& thePnt3,
                                                      Select3D_TypeOfSensitivity theSensType,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
 
   //! Nullifies the handle to corresponding builder instance to prevent memory leaks
index cca7a39..7da5398 100644 (file)
@@ -127,11 +127,12 @@ Handle(SelectMgr_BaseFrustum) SelectMgr_TriangularFrustumSet::ScaleAndTransform
 // =======================================================================
 Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const SelectMgr_Vec3& theMinPnt,
                                                            const SelectMgr_Vec3& theMaxPnt,
+                                                           const SelectMgr_ViewClipRange& theClipRange,
                                                            SelectBasics_PickResult& thePickResult) const
 {
   for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
   {
-    if (anIter.Value()->Overlaps (theMinPnt, theMaxPnt, thePickResult))
+    if (anIter.Value()->Overlaps (theMinPnt, theMaxPnt, theClipRange, thePickResult))
       return Standard_True;
   }
 
@@ -160,11 +161,12 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const SelectMgr_Vec3&
 // purpose  :
 // =======================================================================
 Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt,
+                                                           const SelectMgr_ViewClipRange& theClipRange,
                                                            SelectBasics_PickResult& thePickResult) const
 {
   for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
   {
-    if (anIter.Value()->Overlaps (thePnt, thePickResult))
+    if (anIter.Value()->Overlaps (thePnt, theClipRange, thePickResult))
       return Standard_True;
   }
 
@@ -177,11 +179,12 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt,
 // =======================================================================
 Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const TColgp_Array1OfPnt& theArrayOfPts,
                                                            Select3D_TypeOfSensitivity theSensType,
+                                                           const SelectMgr_ViewClipRange& theClipRange,
                                                            SelectBasics_PickResult& thePickResult) const
 {
   for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
   {
-    if (anIter.Value()->Overlaps (theArrayOfPts, theSensType, thePickResult))
+    if (anIter.Value()->Overlaps (theArrayOfPts, theSensType, theClipRange, thePickResult))
       return Standard_True;
   }
 
@@ -194,11 +197,12 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const TColgp_Array1Of
 // =======================================================================
 Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt1,
                                                            const gp_Pnt& thePnt2,
+                                                           const SelectMgr_ViewClipRange& theClipRange,
                                                            SelectBasics_PickResult& thePickResult) const
 {
   for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
   {
-    if (anIter.Value()->Overlaps (thePnt1, thePnt2, thePickResult))
+    if (anIter.Value()->Overlaps (thePnt1, thePnt2, theClipRange, thePickResult))
       return Standard_True;
   }
 
@@ -213,11 +217,12 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt1
                                                            const gp_Pnt& thePnt2,
                                                            const gp_Pnt& thePnt3,
                                                            Select3D_TypeOfSensitivity theSensType,
+                                                           const SelectMgr_ViewClipRange& theClipRange,
                                                            SelectBasics_PickResult& thePickResult) const
 {
   for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
   {
-    if (anIter.Value()->Overlaps (thePnt1, thePnt2, thePnt3, theSensType, thePickResult))
+    if (anIter.Value()->Overlaps (thePnt1, thePnt2, thePnt3, theSensType, theClipRange, thePickResult))
       return Standard_True;
   }
 
index 47b7bbf..fc2d4c1 100644 (file)
@@ -52,6 +52,7 @@ public:
 
   Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt,
                                                      const SelectMgr_Vec3& theMaxPnt,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
 
   Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt,
@@ -59,20 +60,24 @@ public:
                                                      Standard_Boolean* theInside) const Standard_OVERRIDE;
 
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
 
   Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
                                                      Select3D_TypeOfSensitivity theSensType,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
 
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
                                                      const gp_Pnt& thePnt2,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
 
   Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
                                                      const gp_Pnt& thePnt2,
                                                      const gp_Pnt& thePnt3,
                                                      Select3D_TypeOfSensitivity theSensType,
+                                                     const SelectMgr_ViewClipRange& theClipRange,
                                                      SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
 
   //! Stores plane equation coefficients (in the following form:
diff --git a/src/SelectMgr/SelectMgr_ViewClipRange.cxx b/src/SelectMgr/SelectMgr_ViewClipRange.cxx
new file mode 100644 (file)
index 0000000..d820ecd
--- /dev/null
@@ -0,0 +1,104 @@
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <SelectMgr_ViewClipRange.hxx>
+
+#include <gp_Ax1.hxx>
+#include <Graphic3d_SequenceOfHClipPlane.hxx>
+
+// =======================================================================
+// function : AddClippingPlanes
+// purpose  :
+// =======================================================================
+void SelectMgr_ViewClipRange::AddClippingPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes,
+                                                 const gp_Ax1& thePickRay)
+{
+  const gp_Dir& aViewRayDir = thePickRay.Direction();
+  const gp_Pnt& aNearPnt    = thePickRay.Location();
+
+  Graphic3d_Vec4d aPlaneABCD;
+  for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (thePlanes); aPlaneIt.More(); aPlaneIt.Next())
+  {
+    const Handle(Graphic3d_ClipPlane)& aClipPlane = aPlaneIt.Value();
+    if (!aClipPlane->IsOn())
+    {
+      continue;
+    }
+
+    Bnd_Range aSubRange (RealFirst(), RealLast());
+    for (const Graphic3d_ClipPlane* aSubPlaneIter = aClipPlane.get(); aSubPlaneIter != NULL; aSubPlaneIter = aSubPlaneIter->ChainNextPlane().get())
+    {
+      const gp_Pln aGeomPlane = aSubPlaneIter->ToPlane();
+      aGeomPlane.Coefficients (aPlaneABCD[0], aPlaneABCD[1], aPlaneABCD[2], aPlaneABCD[3]);
+
+      const gp_XYZ& aPlaneDirXYZ = aGeomPlane.Axis().Direction().XYZ();
+      Standard_Real aDotProduct = aViewRayDir.XYZ().Dot (aPlaneDirXYZ);
+      Standard_Real aDistance   = -aNearPnt.XYZ().Dot (aPlaneDirXYZ) - aPlaneABCD[3];
+      Standard_Real aDistToPln  = 0.0;
+
+      // check whether the pick line is parallel to clip plane
+      if (Abs (aDotProduct) < Precision::Angular())
+      {
+        if (aDistance < 0.0)
+        {
+          continue;
+        }
+        aDistToPln  = RealLast();
+        aDotProduct = 1.0;
+      }
+      else
+      {
+        // compute distance to point of pick line intersection with the plane
+        const Standard_Real aParam = aDistance / aDotProduct;
+
+        const gp_Pnt anIntersectionPnt = aNearPnt.XYZ() + aViewRayDir.XYZ() * aParam;
+        aDistToPln = anIntersectionPnt.Distance (aNearPnt);
+        if (aParam < 0.0)
+        {
+          // the plane is "behind" the ray
+          aDistToPln = -aDistToPln;
+        }
+      }
+
+      // change depth limits for case of opposite and directed planes
+      if (!aClipPlane->IsChain())
+      {
+        if (aDotProduct < 0.0)
+        {
+          ChangeUnclipRange().TrimTo (aDistToPln);
+        }
+        else
+        {
+          ChangeUnclipRange().TrimFrom (aDistToPln);
+        }
+      }
+      else
+      {
+        if (aDotProduct < 0.0)
+        {
+          aSubRange.TrimFrom (aDistToPln);
+        }
+        else
+        {
+          aSubRange.TrimTo (aDistToPln);
+        }
+      }
+    }
+
+    if (!aSubRange.IsVoid()
+      && aClipPlane->IsChain())
+    {
+      AddClipSubRange (aSubRange);
+    }
+  }
+}
index 575d376..b2f0124 100644 (file)
 #include <Bnd_Range.hxx>
 #include <Standard_TypeDef.hxx>
 
+#include <vector>
+
+class gp_Ax1;
+class Graphic3d_SequenceOfHClipPlane;
+
 //! Class for handling depth clipping range.
 //! It is used to perform checks in case if global (for the whole view)
 //! clipping planes are defined inside of SelectMgr_RectangularFrustum class methods.
@@ -93,6 +98,8 @@ public:
     return !theRange.IsOut (theDepth);
   }
 
+public:
+
   //! Clears clipping range.
   void SetVoid()
   {
@@ -100,6 +107,10 @@ public:
     myUnclipRange = Bnd_Range (RealFirst(), RealLast());
   }
 
+  //! Add clipping planes. Planes and picking ray should be defined in the same coordinate system.
+  Standard_EXPORT void AddClippingPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes,
+                                          const gp_Ax1& thePickRay);
+
   //! Returns the main unclipped range; [-inf, inf] by default.
   Bnd_Range& ChangeUnclipRange() { return myUnclipRange; }
 
index 262f704..9e467d2 100644 (file)
@@ -414,7 +414,7 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable
   Standard_Integer aHead = -1;
   Standard_Integer aNode = 0; // a root node
   SelectMgr_FrustumCache aScaledTrnsfFrustums;
-  SelectMgr_SelectingVolumeManager aTmpMgr;
+  SelectMgr_SelectingVolumeManager aTmpMgr (false);
   for (;;)
   {
     if (!aSensitivesTree->IsOuter (aNode))
diff --git a/tests/bugs/vis/bug30906 b/tests/bugs/vis/bug30906
new file mode 100644 (file)
index 0000000..ab1410d
--- /dev/null
@@ -0,0 +1,20 @@
+puts "============="
+puts "0030906: Visualization, SelectMgr_ViewerSelector - Object clipping planes overrides View clipping plane for next objects"
+puts "============="
+
+pload MODELING VISUALIZATION
+box b1 1 1 0 1 2 3
+box b2 3 0 0 1 2 3
+vclear
+vinit View1
+vdisplay -dispMode 1 -highMode 1 b1 b2
+vfit
+vzbufftrihedron
+vpoint p0 0 0 0
+vclipplane c1 -equation 0 1 0  1 -setOverrideGlobal b1
+vclipplane c2 -equation 0 1 0 -1 -set
+vmoveto 200 200
+if { [vreadpixel 250 200 -rgb -name] != "DARKGOLDENROD3" } { puts "Error: selection of clipped object" }
+if { [vreadpixel 150 200 -rgb -name] != "DARKTURQUOISE"  } { puts "Error: object is not selected" }
+
+vdump ${imagedir}/${casename}.png