示例#1
0
        private static Point3dCollection SamplePoints(EllipticalArc3d arc, bool isCounterClockwise)
        {
            double num = arc.GetLength(arc.StartAngle, arc.EndAngle, 0.0) / 1000.0;

            PointOnCurve3d[]  samplePoints      = arc.GetSamplePoints(arc.StartAngle, arc.EndAngle, num);
            Point3dCollection point3dCollection = new Point3dCollection();

            if (isCounterClockwise)
            {
                PointOnCurve3d[] array = samplePoints;
                for (int i = 0; i < array.Length; i++)
                {
                    PointOnCurve3d pointOnCurve3d = array[i];
                    point3dCollection.Add(pointOnCurve3d.GetPoint());
                }
            }
            else
            {
                int num2 = samplePoints.Length;
                for (int j = num2 - 1; j >= 0; j--)
                {
                    point3dCollection.Add(samplePoints[j].GetPoint());
                }
            }
            return(point3dCollection);
        }
示例#2
0
        public static Ellipse ToCadEllipse(EllipticArc arc, double defaultElevation)
        {
            EllipticArc ellipticArc = (EllipticArc)Utility.CloneObject(arc);
            PointN      pointN      = (PointN)ellipticArc.CenterPoint;

            if (double.IsNaN(pointN.Z))
            {
                pointN.Z = 0.0;
            }
            if (!pointN.ZSpecified)
            {
                pointN.Z = defaultElevation;
                ((PointN)ellipticArc.FromPoint).Z = defaultElevation;
                ((PointN)ellipticArc.ToPoint).Z   = defaultElevation;
            }
            Point3d point3d  = GIS2CAD.ToCadPoint3d((PointN)ellipticArc.FromPoint);
            Point3d point3d2 = GIS2CAD.ToCadPoint3d((PointN)ellipticArc.ToPoint);

            if (!ellipticArc.EllipseStd)
            {
                AGSEllipticalArc.TransformToEllipseStd(ref ellipticArc);
            }
            PointN          pointN2         = (PointN)ellipticArc.FromPoint;
            PointN          pointN3         = (PointN)ellipticArc.ToPoint;
            double          arg_B7_0        = pointN2.X;
            double          arg_BF_0        = pointN2.Y;
            double          num             = ellipticArc.MinorMajorRatio * ellipticArc.MinorMajorRatio;
            double          x               = pointN2.X;
            double          y               = pointN2.Y;
            double          x2              = pointN3.X;
            double          y2              = pointN3.Y;
            double          num2            = Math.Sqrt(num * x * x + y * y);
            double          num3            = Math.Sqrt(num * x2 * x2 + y2 * y2);
            double          num4            = 0.5 * (num2 + num3);
            double          num5            = num4 / ellipticArc.MinorMajorRatio;
            Vector3d        vector3d        = new Vector3d(num5, 0.0, 0.0);
            Vector3d        vector3d2       = new Vector3d(0.0, num4, 0.0);
            Vector3d        vector3d3       = vector3d.RotateBy(ellipticArc.Rotation, Vector3d.ZAxis);
            Vector3d        vector3d4       = vector3d2.RotateBy(ellipticArc.Rotation, Vector3d.ZAxis);
            Point3d         point3d3        = GIS2CAD.ToCadPoint3d(pointN);
            EllipticalArc3d ellipticalArc3d = new EllipticalArc3d(point3d3, vector3d3, vector3d4, num5, num4);
            double          num6            = ellipticalArc3d.GetParameterOf(point3d);
            double          num7            = ellipticalArc3d.GetParameterOf(point3d2);

            if (!ellipticArc.IsCounterClockwise)
            {
                double num8 = num6;
                num6 = num7;
                num7 = num8;
            }
            return(new Ellipse(point3d3, Vector3d.ZAxis, vector3d3, ellipticArc.MinorMajorRatio, num6, num7));
        }
示例#3
0
        public static Point3dCollection SamplePoints(EllipticArc inArc, double defaultElevation)
        {
            Ellipse         ellipse           = AGSEllipticalArc.ToCadEllipse(inArc, defaultElevation);
            Point3d         center            = ellipse.Center;
            Vector3d        majorAxis         = ellipse.MajorAxis;
            Vector3d        minorAxis         = ellipse.MinorAxis;
            double          majorRadius       = ellipse.MajorRadius;
            double          minorRadius       = ellipse.MinorRadius;
            double          parameterAtAngle  = ellipse.GetParameterAtAngle(ellipse.StartAngle);
            double          parameterAtAngle2 = ellipse.GetParameterAtAngle(ellipse.EndAngle);
            EllipticalArc3d arc = new EllipticalArc3d(center, majorAxis, minorAxis, majorRadius, minorRadius, parameterAtAngle, parameterAtAngle2);

            return(AGSEllipticalArc.SamplePoints(arc, inArc.IsCounterClockwise));
        }
        /// <summary>
        /// Get the point of selected entities
        /// </summary>
        private void GetPoint()
        {
            if (PickedEntities == null)
            {
                return;
            }

            using (var trans = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
            {
                foreach (var id in PickedEntities)
                {
                    DBObject obj = null;
                    try
                    {
                        obj = trans.GetObject(id, OpenMode.ForRead);
                    }
                    catch (Exception e)
                    {
                        Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage($"\n{e.Message}");
                    }

                    if (obj is Line)
                    {
                        var line = obj as Line;
                        _keyPoints.Add(line.StartPoint);
                        _keyPoints.Add(line.EndPoint);
                    }
                    else if (obj is Circle)
                    {
                        var circle = obj as Circle;
                        _keyPoints.Add(circle.Center);
                    }
                    else if (obj is Arc)
                    {
                        var arc = obj as Arc;
                        var a   = new CircularArc3d(arc.Center, arc.Normal, arc.Radius);
                        _keyPoints.Add(a.Center);
                        _keyPoints.Add(a.StartPoint);
                        _keyPoints.Add(a.EndPoint);
                    }
                    else if (obj is Ellipse)
                    {
                        var ellipse = obj as Ellipse;
                        var e       = new EllipticalArc3d(ellipse.Center, ellipse.MajorAxis, ellipse.MinorAxis,
                                                          ellipse.MajorRadius, ellipse.MinorRadius);
                        _keyPoints.Add(ellipse.Center);

                        // ellipse arc
                        if (!e.IsCircular())
                        {
                            _keyPoints.Add(e.StartPoint);
                            _keyPoints.Add(e.EndPoint);
                        }
                    }
                    else if (obj is Polyline)
                    {
                        var poly = obj as Polyline;
                        for (var i = 0; i < poly.NumberOfVertices; i++)
                        {
                            _keyPoints.Add(poly.GetPoint3dAt(i));

                            // Closed polyline only has NumberOfVertices-1 segments
                            if (!poly.Closed && i == poly.NumberOfVertices - 1)
                            {
                                continue;
                            }

                            var segType = poly.GetSegmentType(i);
                            if (segType == SegmentType.Arc)
                            {
                                var arc = poly.GetArcSegmentAt(i);
                                _keyPoints.Add(arc.Center);
                            }
                        }
                    }
                }
            }
        }
示例#5
0
        private static Spline BuildSpline(EllipticalArc3d arc, bool isCounterClockwise)
        {
            Point3dCollection point3dCollection = AGSEllipticalArc.SamplePoints(arc, isCounterClockwise);

            return(new Spline(point3dCollection, 2, 0.0));
        }
示例#6
0
        public void Ge2DbMethod()
        {
            EllipticalArc3d arc1 = new EllipticalArc3d(Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, 2.0, 0.5);

            GetCurveObjectId(arc1);
        }