Integration of OCCT 6.5.0 from SVN
[occt.git] / samples / mfc / standard / 04_Viewer3d / src / ConvertClickToPoint.cxx
1 #include <stdafx.h>
2
3 gp_Pnt ConvertClickToPoint(Standard_Real x, Standard_Real y, Handle(V3d_View) aView)
4 {
5         
6         V3d_Coordinate XEye,YEye,ZEye,XAt,YAt,ZAt;
7         aView->Eye(XEye,YEye,ZEye);
8         aView->At(XAt,YAt,ZAt);
9         gp_Pnt EyePoint(XEye,YEye,ZEye);
10         gp_Pnt AtPoint(XAt,YAt,ZAt);
11
12         gp_Vec EyeVector(EyePoint,AtPoint);
13         gp_Dir EyeDir(EyeVector);
14
15         gp_Pln PlaneOfTheView = gp_Pln(AtPoint,EyeDir);
16         Standard_Real X,Y,Z;
17         aView->Convert((int)x,(int)y,X,Y,Z);
18         gp_Pnt ConvertedPoint(X,Y,Z);
19         gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project(PlaneOfTheView,ConvertedPoint);
20         
21         gp_Pnt ResultPoint = ElSLib::Value(ConvertedPointOnPlane.X(),
22                                                                         ConvertedPointOnPlane.Y(),
23                                                                         PlaneOfTheView);
24         return ResultPoint;
25 }
26
27