Exemple #1
0
        /// <summary>
        /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.Clone ()"/>
        /// </summary>
        /// <returns></returns>
        public override ICurve2D Clone()
        {
            EllipseArc2D res = new EllipseArc2D(Center, majorAxis, minorAxis, startPar, sweepPar, left, right, bottom, top);

            res.UserData.CloneFrom(this.UserData);
            return(res);
        }
Exemple #2
0
        /// <summary>
        /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.GetModified (ModOp2D)"/>
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public override ICurve2D GetModified(ModOp2D m)
        {
            // es ist wichtig hier zu überschreiben, die Basisfunktionalität macht aus einem 360°
            // Kreisbogen einen Kreis und der Anfangspunkt geht verloren. Diese Information ist aber
            // für die Edges wichtig.
            if (m.IsIsogonal)
            {
                bool cc = sweep > 0.0;
                if (m.Determinant < 0.0)
                {
                    cc = !cc;
                }
                Arc2D res = new Arc2D(m * Center, m.Factor * Radius, m * StartPoint, m * EndPoint, cc);
                if (m.Determinant < 0.0)
                {
                    res.sweep = -sweep; // das schaltet die Fälle aus, wo Unsicherheit zwischen 0 und 360° besteht
                }
                else
                {
                    res.sweep = sweep;
                }
                return(res);
            }
            else
            {
                //double sw = sweep;
                //if (m.Determinant < 0.0) sw = -sw;
                GeoVector2D majorAxis;
                GeoVector2D minorAxis;
                GeoPoint2D  left, right, bottom, top;
                bool        cc = sweep > 0.0;
                if (m.Determinant < 0.0)
                {
                    cc = !cc;
                }
                majorAxis = m * (Radius * GeoVector2D.XAxis);
                minorAxis = m * (Radius * GeoVector2D.YAxis);
                if (Math.Abs(majorAxis.Length - minorAxis.Length) < (majorAxis.Length + minorAxis.Length) * 1e-6)
                {
                    return(new Arc2D(m * Center, Math.Abs(m.Determinant * Radius), m * StartPoint, m * EndPoint, cc));
                }
                Geometry.PrincipalAxis(m * Center, m * (Radius * GeoVector2D.XAxis), m * (Radius * GeoVector2D.YAxis), out majorAxis, out minorAxis, out left, out right, out bottom, out top, false);
                // geändert wg. Fehler in IsIsogonal Fall, noch nicht getestet
                return(EllipseArc2D.Create(m * Center, majorAxis, minorAxis, m * StartPoint, m * EndPoint, cc));

                //if (m.Determinant < 0.0)
                //{
                //    return new EllipseArc2D(m * Center, m * (Radius * GeoVector2D.XAxis), m * (Radius * GeoVector2D.YAxis), start + sweep, sw, left, right, bottom, top);
                //}
                //else
                //{
                //    return new EllipseArc2D(m * Center, m * (Radius * GeoVector2D.XAxis), m * (Radius * GeoVector2D.YAxis), start, sw, left, right, bottom, top);
                //}
            }
        }
Exemple #3
0
        /// <summary>
        /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.GetFused (ICurve2D, double)"/>
        /// </summary>
        /// <param name="toFuseWith"></param>
        /// <param name="precision"></param>
        /// <returns></returns>
        public override ICurve2D GetFused(ICurve2D toFuseWith, double precision)
        {
            if (toFuseWith is Ellipse2D && !(toFuseWith is EllipseArc2D))
            {
                return(toFuseWith.GetFused(this, precision));
            }
            if (toFuseWith is EllipseArc2D)
            {
                EllipseArc2D a2d = (toFuseWith as EllipseArc2D);
                // hier wird vorausgesetzt, dass majrad>minrad immer gilt. Stimmt das?
                if ((Center | a2d.Center) + Math.Abs(majrad - a2d.majrad) + Math.Abs(minrad - a2d.minrad) < precision)
                {   // alle zusammen kleiner als precision, vielleich beim Bogen zu streng
                    // weitere Bedingung: Achsen müssen übereinstimmen.
                    // dazu müsste man bei vertauschten Richtungen noch mehr Grips reinstecken...

                    EllipseArc2D a1, a2;
                    if (Math.Abs(this.sweepPar) > Math.Abs(a2d.sweepPar))
                    {
                        a1 = this;
                        a2 = a2d;
                    }
                    else
                    {
                        a1 = a2d;
                        a2 = this;
                    }
                    if (a1.sweepPar * a2.sweepPar < 0.0)
                    {
                        a2.Reverse();
                    }
                    // a1 ist länger als a2. Wenn es verschmelzen soll, dann muss der Start- oder der Endpunkt von a2
                    // innerhalb von a1 liegen

                    // Mittelpunkt und radius ist ja schon getestet
                    double pos1 = a1.PositionOf(a2.StartPoint); // vor dem Anfang oder auf dem Bogen
                    double pos2 = a1.PositionOf(a2.EndPoint);   // nach dem Ende oder auf dem Bogen
                    // System.Diagnostics.Trace.WriteLine("pos1, pos2: " + pos1.ToString() + ", " + pos2.ToString());
                    bool pos1ok = a1.IsParameterOnCurve(pos1);
                    bool pos2ok = a1.IsParameterOnCurve(pos2);
                    if (pos1ok && pos2ok)
                    {   // beide Punkte sind drauf
                        return(a1.Clone());
                    }
                    else if (pos1ok)
                    {
                        return(Create(a1.center, a1.majorAxis, a1.minorAxis, a1.startPoint, a2.endPoint, a1.sweepPar > 0.0));
                    }
                    else if (pos2ok)
                    {
                        return(Create(a1.center, a1.majorAxis, a1.minorAxis, a2.startPoint, a1.endPoint, a1.sweepPar > 0.0));
                    }
                }
            }
            return(null);
        }
Exemple #4
0
        /// <summary>
        /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.Copy (ICurve2D)"/>
        /// </summary>
        /// <param name="toCopyFrom"></param>
        public override void Copy(ICurve2D toCopyFrom)
        {
            EllipseArc2D c = toCopyFrom as EllipseArc2D;

            start        = c.start;
            sweep        = c.sweep;
            startPar     = c.startPar;
            sweepPar     = c.sweepPar;
            startPoint   = c.startPoint;
            endPoint     = c.endPoint;
            startQuad    = c.startQuad;
            endQuad      = c.endQuad;
            crossingZero = c.crossingZero;
            base.Copy(toCopyFrom);
        }
Exemple #5
0
        /// <summary>
        /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.CloneReverse (bool)"/>
        /// </summary>
        /// <param name="reverse"></param>
        /// <returns></returns>
        public override ICurve2D CloneReverse(bool reverse)
        {
            ICurve2D res;

            if (reverse)
            {
                res = new EllipseArc2D(Center, majorAxis, minorAxis, startPar + sweepPar, -sweepPar, left, right, bottom, top);
            }
            else
            {
                res = Clone();
            }
            res.UserData.CloneFrom(this.UserData);
            return(res);
        }
Exemple #6
0
        /// <summary>
        /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.GetModified (ModOp2D)"/>
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public override ICurve2D GetModified(ModOp2D m)
        {
#if DEBUG
            ////DebuggerContainer dc = new DebuggerContainer();
            ////GeoPoint[] tst = new GeoPoint[10];
            ////for (int i = 0; i < 10; i++)
            ////{
            ////    tst[i] = new GeoPoint(PointAt(i / 9.0));
            ////}
            ////Polyline pl = Polyline.Construct();
            ////try
            ////{
            ////    pl.SetPoints(tst, false);
            ////    dc.Add(pl, 0);
            ////}
            ////catch { }
            ////EllipseArc2D dbg = EllipseArc2D.Create(m * center, m * majorAxis, m * minorAxis, m * StartPoint, m * EndPoint, counterClock);
            ////for (int i = 0; i < 10; i++)
            ////{
            ////    tst[i] = new GeoPoint(dbg.PointAt(i / 9.0));
            ////}
            ////pl = Polyline.Construct();
            ////try
            ////{
            ////    pl.SetPoints(tst, false);
            ////    dc.Add(pl, 1);
            ////}
            ////catch { }
#endif
            EllipseArc2D res = EllipseArc2D.Create(m * center, m * majorAxis, m * minorAxis, m * StartPoint, m * EndPoint, counterClock);
            if (Math.Abs(res.sweepPar) < 1e-6 && Math.Abs(this.sweepPar) > Math.PI * 2.0 - 1e-6)
            {
                res.sweepPar = this.sweepPar;
            }
            return(res);
        }