gp_Pnt ViewCalculations::convert2DPointTo3DPoint(Standard_Real x, Standard_Real y, Handle(V3d_View) aView) { V3d_Coordinate XEye,YEye,ZEye,XAt,YAt,ZAt; aView->Eye(XEye,YEye,ZEye); aView->At(XAt,YAt,ZAt); gp_Pnt EyePoint(XEye,YEye,ZEye); gp_Pnt AtPoint(XAt,YAt,ZAt); gp_Vec EyeVector(EyePoint,AtPoint); gp_Dir EyeDir(EyeVector); gp_Pln PlaneOfTheView = gp_Pln(AtPoint,EyeDir); Standard_Real X,Y,Z; aView->Convert(int(x),int(y),X,Y,Z); gp_Pnt ConvertedPoint(X,Y,Z); gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project(PlaneOfTheView,ConvertedPoint); gp_Pnt ResultPoint = ElSLib::Value(ConvertedPointOnPlane.X(), ConvertedPointOnPlane.Y(), PlaneOfTheView); return ResultPoint; } gp_Pnt ViewCalculations::convert2DpointTo3DPointOnPlane(Standard_Real x, Standard_Real y, Handle(V3d_View) view) { Standard_Real Xp = x, Yp = y; Standard_Real Xv, Yv, Zv; Standard_Real Vx, Vy, Vz; gp_Pln aPlane(view->Viewer()->PrivilegedPlane()); view->Convert( Xp, Yp, Xv, Yv, Zv ); view->Proj( Vx, Vy, Vz ); gp_Lin aLine(gp_Pnt(Xv, Yv, Zv), gp_Dir(Vx, Vy, Vz)); IntAna_IntConicQuad theIntersection (aLine, aPlane, Precision::Angular()); if (theIntersection.IsDone()) { if (!theIntersection.IsParallel()) { if (theIntersection.NbPoints() > 0) { gp_Pnt theSolution(theIntersection.Point(1)); return gp_Pnt(theSolution.X(), theSolution.Y(), theSolution.Z()); // if (usePrecision) // { // X = (X < 0. ? -1 : (X > 0. ? 1 : 0.)) * floor((abs(X)) / myPrecision) * myPrecision; // Y = (Y < 0. ? -1 : (Y > 0. ? 1 : 0.)) * floor((abs(Y)) / myPrecision) * myPrecision; // Z = (Z < 0. ? -1 : (Z > 0. ? 1 : 0.)) * floor((abs(Z)) / myPrecision) * myPrecision; // } } } } }