Ejemplo n.º 1
0
        /// <summary>
        /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.GetExtent ()"/>
        /// </summary>
        /// <returns></returns>
        public override BoundingRect GetExtent()
        {
            BoundingRect res = BoundingRect.EmptyBoundingRect;

            res.MinMax(startPoint);
            res.MinMax(endPoint);
            return(res);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.GetExtent ()"/>
        /// </summary>
        /// <returns></returns>
        public override BoundingRect GetExtent()
        {
            BoundingRect res = BoundingRect.EmptyBoundingRect;

            res.MinMax(left);
            res.MinMax(top);
            res.MinMax(bottom);
            res.MinMax(right);
            return(res);
        }
Ejemplo n.º 3
0
        public BoundingRect GetExtent(Projection projection, bool Use2DWorld, bool RegardLineWidth)
        {
            BoundingRect res = BoundingRect.EmptyBoundingRect;

            foreach (IGeoObject go in list)
            {
                res.MinMax(go.GetExtent(projection, ExtentPrecision.Raw));
            }
            return(res);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.GetExtent ()"/>
        /// </summary>
        /// <returns></returns>
        public override BoundingRect GetExtent()
        {
            BoundingRect res = BoundingRect.EmptyBoundingRect;

            for (int i = 0; i < vertex.Length; ++i)
            {
                res.MinMax(vertex[i]);
            }
            return(res);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Overrides <see cref="CADability.Actions.Action.OnMouseUp (MouseEventArgs, IView)"/>
        /// </summary>
        /// <param name="e"></param>
        /// <param name="vw"></param>
        public override void OnMouseUp(MouseEventArgs e, IView vw)
        {
            OnMouseMove(e, vw); // damit wird Invalidate... aufgerufen
            switch (Mode)
            {
            case 0:
                Mode        = 1;
                SecondPoint = FirstPoint;
                break;

            case 1:
                Mode = -1;
                BoundingRect mm = BoundingRect.EmptyBoundingRect;
                mm.MinMax(vw.Projection.PointWorld2D(FirstPoint));
                mm.MinMax(vw.Projection.PointWorld2D(SecondPoint));
                base.RemoveThisAction();     // damit werden auch die PaintHandler abgemeldet
                                             // und es gibt noch ungültige Bereiche im Active. D.h. es wird gelöscht.
                vw.ZoomToRect(mm);
                break;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.GetExtent ()"/>
        /// </summary>
        /// <returns></returns>
        public override BoundingRect GetExtent()
        {
            double exc = Math.Min(majrad, minrad) / Math.Max(majrad, minrad); // die sind doch immer positiv, oder?

            if (exc < 1e-4)
            {
                return(this.Approximate(true, Precision.eps).GetExtent());
            }
            BoundingRect res = BoundingRect.EmptyBoundingRect;

            res.MinMax(startPoint);
            res.MinMax(endPoint);
            if (IsPointOnArc(left))
            {
                res.MinMax(left);
            }
            if (IsPointOnArc(right))
            {
                res.MinMax(right);
            }
            if (IsPointOnArc(bottom))
            {
                res.MinMax(bottom);
            }
            if (IsPointOnArc(top))
            {
                res.MinMax(top);
            }
            return(res);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Overrides <see cref="CADability.GeoObject.IGeoObjectImpl.GetExtent (Projection, ExtentPrecision)"/>
        /// </summary>
        /// <param name="projection"></param>
        /// <param name="extentPrecision"></param>
        /// <returns></returns>
        public override BoundingRect GetExtent(Projection projection, ExtentPrecision extentPrecision)
        {
            BoundingRect res = BoundingRect.EmptyBoundingRect;

            // lock (this) kann sich containedObjects währenddessen ändern???
            {
                foreach (IGeoObject go in containedObjects)
                {
                    res.MinMax(go.GetExtent(projection, extentPrecision));
                }
            }
            return(res);
        }
Ejemplo n.º 8
0
        public ISurface AdaptToCurves(IEnumerable <ICurve> curves)
        {
            BoundingRect domain = BoundingRect.EmptyBoundingRect;

            foreach (ICurve curve in curves)
            {
                ICurve2D c2d = periodicSurface.GetProjectedCurve(curve, 0.0);
                if (domain.IsEmpty())
                {
                    domain = c2d.GetExtent();
                }
                else
                {
                    SurfaceHelper.AdjustPeriodic(periodicSurface, domain, c2d);
                    domain.MinMax(c2d.GetExtent());
                }
            }
            return(new NonPeriodicSurface(periodicSurface, domain));
        }
Ejemplo n.º 9
0
        public BoundingRect GetExtent()
        {
            BoundingRect res = BoundingRect.EmptyBoundingRect;

            foreach (Joint lp in Joints)
            {
                GeoPoint2D p;
                if (lp.StartCluster == this)
                {
                    p = lp.curve.StartPoint;
                }
                else
                {
                    p = lp.curve.EndPoint;
                }
                res.MinMax(p);
            }
            return(res);
        }
Ejemplo n.º 10
0
        public CurveGraph(ICurve2D[] curves, double maxGap)
        {   // aus den ICurve2D wird eine Clusterliste erzeugt (Start- und Endpunkte)
            this.maxGap = maxGap;
            BoundingRect ext = BoundingRect.EmptyBoundingRect;

            for (int i = 0; i < curves.Length; ++i)
            {
                ext.MinMax(curves[i].GetExtent());
            }
            // clusterSize = (ext.Width + ext.Height) * 1e-8;
            clusterSize            = maxGap;
            clusterTree            = new QuadTree(ext);
            clusterTree.MaxDeepth  = 8;
            clusterTree.MaxListLen = 3;
            clusterSet             = new UntypedSet();
            for (int i = 0; i < curves.Length; ++i)
            {
                if (curves[i].Length > clusterSize)
                {
                    Insert(curves[i]);
                }
            }
        }
Ejemplo n.º 11
0
        static public CurveGraph CrackCurves(GeoObjectList l, Plane plane, double maxGap)
        {   // alle Kurven in l werden in die Ebene plane projiziert. Das ist mal ein erster Ansatz
            // Man könnte auch gemeinsame Ebenen finden u.s.w.
            ArrayList    curves = new ArrayList();
            BoundingRect ext    = BoundingRect.EmptyBoundingRect;

            foreach (IGeoObject go in l)
            {
                ICurve cv = go as ICurve;
                if (cv != null)
                {
                    ICurve2D cv2 = cv.GetProjectedCurve(plane);
                    if (cv2 != null)
                    {
                        // "3d" wird nur verwendet um hinterher aus den Originalkurven die Ebene zu bestimmen
                        // in die alles zurücktranformiert wird. Besser würde man vermutlich mit "plane" arbeiten
                        // so wie es hier reinkommt.
                        if (cv2 is Path2D && (cv2 as Path2D).GetSelfIntersections().Length > 0)
                        {   // ein sich selbst überschneidender Pfad muss aufgelöst werden
                            ICurve2D[] sub = (cv2 as Path2D).SubCurves;
                            curves.AddRange(sub);
                            for (int i = 0; i < sub.Length; ++i)
                            {
                                sub[i].UserData.Add("3d", cv);
                            }
                            ext.MinMax(cv2.GetExtent());
                        }
                        else
                        {
                            cv2.UserData.Add("3d", cv);
                            curves.Add(cv2);
                            ext.MinMax(cv2.GetExtent());
                        }
                    }
                }
            }
            if (curves.Count == 0)
            {
                return(null);
            }
            QuadTree qt = new QuadTree(ext);

            qt.MaxDeepth  = 8;
            qt.MaxListLen = 3;
            for (int i = 0; i < curves.Count; ++i)
            {
                qt.AddObject(curves[i] as ICurve2D);
            }
            // jetzt alle mit allen schneiden und die Schnipsel in eine weitere Liste stecken
            ArrayList snippet = new ArrayList();

            for (int i = 0; i < curves.Count; ++i)
            {
                ICurve2D    cv1 = curves[i] as ICurve2D;
                ArrayList   intersectionPoints = new ArrayList(); // double
                ICollection closecurves        = qt.GetObjectsCloseTo(cv1);
                foreach (ICurve2D cv2 in closecurves)
                {
                    if (cv2 != cv1)
                    {
                        //if ((cv1 is Line2D && (cv1 as Line2D).Length > 10 && (cv1 as Line2D).Length < 15) ||
                        //    (cv2 is Line2D && (cv2 as Line2D).Length > 10 && (cv2 as Line2D).Length < 15))
                        //{
                        //}
                        GeoPoint2DWithParameter[] isp = cv1.Intersect(cv2);
                        for (int k = 0; k < isp.Length; ++k)
                        {
                            if (cv2.IsParameterOnCurve(isp[k].par2) && 0.0 < isp[k].par1 && isp[k].par1 < 1.0)
                            {
                                intersectionPoints.Add(isp[k].par1);
                            }
                        }
                    }
                }
                if (intersectionPoints.Count == 0)
                {
                    snippet.Add(cv1);
                }
                else
                {
                    intersectionPoints.Add(0.0);
                    intersectionPoints.Add(1.0); // damit sinds mindesten 3
                    double[] pps = (double[])intersectionPoints.ToArray(typeof(double));
                    Array.Sort(pps);
                    for (int ii = 1; ii < pps.Length; ++ii)
                    {
                        if (pps[ii - 1] < pps[ii])
                        {
                            ICurve2D cv3 = cv1.Trim(pps[ii - 1], pps[ii]);
                            if (cv3 != null)
                            {
#if DEBUG
                                GeoPoint2D dbg1 = cv1.PointAt(pps[ii - 1]);
                                GeoPoint2D dbg2 = cv1.PointAt(pps[ii]);
                                GeoPoint2D dbg3 = cv3.StartPoint;
                                GeoPoint2D dbg4 = cv3.EndPoint;
                                double     d1   = dbg1 | dbg3;
                                double     d2   = dbg2 | dbg4;
#endif
                                cv3.UserData.Add("3d", cv1.UserData.GetData("3d"));
                                snippet.Add(cv3);
                            }
                        }
                    }
                }
            }
            // snippet ist jetzt die Liste aller Schnipsel
            return(new CurveGraph((ICurve2D[])snippet.ToArray(typeof(ICurve2D)), maxGap));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.GetExtent ()"/>
        /// </summary>
        /// <returns></returns>
        public override BoundingRect GetExtent()
        {
            int StartQuadrant = start.Quadrant;
            int EndQuadrant   = (start + sweep).Quadrant;
            int numQuads;

            if (sweep < 0.0)
            {
                numQuads = StartQuadrant - EndQuadrant;
            }
            else
            {
                numQuads = EndQuadrant - StartQuadrant;
            }
            if (numQuads < 0)
            {
                numQuads += 4;
            }
            // 19.8.15: die folgende Zeile verworfen, dafür die Abfrage "if (EndQuadrant == StartQuadrant)" wieder aktiviert
            // führt definitiv zum falschen Ergebnis, wenn mehr als 270° und eine Achse nicht im Bogen
            // if (Math.Abs(sweep) > 3 * Math.PI / 2) numQuads = 4; // mehr als 270°
            if (Math.Abs(sweep) >= 2.0 * Math.PI - 1e-7)
            {   // bei ganz rum und start auf 360° gabs ein Problem
                numQuads = 4;
            }
            else if (EndQuadrant == StartQuadrant)
            {   // muss entweder kleiner 90° oder größer 270° sein, d.h. wenns mehr als halbrum geht, dann alle Quadranten betroffen
                if (Math.Abs(sweep) > Math.PI)
                {
                    numQuads = 4;
                }
            }
            BoundingRect res = BoundingRect.EmptyBoundingRect;

            if (sweep < 0.0)
            {   // rechtsrum
                int q = StartQuadrant;
                for (int i = 0; i < numQuads; ++i)
                {
                    switch (q) // Achse zur Rechten betrachten
                    {
                    case 0: res.MinMax(new GeoPoint2D(Center.x + Radius, Center.y)); break;

                    case 1: res.MinMax(new GeoPoint2D(Center.x, Center.y + Radius)); break;

                    case 2: res.MinMax(new GeoPoint2D(Center.x - Radius, Center.y)); break;

                    case 3: res.MinMax(new GeoPoint2D(Center.x, Center.y - Radius)); break;
                    }
                    q -= 1;
                    if (q < 0)
                    {
                        q += 4;
                    }
                }
            }
            else
            {   // linksrum
                int q = StartQuadrant;
                if (q > 3)
                {
                    q -= 4;
                }
                for (int i = 0; i < numQuads; ++i)
                {
                    switch (q) // Achse zur Linken betrachten
                    {
                    case 4:
                    case 0: res.MinMax(new GeoPoint2D(Center.x, Center.y + Radius)); break;

                    case 1: res.MinMax(new GeoPoint2D(Center.x - Radius, Center.y)); break;

                    case 2: res.MinMax(new GeoPoint2D(Center.x, Center.y - Radius)); break;

                    case 3: res.MinMax(new GeoPoint2D(Center.x + Radius, Center.y)); break;
                    }
                    q += 1;
                    if (q > 3)
                    {
                        q -= 4;
                    }
                }
            }
            res.MinMax(StartPoint);
            res.MinMax(EndPoint);
            return(res);
        }
Ejemplo n.º 13
0
 public void Add(IQuadTreeInsertableZ toAdd)
 {
     allObjects.AddObject(toAdd);
     extent.MinMax(toAdd.GetExtent());
 }