0029934: Visualization - handle properly orthogonal clipping plane within SelectMgr_R...
authorkgv <kgv@opencascade.com>
Fri, 6 Jul 2018 16:04:49 +0000 (19:04 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 13 Jul 2018 12:02:38 +0000 (15:02 +0300)
SelectMgr_RectangularFrustum now considers the direction of clipping plane orthogonal to picking ray.

src/SelectMgr/SelectMgr_RectangularFrustum.cxx
tests/bugs/vis/bug29791

index 7bcd65c..ccc4868 100644 (file)
@@ -665,23 +665,30 @@ void SelectMgr_RectangularFrustum::computeClippingRange (const Graphic3d_Sequenc
       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())
       {
-        // line lies below the plane and is not clipped, skip
-        continue;
+        if (aDistance < 0.0)
+        {
+          continue;
+        }
+        aDistToPln  = RealLast();
+        aDotProduct = 1.0;
       }
-
-      // 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;
-      Standard_Real aDistToPln = anIntersectionPnt.Distance (myNearPickedPnt);
-      if (aParam < 0.0)
+      else
       {
-        // the plane is "behind" the ray
-        aDistToPln = -aDistToPln;
+        // 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
index 64190c1..587f861 100644 (file)
@@ -10,12 +10,24 @@ vinit View1
 vdisplay -dispMode 1 -highMode 1 b
 vfit
 vzbufftrihedron
-vviewparams -scale 14.7435 -proj 0.193921 -0.891229 0.410007 -up -0.0205984 0.414149 0.909976 -at 11.3689 1.32152 24.9954
 vclipplane p -equation 1 0 0 -20 -set
+
+# clipping plane orthogonal to the camera direction
+vfront
+vfit
+vmoveto 150 200
+vstate -entities
+vselect 150 200
+if { [vreadpixel 150 200 rgb name] != "BLACK"      } { puts "Error: object is not clipped" }
+if { [vreadpixel 350 200 rgb name] != "GOLDENROD1" } { puts "Error: object should NOT be selected" }
+vdump $imagedir/${casename}_1.png
+
+# depth range starts behinds the picking ray
+vviewparams -scale 14.7435 -proj 0.193921 -0.891229 0.410007 -up -0.0205984 0.414149 0.909976 -at 11.3689 1.32152 24.9954
 vmoveto 150 200
 vstate -entities
 vselect 150 200
 if { [vreadpixel 150 200 rgb name] != "BLACK"      } { puts "Error: object is not clipped" }
 if { [vreadpixel 300 200 rgb name] != "GOLDENROD1" } { puts "Error: object should NOT be selected" }
 
-vdump $imagedir/${casename}.png
+vdump $imagedir/${casename}_2.png