Advertisement
Guest User

convert2DPointTo3DPoint

a guest
Mar 7th, 2014
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. gp_Pnt ViewCalculations::convert2DPointTo3DPoint(Standard_Real x, Standard_Real y, Handle(V3d_View) aView)
  2. {
  3.     V3d_Coordinate XEye,YEye,ZEye,XAt,YAt,ZAt;
  4.     aView->Eye(XEye,YEye,ZEye);
  5.     aView->At(XAt,YAt,ZAt);
  6.     gp_Pnt EyePoint(XEye,YEye,ZEye);
  7.     gp_Pnt AtPoint(XAt,YAt,ZAt);
  8.  
  9.     gp_Vec EyeVector(EyePoint,AtPoint);
  10.     gp_Dir EyeDir(EyeVector);
  11.  
  12.     gp_Pln PlaneOfTheView = gp_Pln(AtPoint,EyeDir);
  13.     Standard_Real X,Y,Z;
  14.     aView->Convert(int(x),int(y),X,Y,Z);
  15.     gp_Pnt ConvertedPoint(X,Y,Z);
  16.     gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project(PlaneOfTheView,ConvertedPoint);
  17.  
  18.     gp_Pnt ResultPoint = ElSLib::Value(ConvertedPointOnPlane.X(),
  19.                                        ConvertedPointOnPlane.Y(),
  20.                                        PlaneOfTheView);
  21.  
  22.     return ResultPoint;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement