Esempio n. 1
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Dwg_Entity_TEXT obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Esempio n. 2
0
        public void LoadFile()
        {
            Dwg_Data       dwg_Data = new Dwg_Data();
            Dwg_Object_Ref dwg      = new Dwg_Object_Ref();

            string path = "l0949.dwg";

            //string path = "example_2010.dwg";


            LibreDWG.dwg_read_file(path, dwg_Data);

            //LibreDWG.dwg_getall_POLYLINE_2D(dwg_Data);



            SWIGTYPE_p_int error = null;

            for (uint i = 0; i < dwg_Data.num_objects; i++)
            {
                var x = LibreDWG.dwg_get_object(dwg_Data, i);


                switch ((Dwg_Object_Type)Enum.ToObject(typeof(Dwg_Object_Type), x.type))
                {
                case Dwg_Object_Type.DWG_TYPE_UNUSED:
                    break;

                case Dwg_Object_Type.DWG_TYPE_TEXT:
                    Console.WriteLine("Text");
                    Dwg_Entity_TEXT dwg_Entity_TEXT = x.tio.entity.tio.TEXT;
                    texts.Add(new Text(dwg_Entity_TEXT.text_value, (float)dwg_Entity_TEXT.insertion_pt.x, (float)dwg_Entity_TEXT.insertion_pt.y, (float)dwg_Entity_TEXT.height));
                    FindMin(Convert.ToInt32(dwg_Entity_TEXT.insertion_pt.x), Convert.ToInt32(dwg_Entity_TEXT.insertion_pt.y));
                    break;

                case Dwg_Object_Type.DWG_TYPE_SPLINE:
                    Console.WriteLine("Text");
                    Dwg_Entity_SPLINE dwg_Entity_SPLINE = x.tio.entity.tio.SPLINE;


                    if (dwg_Entity_SPLINE.fit_pts != null)
                    {
                        var ptx = dwg_Entity_SPLINE.fit_pts.x;
                        var pty = dwg_Entity_SPLINE.fit_pts.y;

                        spline.Add(new Polygon3d((float)ptx, (float)pty));
                        FindMin((int)ptx, (int)pty);
                    }

                    if (dwg_Entity_SPLINE.ctrl_pts != null)
                    {
                        var ptx = dwg_Entity_SPLINE.ctrl_pts.x;
                        var pty = dwg_Entity_SPLINE.ctrl_pts.y;

                        spline.Add(new Polygon3d((float)ptx, (float)pty));
                        FindMin((int)ptx, (int)pty);
                    }


                    break;

                case Dwg_Object_Type.DWG_TYPE_POINT:
                    Console.WriteLine("Text");
                    Dwg_Entity_POINT point = x.tio.entity.tio.POINT;
                    pkt.Add(new Points(point.x, point.y));
                    FindMin((int)point.x, (int)point.y);


                    break;


                case Dwg_Object_Type.DWG_TYPE_MTEXT:
                    Dwg_Entity_MTEXT mtext = x.tio.entity.tio.MTEXT;
                    mmtext.Add(new Text(mtext.text, (float)mtext.insertion_pt.x, (float)mtext.insertion_pt.y, (float)mtext.text_height));
                    FindMin(Convert.ToInt32(mtext.insertion_pt.x), Convert.ToInt32(mtext.insertion_pt.y));
                    break;

                case Dwg_Object_Type.DWG_TYPE_MLINE:
                    Dwg_Entity_MLINE mline = x.tio.entity.tio.MLINE;
                    for (int k = 0; k < mline.num_lines; k++)
                    {
                        var xyza = mline.base_point;
                    }


                    break;

                case Dwg_Object_Type.DWG_TYPE_SOLID:
                    Dwg_Entity_SOLID solid = x.tio.entity.tio.SOLID;
                    solids.Add(new Solid((float)solid.corner1.x, (float)solid.corner1.y, (float)solid.corner2.x, (float)solid.corner2.y, (float)solid.corner3.x, (float)solid.corner3.y, (float)solid.corner4.x, (float)solid.corner4.y));
                    FindMin((int)solid.corner1.x, (int)solid.corner1.y);
                    FindMin((int)solid.corner2.x, (int)solid.corner2.y);
                    FindMin((int)solid.corner3.x, (int)solid.corner3.y);
                    FindMin((int)solid.corner4.x, (int)solid.corner4.y);
                    break;


                case Dwg_Object_Type.DWG_TYPE_HATCH:
                    Dwg_Entity_HATCH hatch = x.tio.entity.tio.HATCH;

                    if (hatch.paths.polyline_paths != null)
                    {
                        hatchList.Add(new Polygon2d((float)hatch.paths.polyline_paths.point.x, (float)hatch.paths.polyline_paths.point.y));

                        FindMin(Convert.ToInt32(hatch.paths.polyline_paths.point.x), Convert.ToInt32(hatch.paths.polyline_paths.point.y));
                    }
                    break;

                case Dwg_Object_Type.DWG_TYPE_LWPOLYLINE:
                    Console.WriteLine("LWPOLYLINE");
                    Dwg_Entity_LWPOLYLINE pol3d = x.tio.entity.tio.LWPOLYLINE;
                    lines.Add(new Lines((float)pol3d.points.x, (float)pol3d.extrusion.y));
                    FindMin(Convert.ToInt32(pol3d.points.x), Convert.ToInt32(pol3d.points.y));
                    break;

                case Dwg_Object_Type.DWG_TYPE_VERTEX_2D:
                    Dwg_Entity_VERTEX_2D linear = x.tio.entity.tio.VERTEX_2D;
                    poly2.Add(new Polygon2d((float)linear.point.x, (float)linear.point.y));
                    FindMin((int)linear.point.x, (int)linear.point.y);
                    break;

                case Dwg_Object_Type.DWG_TYPE_ARC:
                    Dwg_Entity_ARC arc = x.tio.entity.tio.ARC;
                    arcs.Add(new Arc((float)arc.center.x, (float)arc.center.y, (float)arc.radius, (float)(Math.Round(arc.start_angle, 2)), (float)(Math.Round(arc.end_angle, 2))));

                    FindMin(Convert.ToInt32(arc.center.x), Convert.ToInt32(arc.center.y));
                    break;

                case Dwg_Object_Type.DWG_TYPE_CAMERA:

                    break;

                case Dwg_Object_Type.DWG_TYPE_CIRCLE:
                    Dwg_Entity_CIRCLE dwg_Entity_CIRCLE = x.tio.entity.tio.CIRCLE;


                    circles.Add(new CirclePoints((float)dwg_Entity_CIRCLE.center.x, (float)dwg_Entity_CIRCLE.center.y, (float)dwg_Entity_CIRCLE.radius));
                    FindMin(Convert.ToInt32(dwg_Entity_CIRCLE.center.x), Convert.ToInt32(dwg_Entity_CIRCLE.center.y));
                    break;

                case Dwg_Object_Type.DWG_TYPE_ELLIPSE:
                    Dwg_Entity_ELLIPSE el = x.tio.entity.tio.ELLIPSE;

                    ellipse.Add(new Ellipse((float)el.sm_axis.x, (float)el.sm_axis.y, (float)(Math.Round(el.axis_ratio))));
                    FindMin(Convert.ToInt32(el.center.x), Convert.ToInt32(el.sm_axis.y));

                    break;

                case Dwg_Object_Type.DWG_TYPE_LINE:
                    Console.WriteLine("Line");
                    Dwg_Entity_LINE dwg_Entity_LINE = x.tio.entity.tio.LINE;



                    var Px1 = Math.Round(dwg_Entity_LINE.start.x, 2);
                    var Py1 = Math.Round(dwg_Entity_LINE.start.y, 2);
                    var Px2 = Math.Round(dwg_Entity_LINE.end.x, 2);
                    var Py2 = Math.Round(dwg_Entity_LINE.end.y, 2);
                    Punkty.Add(new Points(Px1, Py1, Px2, Py2));
                    FindMin(Convert.ToInt32(Px1), Convert.ToInt32(Py1));
                    FindMax(Convert.ToInt32(Px2), Convert.ToInt32(Py2));

                    break;

                default:
                    break;
                }
            }
        }