1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0029934: Visualization - handle properly orthogonal clipping plane within SelectMgr_RectangularFrustum::computeClippingRange()

SelectMgr_RectangularFrustum now considers the direction of clipping plane orthogonal to picking ray.
This commit is contained in:
kgv 2018-07-06 19:04:49 +03:00 committed by bugmaster
parent 98b15dbfce
commit 029594a052
2 changed files with 32 additions and 13 deletions

View 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

View 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