From: Konstantin LEONTEV Date: Wed, 31 Aug 2022 13:00:11 +0000 (+0300) Subject: Mantis 0054772: crash when select point in viewer inside created face X-Git-Tag: V9_10_0a1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=46676347f26294f60ec56f5d31abb87bceebf317;hp=a3eca73f94436dac52dcec3b61cc75a6c3837d86;p=modules%2Fgeom.git Mantis 0054772: crash when select point in viewer inside created face --- diff --git a/src/GEOMUtils/GEOMUtils.cxx b/src/GEOMUtils/GEOMUtils.cxx index 4c69a9a05..24d7318c0 100644 --- a/src/GEOMUtils/GEOMUtils.cxx +++ b/src/GEOMUtils/GEOMUtils.cxx @@ -1089,17 +1089,17 @@ gp_Pnt GEOMUtils::ProjectPointOnFace(const gp_Pnt& thePoint, //======================================================================= gp_Pnt GEOMUtils::ConvertClickToPoint( int x, int y, Handle(V3d_View) aView ) { - V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt; - aView->Eye( XEye, YEye, ZEye ); + // We can't rely on Eye and At points to get EyeDir, because they collapse + // for views with flat bounding boxes. For example if you create a circle and + // switch to the top view, then both camera's Eye and At points will fall to zero + // inside V3d_View::FitMinMax() method. It's by occt design. + // So, we should use camera direction instead. - aView->At( XAt, YAt, ZAt ); - gp_Pnt EyePoint( XEye, YEye, ZEye ); - gp_Pnt AtPoint( XAt, YAt, ZAt ); + V3d_Coordinate XAt, YAt, ZAt; + aView->At(XAt, YAt, ZAt); + gp_Pnt AtPoint(XAt, YAt, ZAt); - gp_Vec EyeVector( EyePoint, AtPoint ); - gp_Dir EyeDir( EyeVector ); - - gp_Pln PlaneOfTheView = gp_Pln( AtPoint, EyeDir ); + gp_Pln PlaneOfTheView = gp_Pln( AtPoint, aView->Camera()->Direction() ); Standard_Real X, Y, Z; aView->Convert( x, y, X, Y, Z ); gp_Pnt ConvertedPoint( X, Y, Z );