From ba4feb7629b4e1e2fbeca1a154767352d0e34292 Mon Sep 17 00:00:00 2001 From: apl Date: Tue, 14 Oct 2014 15:47:34 +0400 Subject: [PATCH] 0025265: Perspective projection - selecting front point of two --- src/Select3D/Select3D_Projector.cxx | 4 +- tests/bugs/vis/bug25265 | 74 +++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 tests/bugs/vis/bug25265 diff --git a/src/Select3D/Select3D_Projector.cxx b/src/Select3D/Select3D_Projector.cxx index 6b7eb651fa..50cc4a9028 100644 --- a/src/Select3D/Select3D_Projector.cxx +++ b/src/Select3D/Select3D_Projector.cxx @@ -454,10 +454,10 @@ gp_Lin Select3D_Projector::Shoot (const Standard_Real theX, const Standard_Real return gp_Lin(); } - Graphic3d_Vec4d aVPnt1 = aProjInv * Graphic3d_Vec4d (theX, theY, 0.0, 1.0); + Graphic3d_Vec4d aVPnt1 = aProjInv * Graphic3d_Vec4d (theX, theY, 0.0, 1.0); Graphic3d_Vec4d aVPnt2 = aProjInv * Graphic3d_Vec4d (theX, theY, 10.0, 1.0); aVPnt1 /= aVPnt1.w(); - aVPnt2 /= aVPnt1.w(); + aVPnt2 /= aVPnt2.w(); gp_Vec aViewDir (aVPnt2.x() - aVPnt1.x(), aVPnt2.y() - aVPnt1.y(), aVPnt2.z() - aVPnt1.z()); diff --git a/tests/bugs/vis/bug25265 b/tests/bugs/vis/bug25265 new file mode 100644 index 0000000000..b93dd3413a --- /dev/null +++ b/tests/bugs/vis/bug25265 @@ -0,0 +1,74 @@ +puts "============" +puts "OCC25265" +puts "============" +puts "" +#################################################################################### +# Perspective projection - selecting front point of two. +# When trying to select front point of two (lying on Z-coordinate) in a perspective +# view, the back one is snapped and selected. +#################################################################################### + +set select_x 204 +set select_y 204 + +vinit View1 +vsetdispmode 1 +vcamera -persp + +# Draw grid of points 7x7. +set j 0 +for {set x 0} {$x<7} {incr x} { + for {set y 0} {$y<7} {incr y} { + vpoint $j $x $y 10 + incr j + } +} + for {set x 0} {$x<7} {incr x} { + for {set y 0} {$y<7} {incr y} { + vpoint $j $x $y 0 + incr j + } +} + +# Prepare view. +vtop +vfit + +vselect $select_x $select_y + +set stat 0 +set result [vstate] +set newlist {} +set ref_selected {24} +set asplit [split $result "\n"] +for {set i 0} {$i < [llength $ref_selected]} {incr i} { + lappend newlist [lindex [lindex $asplit $i] 0] +} +set newsorted [lsort $newlist] +set refsorted [lsort $ref_selected] +for {set i 0} {$i < [llength $refsorted]} {incr i} { + if {[lindex $refsorted $i] != [lindex $newsorted $i]} { + set stat 1 + break + } +} + +if {$stat == 1} { + puts "Error : Perspective selection is broken." +} + +# Dump view. +set scale 48.20 +set up_x -0.09 +set up_y 0.94 +set up_z -0.33 +set at_x 3.03 +set at_y 2.70 +set at_z 5.10 +set eye_x 16.40 +set eye_y 10.98 +set eye_z 24.59 + +vviewparams -scale $scale -up $up_x $up_y $up_z -at $at_x $at_y $at_z -eye $eye_x $eye_y $eye_z + +set only_screen 1 \ No newline at end of file