private double Radius2Calculate(GeoPoint MousePosition) { // falls die Höhe über einen Punkt im Raum über der jetzigen Cone bestimmt wird: // komplizierte Berechnung des Radius. Zunächst der Spezialfall Draufsicht auf Kegel: double l; if (Precision.SameDirection(CurrentMouseView.Projection.Direction, coneDirZ, false)) { l = Geometry.DistPL(MousePosition, coneStartPoint, coneDirZ); } else { // ebene aus Kegelachse und der Senkrechten dieser Achse mit der Projektionsrichtung (Auge-Zeichnung) Plane pl = new Plane(coneStartPoint, coneDirZ, CurrentMouseView.Projection.Direction ^ coneDirZ); // Projektion des Mousepunkts in diese Ebene GeoPoint2D tP = pl.Project(MousePosition); // gemäß Ebenendefinition ist der y-Wert der gewünschte Radius l = Math.Abs(tP.y); } if (l >= 0.0) { if (l <= Precision.eps) { l = 0.0; } // nun die Länge zurückliefern return(l); } return(0); }
/// <summary> /// Returns the position of the point p, which is assumed to be on the bound of this rectangle. /// 0 is lower left, 1 is lower right and so on /// </summary> /// <param name="p">the point to check</param> /// <returns>the parameter which is between 0 and 4</returns> internal double PositionOf(GeoPoint2D p) { double ld = Math.Abs(p.x - Left); double rd = Math.Abs(p.x - Right); double bd = Math.Abs(p.y - Bottom); double td = Math.Abs(p.y - Top); if (ld < rd && ld < bd && ld < td) { // closest to the left side double d = (p.y - Bottom) / (Top - Bottom); return(Math.Min(4.0, 4.0 - d)); } else if (rd < bd && rd < td) { // closest to the right side double d = (p.y - Bottom) / (Top - Bottom); return(1.0 + d); } else if (bd < td) { // closest to the bottom side double d = (p.x - Left) / (Right - Left); return(Math.Max(0.0, d)); } else { // closest to the top double d = (p.x - Left) / (Right - Left); return(3.0 - d); } }
internal bool ContainsPeriodic(GeoPoint2D uv, double up, double vp) { if (uv.x >= Left && uv.x <= Right && uv.y >= Bottom && uv.y <= Top) { return(true); } if (up > 0.0) { while (Right - uv.x >= up) { uv.x += up; } while (uv.x - Left >= up) { uv.x -= up; } } if (vp > 0.0) { while (Top - uv.y >= vp) { uv.y += vp; } while (uv.y - Bottom >= vp) { uv.y -= vp; } } if (up > 0.0 || vp > 0.0) { return(uv.x >= Left && uv.x <= Right && uv.y >= Bottom && uv.y <= Top); } return(false); }
/// <summary> /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.SameGeometry (BoundingRect, ISurface, BoundingRect, double, out ModOp2D)"/> /// </summary> /// <param name="thisBounds"></param> /// <param name="other"></param> /// <param name="otherBounds"></param> /// <param name="precision"></param> /// <param name="firstToSecond"></param> /// <returns></returns> public override bool SameGeometry(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds, double precision, out ModOp2D firstToSecond) { firstToSecond = ModOp2D.Null; if (other is PlaneSurface) { PlaneSurface second = other as PlaneSurface; GeoPoint p = PointAt(thisBounds.GetCenter()); if (Math.Abs(second.Plane.Distance(p)) > precision) { return(false); } p = second.PointAt(otherBounds.GetCenter()); if (Math.Abs(Plane.Distance(p)) > precision) { return(false); } if (Precision.SameDirection(Normal, second.Normal, false)) { GeoPoint2D[] src = new GeoPoint2D[] { GeoPoint2D.Origin, new GeoPoint2D(1, 0), new GeoPoint2D(0, 1) }; GeoPoint2D[] dst = new GeoPoint2D[3]; for (int i = 0; i < 3; ++i) { dst[i] = second.PositionOf(PointAt(src[i])); } firstToSecond = ModOp2D.Fit(src, dst, true); return(true); } else { return(false); } } return(base.SameGeometry(thisBounds, other, otherBounds, precision, out firstToSecond)); }
public void OnMouseWheel(MouseEventArgs e) { double Factor; if (e.Delta > 0) { Factor = 1.0 / 1.1; } else if (e.Delta < 0) { Factor = 1.1; } else { return; } Rectangle clr = canvas.ClientRectangle; BoundingRect rct = new BoundingRect(clr.Left, clr.Bottom, clr.Right, clr.Top); rct.Modify(screenToLayout); System.Drawing.Point p = new System.Drawing.Point(e.X, e.Y); p = canvas.PointToClient(Frame.UIService.CurrentMousePosition); GeoPoint2D p2 = screenToLayout * new GeoPoint2D(p.X, p.Y); rct.Right = p2.x + (rct.Right - p2.x) * Factor; rct.Left = p2.x + (rct.Left - p2.x) * Factor; rct.Bottom = p2.y + (rct.Bottom - p2.y) * Factor; rct.Top = p2.y + (rct.Top - p2.y) * Factor; (this as IView).ZoomToRect(rct); (this as IView).InvalidateAll(); }
/// <summary> /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.GetLineIntersection (GeoPoint, GeoVector)"/> /// </summary> /// <param name="startPoint"></param> /// <param name="direction"></param> /// <returns></returns> public override GeoPoint2D[] GetLineIntersection(GeoPoint startPoint, GeoVector direction) { if (Precision.SameDirection(this.direction, direction, false)) { // Linie parallel zur Auszugsrichtung return(new GeoPoint2D[] { }); } else { // Die Ebene durch Auszugsrichtung und Schnittgerade und Schnittlinien-Startpunkt, schneide // die Basiskurve mit der Ebene. Die Schnittpunkt liefern die richtigen u-Werte // die v-Werte finden wir vom u-Wert auf der basisCurve ausgehen in Auszugsrichtung und mit der Schnittlinie schneiden Plane pln = new Plane(startPoint, direction, this.direction); double[] u = basisCurve.GetPlaneIntersection(pln); GeoPoint2D[] res = new GeoPoint2D[u.Length]; pln = new Plane(startPoint, direction, direction ^ this.direction); // Ebene senkrech zur Auszugsrichtung durch den Linienpunkt for (int i = 0; i < u.Length; ++i) { GeoPoint ip = pln.Intersect(basisCurve.PointAt(u[i]), this.direction); GeoPoint vbasis = basisCurve.PointAt(u[i]); //res[i] = new GeoPoint2D((u[i] - curveStartParameter) / (curveEndParameter - curveStartParameter), Geometry.LinePar(startPoint, this.direction, ip)); res[i] = new GeoPoint2D((u[i] * (curveEndParameter - curveStartParameter) + curveStartParameter), Geometry.LinePar(vbasis, this.direction, ip)); } return(res); } }
public override GeoPoint PointAt(GeoPoint2D uv) { double l = Math.Sqrt(uv.x * uv.x + uv.y * uv.y); if (l == 0.0) { return(location + zAxis); // this is invalid and should never be used. } double r = xAxis.Length; // l must be between r/2 and r // trying to clip here: #if DEBUG if (l < r / 2 * 0.99) { } #endif if (l < r / 2) { l = r / 2; } if (l > r) { l = r; } double z = (r - l) / l; double a = Math.Atan2(uv.y, uv.x); return(location + Math.Cos(a) * xAxis + Math.Sin(a) * yAxis + z * zAxis); }
internal void AddPositionOnFace(Face fc, GeoPoint2D uv) { lock (uvposition) { uvposition[fc] = uv; } }
GeoPoint2D ICurveTransformation2D.TransformPoint(ICurve2D curve, double par) { // gesucht: Punkt der Kurve im nichtperiodischen System GeoPoint2D uv = curve.PointAt(par); double r = uv.y - vmin; return(new GeoPoint2D(r * Math.Cos(uv.x), r * Math.Sin(uv.x))); }
public Arc2D(GeoPoint2D center, double radius, GeoPoint2D StartPoint, GeoPoint2D EndPoint, bool counterclock) : base(center, radius) { start = new Angle(StartPoint, center); sweep = new SweepAngle(StartPoint - center, EndPoint - center); // sweep ist zwischen -pi und +pi, also der Bogen ist maximal ein Halbkreis. // counterclock gibt aber die Richtung vor, deshalb ggf. umdrehen if ((StartPoint | EndPoint) < radius * 1e-10) { if (counterclock) { sweep = SweepAngle.Full; } else { sweep = SweepAngle.FullReverse; } } if (counterclock && sweep <= 0.0) { sweep += 2.0 * Math.PI; } if (!counterclock && sweep >= 0.0) { sweep -= 2.0 * Math.PI; } }
public ClipRect[] Split() { GeoPoint2D cnt = Center; ClipRect[] res = new ClipRect[4]; res[0].Left = Left; res[0].Bottom = Bottom; res[0].Right = cnt.x; res[0].Top = cnt.y; res[1].Left = Left; res[1].Bottom = cnt.y; res[1].Right = cnt.x; res[1].Top = Top; res[2].Left = cnt.x; res[2].Bottom = cnt.y; res[2].Right = Right; res[2].Top = Top; res[3].Left = cnt.x; res[3].Bottom = Bottom; res[3].Right = Right; res[3].Top = cnt.y; return(res); }
private void PerpFoot() { if (dimCurve != null) //falls in CurveInput (s.u.) ein Objekt getroffen war { Plane pl; double mindist = double.MaxValue; GeoPoint2D footPoint = new GeoPoint2D(0.0, 0.0); if (Curves.GetCommonPlane(dim.DimLineRef, dimCurve, out pl)) { ICurve2D c2D = dimCurve.GetProjectedCurve(pl); if (c2D is Path2D) { (c2D as Path2D).Flatten(); } GeoPoint2D[] perpPoints = c2D.PerpendicularFoot(pl.Project(dim.DimLineRef)); if (perpPoints.Length > 0) { // eine gültige Kurve ist gefunden for (int j = 0; j < perpPoints.Length; ++j) { double dist = Geometry.Dist(perpPoints[j], pl.Project(dim.DimLineRef)); if (dist < mindist) { mindist = dist; footPoint = perpPoints[j]; } } } } if (mindist < double.MaxValue) { // also: Fußpunkt gefunden dim.SetPoint(0, pl.ToGlobal(footPoint)); } } }
public override bool TryPointDeriv2At(double position, out GeoPoint2D point, out GeoVector2D deriv, out GeoVector2D deriv2) { // not yet tested point = fromUnit * new GeoPoint2D(position, Math.Sin(ustart + position * udiff)); deriv = fromUnit * new GeoVector2D(1, udiff * Math.Cos(ustart + position * udiff)); deriv2 = fromUnit * new GeoVector2D(1, -udiff * udiff * Math.Sin(ustart + position * udiff)); return(true); }
public override GeoPoint2D PointAt(double pos) { double u = PosToPar(pos); GeoPoint2D p = new GeoPoint2D(u, Math.Sin(u)); return(fromUnit * p); }
public override void DerivationAt(GeoPoint2D uv, out GeoPoint location, out GeoVector du, out GeoVector dv) { periodicSurface.DerivationAt(toPeriodic(uv), out GeoPoint ploc, out GeoVector pdu, out GeoVector pdv); location = ploc; double l = uv.x * uv.x + uv.y * uv.y; double sl = Math.Sqrt(l); double dsdu, dsdv, dtdu, dtdv; if (l > 0) { dsdu = toPeriodicBounds[0, 1] * uv.x / sl - toPeriodicBounds[0, 0] * uv.y / l; dsdv = toPeriodicBounds[0, 1] * uv.y / sl + toPeriodicBounds[0, 0] * uv.x / l; dtdu = toPeriodicBounds[1, 1] * uv.x / sl - toPeriodicBounds[1, 0] * uv.y / l; dtdv = toPeriodicBounds[1, 1] * uv.y / sl + toPeriodicBounds[1, 0] * uv.x / l; du = dsdu * pdu + dtdu * pdv; dv = dsdv * pdu + dtdv * pdv; } else { // toPeriodic at (0,0) did return toPeriodicBounds * (0,0), but we also need toPeriodicBounds * (pi/2,0), because at (0,0) there is the pole GeoPoint2D pole1 = toPeriodicBounds * new GeoPoint2D(Math.PI / 2.0, 0.0); periodicSurface.DerivationAt(pole1, out GeoPoint ploc1, out GeoVector pdu1, out GeoVector pdv1); dsdu = toPeriodicBounds[0, 1] - toPeriodicBounds[0, 0]; dsdv = toPeriodicBounds[0, 1] + toPeriodicBounds[0, 0]; dtdu = toPeriodicBounds[1, 1] - toPeriodicBounds[1, 0]; dtdv = toPeriodicBounds[1, 1] + toPeriodicBounds[1, 0]; du = dsdu * pdu + dtdu * pdv; dv = dsdv * pdu1 + dtdv * pdv1; } }
public int Compare(object x, object y) { // Typ-Casting IGeoObject o1 = (IGeoObject)x; IGeoObject o2 = (IGeoObject)y; // Sortierung nach Mittelpunkten BoundingRect re = IGeoObjectImpl.GetExtent(o1, projection, false); GeoPoint2D p1 = re.GetCenter(); re = IGeoObjectImpl.GetExtent(o2, projection, false); GeoPoint2D p2 = re.GetCenter(); if (dirx) { if (p1.x < p2.x) { return(-1); } if (p1.x > p2.x) { return(1); } } else { if (p1.y < p2.y) { return(-1); } if (p1.y > p2.y) { return(1); } } return(0); }
public override GeoPoint2D PositionOf(GeoPoint p) { GeoPoint2D uvp = periodicSurface.PositionOf(p); SurfaceHelper.AdjustPeriodic(periodicSurface, periodicBounds, ref uvp); return(fromPeriodic(uvp)); }
private static void RefineIntersectionPoint(Ellipse2D e1, Ellipse2D e2, ref GeoPoint2DWithParameter ip) { // hier mir Param arbeiten, da es sich auch um einen Ellipsenbogen handeln kann double par1 = e1.ParamOf(ip.p); double par2 = e2.ParamOf(ip.p); GeoPoint2D p1 = e1.PointAtParam(par1); GeoPoint2D p2 = e2.PointAtParam(par2); int counter = 0; while (!Precision.IsEqual(p1, p2)) { GeoVector2D d1 = e1.DirectionAtParam(par1); GeoVector2D d2 = e2.DirectionAtParam(par2); GeoPoint2D p; if (Geometry.IntersectLL(p1, d1, p2, d2, out p)) { par1 = e1.ParamOf(p); par2 = e2.ParamOf(p); p1 = e1.PointAtParam(par1); p2 = e2.PointAtParam(par2); ip.p = p; } else { break; } ++counter; if (counter > 100) { break; } } ip.par1 = e1.PositionOf(ip.p); // richtige Werte auch für Arc ip.par2 = e2.PositionOf(ip.p); }
/// <summary> /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.SameGeometry (BoundingRect, ISurface, BoundingRect, double, out ModOp2D)"/> /// </summary> /// <param name="thisBounds"></param> /// <param name="other"></param> /// <param name="otherBounds"></param> /// <param name="precision"></param> /// <param name="firstToSecond"></param> /// <returns></returns> public override bool SameGeometry(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds, double precision, out ModOp2D firstToSecond) { if (other is SurfaceOfLinearExtrusion) { firstToSecond = ModOp2D.Null; SurfaceOfLinearExtrusion sleother = other as SurfaceOfLinearExtrusion; // es würde genügen, wenn die beiden Kurven sich überlappen. Dann auf das Überlappungsintervall testen bool reverse; if (!Curves.SameGeometry(BasisCurve, sleother.BasisCurve, precision, out reverse)) { return(false); } // zwei Extrempunkte bestimmen, damit sollte es OK sein GeoPoint2D uv1 = new GeoPoint2D(curveStartParameter, 0.0); GeoPoint p1 = PointAt(uv1); GeoPoint2D uv2 = sleother.PositionOf(p1); GeoPoint p2 = sleother.PointAt(uv2); if ((p1 | p2) > precision) { return(false); } uv1 = new GeoPoint2D(curveEndParameter, 1.0); p1 = PointAt(uv1); uv2 = sleother.PositionOf(p1); p2 = sleother.PointAt(uv2); if ((p1 | p2) > precision) { return(false); } firstToSecond = ModOp2D.Translate(uv2 - uv1); return(true); } return(base.SameGeometry(thisBounds, other, otherBounds, precision, out firstToSecond)); }
public override bool TryPointDeriv3At(double position, out GeoPoint2D point, out GeoVector2D deriv1, out GeoVector2D deriv2, out GeoVector2D deriv3) { double sweepParameter; if (counterClock) { sweepParameter = 2.0 * Math.PI; } else { sweepParameter = -2.0 * Math.PI; } double u = position * sweepParameter; double su = Math.Sin(u); double cu = Math.Cos(u); point = fromUnitCircle * new GeoPoint2D(cu, su); double pp = 2 * Math.PI; double ppp = 4 * Math.PI * Math.PI; double pppp = 8 * Math.PI * Math.PI * Math.PI; if (!counterClock) { pp = -pp; pppp = -pppp; } deriv1 = pp * new GeoVector2D(fromUnitCircle[0, 1] * cu - fromUnitCircle[0, 0] * su, fromUnitCircle[1, 1] * cu - fromUnitCircle[1, 0] * su); deriv2 = ppp * new GeoVector2D(-fromUnitCircle[0, 1] * su - fromUnitCircle[0, 0] * cu, -fromUnitCircle[1, 1] * su - fromUnitCircle[1, 0] * cu); deriv3 = pppp * new GeoVector2D(fromUnitCircle[0, 0] * su - fromUnitCircle[0, 1] * cu, fromUnitCircle[1, 0] * su - fromUnitCircle[1, 1] * cu); return(true); }
public bool IsInside(GeoPoint2D uv) { double r = xAxis.Length; double l = Math.Sqrt(uv.x * uv.x + uv.y * uv.y); return(l <= r && l >= r / 2); }
public override bool TryPointDeriv2At(double position, out GeoPoint2D point, out GeoVector2D deriv, out GeoVector2D deriv2) { point = PointAt(position); deriv = endPoint - startPoint; deriv2 = GeoVector2D.NullVector; return(true); }
/// <summary> /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.HitTest (BoundingCube, out GeoPoint2D)"/> /// </summary> /// <param name="bc"></param> /// <param name="uv"></param> /// <returns></returns> public override bool HitTest(BoundingCube bc, out GeoPoint2D uv) { GeoPoint[] cube = bc.Points; bool[] pos = new bool[8]; // any vertex of the cube on the plane? for (int i = 0; i < 8; ++i) { GeoPoint p = cube[i]; if (Math.Abs((toUnitPlane * p).z) < Precision.eps) { uv = PositionOf(p); return(true); } pos[i] = Orientation(p) < 0; } // any line of the cube interfering the plane? int[,] l = bc.LineNumbers; for (int k = 0; k < 12; ++k) { int i = l[k, 0]; int j = l[k, 1]; if (pos[i] != pos[j]) { GeoPoint2D[] erg = GetLineIntersection(cube[i], cube[j] - cube[i]); uv = erg[0]; return(true); } } // now the cube´s vertices are on one side only uv = GeoPoint2D.Origin; return(false); //convexity of the inner and outer points }
/// <summary> /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.Trim (double, double)"/> /// </summary> /// <param name="StartPos"></param> /// <param name="EndPos"></param> /// <returns></returns> public override ICurve2D Trim(double StartPos, double EndPos) { GeoPoint2D newStartPoint = PointAt(StartPos); GeoPoint2D newEndPoint = PointAt(EndPos); return(new Line2D(newStartPoint, newEndPoint)); }
public override void FindSnapPoint(SnapPointFinder spf) { if (spf.SnapToFaceSurface) { Plane pln = new Plane(location, directionWidth, directionHeight); GeoPoint ip; if (pln.Intersect(spf.SourceBeam.Location, spf.SourceBeam.Direction, out ip)) { GeoPoint2D ip2d = Geometry.GetPosition(pln.Project(ip), GeoPoint2D.Origin, pln.Project(directionWidth), pln.Project(directionHeight)); double linepos = Geometry.LinePar(spf.SourceBeam.Location, spf.SourceBeam.Direction, ip); if (linepos < spf.faceDist) { spf.faceDist = linepos; spf.Check(ip, this, SnapPointFinder.DidSnapModes.DidSnapToFaceSurface); } } } if (spf.SnapToObjectCenter) { GeoPoint Center = location + 0.5 * directionWidth + 0.5 * directionHeight; spf.Check(Center, this, SnapPointFinder.DidSnapModes.DidSnapToObjectCenter); } if (spf.SnapToObjectSnapPoint) { spf.Check(location, this, SnapPointFinder.DidSnapModes.DidSnapToObjectSnapPoint); spf.Check(location + directionWidth, this, SnapPointFinder.DidSnapModes.DidSnapToObjectSnapPoint); spf.Check(location + directionHeight, this, SnapPointFinder.DidSnapModes.DidSnapToObjectSnapPoint); spf.Check(location + directionWidth + directionHeight, this, SnapPointFinder.DidSnapModes.DidSnapToObjectSnapPoint); } }
/// <summary> /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.Reverse ()"/> /// </summary> public override void Reverse() { GeoPoint2D p = startPoint; startPoint = endPoint; endPoint = p; }
/// <summary> /// Returns the position of the provided point with a given precision /// </summary> /// <param name="p">The point to test</param> /// <param name="frameWidth">The precision: if the distance to a bounding line is smaller /// than this value, the point is considered as <see cref="Position.onframe"/></param> /// <returns>The position of the point</returns> public Position GetPosition(GeoPoint2D p, double frameWidth) { if (p.x < Left - frameWidth) { return(Position.outside); } if (p.x > Right + frameWidth) { return(Position.outside); } if (p.y < Bottom - frameWidth) { return(Position.outside); } if (p.y > Top + frameWidth) { return(Position.outside); } if (p.x > Left + frameWidth && p.x < Right - frameWidth && p.y > Bottom + frameWidth && p.y < Top - frameWidth) { return(Position.inside); } return(Position.onframe); }
/// <summary> /// Implements <see cref="Action.OnMouseMove"/>. If you override this method /// don't forget to call the bas implementation. /// </summary> /// <param name="e"><paramref name="Action.OnMouseMove.e"/></param> /// <param name="vw"><paramref name="Action.OnMouseMove.vw"/></param> public override void OnMouseMove(MouseEventArgs e, IView vw) { using (Frame.Project.Undo.ContextFrame(this)) { SnapPointFinder.DidSnapModes DidSnap; GeoPoint p = base.SnapPoint(e, fixPoint, vw, out DidSnap); // hier möglicherweise einige Fangmethoden ausschalten // der fixPoint und der aktuelle Punkt werden in die aktuelle Zeichenebene projiziert if (CalculateAngleEvent != null) { SetAngle(new Angle(CalculateAngleEvent(p))); } else { if (usesLocalPlane) { GeoPoint2D pp = localPlane.Project(p); SetAngle(new Angle(pp, GeoPoint2D.Origin)); } else { GeoPoint2D pp = ActiveDrawingPlane.Project(p); GeoPoint2D pfixpoint = ActiveDrawingPlane.Project(fixPoint); SetAngle(new Angle(pp, pfixpoint)); } } } }
internal void Add(IEnumerable <Edge> edges, Face onThisFace, double arrowsize, System.Drawing.Color clr, int debugHint) { Random rnd = new Random(); foreach (Edge edg in edges) { if (edg.Curve2D(onThisFace) == null) { continue; } int dbgh = debugHint; if (debugHint == -1) { dbgh = edg.GetHashCode(); } Add(edg.Curve2D(onThisFace), clr, dbgh); // noch einen Richtungspfeil zufügen GeoPoint2D[] arrowpnts = new GeoPoint2D[3]; double pos = 0.3 + rnd.NextDouble() * 0.4; // to have different positions when the same curve is displayed twice GeoVector2D dir = edg.Curve2D(onThisFace).DirectionAt(pos).Normalized; arrowpnts[1] = edg.Curve2D(onThisFace).PointAt(pos); arrowpnts[0] = arrowpnts[1] - arrowsize * dir + arrowsize * dir.ToLeft(); arrowpnts[2] = arrowpnts[1] - arrowsize * dir + arrowsize * dir.ToRight(); Polyline2D pl2d = new Polyline2D(arrowpnts); Add(pl2d, clr, edg.GetHashCode()); } }
public void Init(System.Drawing.Point SourcePoint, Projection projection, SnapModes SnapMode, int MaxDist) #endif { this.BestDist = double.MaxValue; this.BestObject = null; this.SnapPointIndex = 0; SourceBeam = projection.PointBeam(SourcePoint); this.SourcePoint = projection.ProjectionPlane.Intersect(SourceBeam); this.Projection = projection; this.SnapPoint = projection.DrawingPlanePoint(SourcePoint); // MaxDist die die maximale Entfernung des Fangpunktes vom aktuellen Punkt bezogen auf die ProjectionPlane #if WEBASSEMBLY GeoPoint2D p1 = projection.ProjectionPlane.Intersect(projection.PointBeam(new CADability.WebDrawing.Point(SourcePoint.X, SourcePoint.Y + MaxDist))); GeoPoint2D p2 = projection.ProjectionPlane.Intersect(projection.PointBeam(new CADability.WebDrawing.Point(SourcePoint.X + MaxDist, SourcePoint.Y))); GeoPoint2D p3 = projection.ProjectionPlane.Intersect(projection.PointBeam(new CADability.WebDrawing.Point(SourcePoint.X, SourcePoint.Y - MaxDist))); GeoPoint2D p4 = projection.ProjectionPlane.Intersect(projection.PointBeam(new CADability.WebDrawing.Point(SourcePoint.X - MaxDist, SourcePoint.Y))); #else GeoPoint2D p1 = projection.ProjectionPlane.Intersect(projection.PointBeam(new System.Drawing.Point(SourcePoint.X, SourcePoint.Y + MaxDist))); GeoPoint2D p2 = projection.ProjectionPlane.Intersect(projection.PointBeam(new System.Drawing.Point(SourcePoint.X + MaxDist, SourcePoint.Y))); GeoPoint2D p3 = projection.ProjectionPlane.Intersect(projection.PointBeam(new System.Drawing.Point(SourcePoint.X, SourcePoint.Y - MaxDist))); GeoPoint2D p4 = projection.ProjectionPlane.Intersect(projection.PointBeam(new System.Drawing.Point(SourcePoint.X - MaxDist, SourcePoint.Y))); #endif this.MaxDist = Math.Max(Math.Max(p1 | this.SourcePoint, p2 | this.SourcePoint), Math.Max(p3 | this.SourcePoint, p4 | this.SourcePoint)); pickArea = projection.GetPickSpace(new Rectangle(SourcePoint.X - MaxDist, SourcePoint.Y - MaxDist, 2 * MaxDist, 2 * MaxDist)); this.BasePointValid = false; this.SnapMode = SnapMode; this.DidSnap = DidSnapModes.DidNotSnap; faceDist = double.MaxValue; }