//-------------------------------------------------------------------------------------------------- public Ax1 ViewAxis(int screenX, int screenY) { double px = 0, py = 0, pz = 0; V3dView.Convert(screenX, screenY, ref px, ref py, ref pz); return(new Ax1(new Pnt(px, py, pz), GetViewDirection())); }
//-------------------------------------------------------------------------------------------------- public bool ScreenToPoint(Pln plane, int screenX, int screenY, out Pnt resultPnt) { try { double xv = 0, yv = 0, zv = 0; double vx = 0, vy = 0, vz = 0; V3dView.Convert(screenX, screenY, ref xv, ref yv, ref zv); V3dView.Proj(ref vx, ref vy, ref vz); gp_Lin line = new gp_Lin(new Pnt(xv, yv, zv), new Dir(vx, vy, vz)); IntAna_IntConicQuad intersection = new IntAna_IntConicQuad(line, plane, Precision.Angular(), 0, 0); if (intersection.IsDone() && !intersection.IsParallel() && intersection.NbPoints() > 0) { resultPnt = intersection.Point(1); return(true); } } catch (Exception) { Debug.Assert(false); } resultPnt = new Pnt(); return(false); }
//-------------------------------------------------------------------------------------------------- public bool PointToScreen(Pnt pnt, out int screenX, out int screenY) { try { int x = 0, y = 0; V3dView.Convert(pnt.X, pnt.Y, pnt.Z, ref x, ref y); screenX = x; screenY = y; return(true); } catch (Exception) { Debug.Assert(false); } screenX = 0; screenY = 0; return(false); }
//-------------------------------------------------------------------------------------------------- #endregion #region Screen Space Conversions public bool ScreenToPoint(int screenX, int screenY, out Pnt resultPnt) { try { var viewPlane = GetViewPlane(); double x = 0, y = 0, z = 0; V3dView.Convert(screenX, screenY, ref x, ref y, ref z); Pnt convertedPoint = new Pnt(x, y, z); Pnt2d convertedPointOnPlane = ProjLib.Project(viewPlane, convertedPoint); resultPnt = ElSLib.Value(convertedPointOnPlane.X, convertedPointOnPlane.Y, viewPlane); return(true); } catch (Exception) { Debug.Assert(false); } resultPnt = Pnt.Origin; return(false); }