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
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