当前位置: 首页>>代码示例>>C#>>正文


C# Arc.GetPoints方法代码示例

本文整理汇总了C#中Arc.GetPoints方法的典型用法代码示例。如果您正苦于以下问题:C# Arc.GetPoints方法的具体用法?C# Arc.GetPoints怎么用?C# Arc.GetPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Arc的用法示例。


在下文中一共展示了Arc.GetPoints方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: importFileInternal

        public void importFileInternal(string path)
        {
            string ext = System.IO.Path.GetExtension(path).ToUpper();

            try
            {
                string contents = "";

                if (ext.Equals(".DXF"))
                {
                    DXF.DxfDocument doc = new DXF.DxfDocument();
                    doc.Load(path);
                    contents = "\r\n// import: " + System.IO.Path.GetFileName(path) + "\r\n\r\n";

                    double x, y;
                    double minx = double.MaxValue;
                    double miny = double.MaxValue;

                    foreach (DXF.Entities.Arc arc in doc.Arcs)
                    {
                        Arc a2 = new Arc(new PointF((float)arc.Center.X, (float)arc.Center.Y), (float)(arc.Radius * 2), -1, (float)(360 - arc.StartAngle), (float)(360 - arc.EndAngle));
                        PointF[] list = a2.GetPoints();
                        foreach (PointF p in list)
                        {
                            minx = Math.Min(minx, p.X);
                            miny = Math.Min(miny, p.Y);
                        }
                        /*
                        double a = 360 - arc.StartAngle;
                        double b = 360 - arc.EndAngle;

                        while (a < 0 || b < 0) { a += 360; b += 360; }

                        x = arc.Center.X + arc.Radius * Math.Sin( ToolpathUtilities.Radians( (float)a ));
                        y = arc.Center.Y + arc.Radius * Math.Cos( ToolpathUtilities.Radians( (float)a ));
                        minx = Math.Min(x, minx);
                        miny = Math.Min(y, miny);

                        x = arc.Center.X + arc.Radius * Math.Sin(ToolpathUtilities.Radians((float)b));
                        y = arc.Center.Y + arc.Radius * Math.Cos(ToolpathUtilities.Radians((float)b));
                        minx = Math.Min(x, minx);
                        miny = Math.Min(y, miny);

                        //minx = Math.Min(arc.Center.X, minx);
                        //miny = Math.Min(arc.Center.Y, miny);
                        */
                    }
                    foreach (DXF.Entities.Circle circle in doc.Circles)
                    {
                        x = circle.Center.X - circle.Radius;
                        y = circle.Center.Y - circle.Radius;
                        minx = Math.Min(x, minx);
                        miny = Math.Min(y, miny);
                    }
                    foreach (DXF.Entities.Line line in doc.Lines)
                    {
                        x = Math.Min(line.StartPoint.X, line.EndPoint.X);
                        y = Math.Min(line.StartPoint.Y, line.EndPoint.Y);
                        minx = Math.Min(x, minx);
                        miny = Math.Min(y, miny);
                    }

                    Console.WriteLine("Min {0:0.00}, {1:0.00}", minx, miny);
                    //minx = miny = 0;

                    foreach (DXF.Entities.Arc arc in doc.Arcs)
                    {
                        double arcLen = Math.PI * arc.Radius * 25.4 * 2; // diameter
                        double degrees = Math.Abs((0 - arc.EndAngle) - (0 - arc.StartAngle));
                        arcLen *= (degrees / 360);

                        contents += string.Format("\tARC {0:0.00}, {1:0.00}, {2:0.00}, {3:0.00}, {4:0.00} \n", // arc len {5:0.00}\n",
                            (arc.Center.X - minx) * 25.4, (arc.Center.Y - miny) * 25.4, arc.Radius * 25.4 * 2, 360 - arc.StartAngle, 360 - arc.EndAngle); // , arcLen);
                    }
                    foreach (DXF.Entities.Circle circle in doc.Circles)
                    {
                        contents += string.Format("\tCIRCLE {0:0.00}, {1:0.00}, {2:0.00}\n",
                            (circle.Center.X - minx) * 25.4, (circle.Center.Y - miny) * 25.4, circle.Radius * 25.4 * 2);
                    }
                    foreach (DXF.Entities.Line line in doc.Lines)
                    {
                        contents += string.Format("\tLINE {0:0.00}, {1:0.00}, {2:0.00}, {3:0.00}\n",
                            (line.StartPoint.X - minx) * 25.4, (line.StartPoint.Y - miny) * 25.4, (line.EndPoint.X - minx) * 25.4, (line.EndPoint.Y - miny) * 25.4);
                    }
                }
                else // try a gerb import
                {
                    contents = new Gerbers.Gerbers().TranslateGerber(path);
                }

                Invoke(new Action<string>((str) =>
                {
                    if (cleanImport) editor.Text = str;
                    else editor.Text += "\r\n" + str;
                }), new object[] { contents });

                Invoke(new Action<string>((str) => { statusMessage.Text = str; }), new object[] { "Import OK" });
                Invoke(new Action(() => { runParse(); }));

                if (cleanImport)
//.........这里部分代码省略.........
开发者ID:duncanwerner,项目名称:chopper,代码行数:101,代码来源:ChopperForm.cs


注:本文中的Arc.GetPoints方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。