Exemplo n.º 1
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);
                //}
            }
        }
Exemplo n.º 2
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);
        }