Пример #1
0
    public void Set(DXFStructure dxf, ELLIPSE item, float ScaleX = 1, float ScaleY = 1)
    {
        var goLayer = GoView.Content.GetLayer(item.C8);
        if (goLayer != null)
        {
            lr.material = goLayer.LayerMaterial;
            ZoomAdjust = goLayer.ZoomAdjust;
        }

        Vector3 center = new Vector3((float)item.C10, (float)item.C20, (float)item.C30);//中心点

        var theta = Mathf.Atan2((float)item.C21, (float)item.C11) * (180 / Mathf.PI);//椭圆的旋转角度
        Quaternion q = Quaternion.AngleAxis(theta, Vector3.forward);//创建一个旋转

        //长轴长度
        var a = Mathf.Abs(Vector3.Distance(new Vector3(), new Vector3((float)item.C11, (float)item.C21, (float)item.C31)));
        LongAxis = a;
        //短轴长度
        var b = a * (float)item.C40;

        //计算组层椭圆的元素数量,用于优化
        int resolution = (int)((a + b) / 2.0 / OptimizingLevel);
        if (resolution > MaxResolution) resolution = MaxResolution;
        else if (resolution < MinResolution) resolution = MinResolution;

        lr.SetVertexCount(resolution + 1);

        for (int i = 0; i < resolution; i++)
        {
            var ii = (float)(i * (item.C42 - item.C41) / resolution) + (float)item.C41;
            //计算出的坐标点
            var v = new Vector3(a * Mathf.Cos(ii), b * Mathf.Sin(ii), 0.0f);
            //加入旋转和中心点位置
            v = q * v + center;
            //增加缩放
            lr.SetPosition(i, new Vector3(v.x * ScaleX, v.y * ScaleY, v.z));
        }

        //最后增加一点用于处理最后一段的连线
        //计算出的坐标点
        var v1 = new Vector3(a * Mathf.Cos((float)item.C42), b * Mathf.Sin((float)item.C42), 0.0f);
        //加入旋转和中心点位置
        v1 = q * v1 + center;
        //增加缩放
        lr.SetPosition(resolution, new Vector3(v1.x * ScaleX, v1.y * ScaleY, v1.z));

        this.gameObject.isStatic = true;
    }
Пример #2
0
        protected override Property ReadSonClass(Property prop)
        {
            if (prop.Code == 0 && prop.Value != "ENDBLK")
            {
                switch (prop.Value)
                {
                //case "C3DFACE":
                //case "C3DSOLID":
                //case "ACAD_PROXY_ENTITY":
                case "ARC":
                    var arc = new ARC(DXFData, prop);
                    ARCList.Add(arc);
                    return(arc.ReadProperties());

                //case "ATTDEF":
                //case "ATTRIB":
                //case "BODY":
                case "CIRCLE":
                    var circle = new CIRCLE(DXFData, prop);
                    CIRCLEList.Add(circle);
                    return(circle.ReadProperties());

                //case "DIMENSION":
                case "ELLIPSE":
                    var ellipes = new ELLIPSE(DXFData, prop);
                    ELLIPSEList.Add(ellipes);
                    return(ellipes.ReadProperties());

                //case "HATCH":
                //case "HELIX":
                //case "IMAGE":
                case "INSERT":
                    var insert = new INSERT(DXFData, prop);
                    INSERTList.Add(insert);
                    return(insert.ReadProperties());

                //case "LEADER":
                //case "LIGHT":
                case "LINE":
                    var line = new LINE(DXFData, prop);
                    LINEList.Add(line);
                    return(line.ReadProperties());

                case "LWPOLYLINE":
                    var lwpolyline = new LWPOLYLINE(DXFData, prop);
                    LWPOLYLINEList.Add(lwpolyline);
                    return(lwpolyline.ReadProperties());

                //case "MESH":
                //case "MLINE":
                //case "MLEADERSTYLE":
                //case "MLEADER":
                //case "MTEXT":
                //case "OLEFRAME":
                //case "OLE2FRAME":
                //case "POINT":
                //case "POLYLINE":
                //case "RAY":
                //case "REGION":
                //case "SECTION":
                //case "SEQEND":
                //case "SHAPE":
                //case "SOLID":
                //case "SPLINE":
                //case "SUN":
                //case "SURFACE":
                //case "TABLE":
                case "TEXT":
                    var text = new TEXT(DXFData, prop);
                    TEXTList.Add(text);
                    return(text.ReadProperties());

                //case "TOLERANCE":
                //case "TRACE":
                //case "UNDERLAY":
                //case "VERTEX":
                //case "VIEWPORT":
                //case "WIPEOUT":
                //case "XLINE":

                default:
                    return(CreateSonClass(new ENTITIE(DXFData, prop)));
                }
            }
            else
            {
                return(base.ReadSonClass(prop));
            }
        }
Пример #3
0
 protected override Property ReadSonClass(Property prop)
 {
     if (prop.Code == 0 && prop.Value != "ENDSEC")
     {
         switch (prop.Value)
         {
             //case "C3DFACE":
             //case "C3DSOLID":
             //case "ACAD_PROXY_ENTITY":
             case "ARC":
                 var arc = new ARC(DXFData, prop);
                 ARCList.Add(arc);
                 return arc.ReadProperties();
             //case "ATTDEF":
             //case "ATTRIB":
             //case "BODY":
             case "CIRCLE":
                 var circle = new CIRCLE(DXFData, prop);
                 CIRCLEList.Add(circle);
                 return circle.ReadProperties();
             //case "DIMENSION":
             case "ELLIPSE":
                 var ellipes = new ELLIPSE(DXFData, prop);
                 ELLIPSEList.Add(ellipes);
                 return ellipes.ReadProperties();
             //case "HATCH":
             //case "HELIX":
             //case "IMAGE":
             case "INSERT":
                 var insert = new INSERT(DXFData, prop);
                  INSERTList.Add(insert);
                  return insert.ReadProperties();
             //case "LEADER":
             //case "LIGHT":
             case "LINE":
                 var line = new LINE(DXFData, prop);
                 LINEList.Add(line);
                 return line.ReadProperties();
             case "LWPOLYLINE":
                 var lwpolyline = new LWPOLYLINE(DXFData, prop);
                 LWPOLYLINEList.Add(lwpolyline);
                 return lwpolyline.ReadProperties();
             //case "MESH":
             //case "MLINE":
             //case "MLEADERSTYLE":
             //case "MLEADER":
             //case "MTEXT":
             //case "OLEFRAME":
             //case "OLE2FRAME":
             //case "POINT":
             //case "POLYLINE":
             //case "RAY":
             //case "REGION":
             //case "SECTION":
             //case "SEQEND":
             //case "SHAPE":
             //case "SOLID":
             //case "SPLINE":
             //case "SUN":
             //case "SURFACE":
             //case "TABLE":
             case "TEXT":
                 var text = new TEXT(DXFData, prop);
                 TEXTList.Add(text);
                 return text.ReadProperties();
             //case "TOLERANCE":
             //case "TRACE":
             //case "UNDERLAY":
             //case "VERTEX":
             //case "VIEWPORT":
             //case "WIPEOUT":
             //case "XLINE":
             default:
                 return CreateSonClass(new ENTITIE(DXFData, prop));
         }
     }
     else
     {
         return base.ReadSonClass(prop);
     }
 }