Ejemplo n.º 1
0
        //private Face3d ReadFace3D(ref CodeValuePair code)
        //{
        //    var face = new Face3d();
        //    Vector3f v0 = Vector3f.Zero;
        //    Vector3f v1 = Vector3f.Zero;
        //    Vector3f v2 = Vector3f.Zero;
        //    Vector3f v3 = Vector3f.Zero;
        //    Dictionary<ApplicationRegistry, XData> xData = new Dictionary<ApplicationRegistry, XData>();
        //    code = this.ReadCodePair();
        //    while (code.Code != 0)
        //    {
        //        switch (code.Code)
        //        {
        //            case 5:
        //                face.Handle = code.Value;
        //                code = this.ReadCodePair();
        //                break;
        //            case 8: //layer code
        //                face.Layer = this.GetLayer(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 62: //aci color code
        //                face.Color = new AciColor(short.Parse(code.Value));
        //                code = this.ReadCodePair();
        //                break;
        //            case 6: //type line code
        //                face.LineType = this.GetLineType(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 10:
        //                v0.X = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 20:
        //                v0.Y = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 30:
        //                v0.Z = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 11:
        //                v1.X = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 21:
        //                v1.Y = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 31:
        //                v1.Z = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 12:
        //                v2.X = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 22:
        //                v2.Y = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 32:
        //                v2.Z = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 13:
        //                v3.X = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 23:
        //                v3.Y = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 33:
        //                v3.Z = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 70:
        //                face.EdgeFlags = (EdgeFlags)(int.Parse(code.Value));
        //                code = this.ReadCodePair();
        //                break;
        //            case 1001:
        //                XData xDataItem = this.ReadXDataRecord(code.Value, ref code);
        //                xData.Add(xDataItem.ApplicationRegistry, xDataItem);
        //                break;
        //            default:
        //                if (code.Code >= 1000 && code.Code <= 1071)
        //                    throw new DxfInvalidCodeValueEntityException(code.Code, code.Value, this.file,
        //                                                                 "The extended data of an entity must start with the application registry code " + this.fileLine);
        //                code = this.ReadCodePair();
        //                break;
        //        }
        //    }
        //    face.FirstVertex = v0;
        //    face.SecondVertex = v1;
        //    face.ThirdVertex = v2;
        //    face.FourthVertex = v3;
        //    face.XData = xData;
        //    return face;
        //}
        //private Solid ReadSolid(ref CodeValuePair code)
        //{
        //    var solid = new Solid();
        //    Vector3f v0 = Vector3f.Zero;
        //    Vector3f v1 = Vector3f.Zero;
        //    Vector3f v2 = Vector3f.Zero;
        //    Vector3f v3 = Vector3f.Zero;
        //    Vector3f normal = Vector3f.UnitZ;
        //    Dictionary<ApplicationRegistry, XData> xData = new Dictionary<ApplicationRegistry, XData>();
        //    code = this.ReadCodePair();
        //    while (code.Code != 0)
        //    {
        //        switch (code.Code)
        //        {
        //            case 5:
        //                solid.Handle = code.Value;
        //                code = this.ReadCodePair();
        //                break;
        //            case 8: //layer code
        //                solid.Layer = this.GetLayer(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 62: //aci color code
        //                solid.Color = new AciColor(short.Parse(code.Value));
        //                code = this.ReadCodePair();
        //                break;
        //            case 6: //type line code
        //                solid.LineType = this.GetLineType(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 10:
        //                v0.X = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 20:
        //                v0.Y = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 30:
        //                v0.Z = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 11:
        //                v1.X = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 21:
        //                v1.Y = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 31:
        //                v1.Z = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 12:
        //                v2.X = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 22:
        //                v2.Y = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 32:
        //                v2.Z = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 13:
        //                v3.X = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 23:
        //                v3.Y = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 33:
        //                v3.Z = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 70:
        //                solid.Thickness = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 210:
        //                normal.X = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 220:
        //                normal.Y = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 230:
        //                normal.Z = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 1001:
        //                XData xDataItem = this.ReadXDataRecord(code.Value, ref code);
        //                xData.Add(xDataItem.ApplicationRegistry, xDataItem);
        //                break;
        //            default:
        //                if (code.Code >= 1000 && code.Code <= 1071)
        //                    throw new DxfInvalidCodeValueEntityException(code.Code, code.Value, this.file,
        //                                                                 "The extended data of an entity must start with the application registry code " + this.fileLine);
        //                code = this.ReadCodePair();
        //                break;
        //        }
        //    }
        //    solid.FirstVertex = v0;
        //    solid.SecondVertex = v1;
        //    solid.ThirdVertex = v2;
        //    solid.FourthVertex = v3;
        //    solid.Normal = normal;
        //    solid.XData = xData;
        //    return solid;
        //}
        //private Insert ReadInsert(ref CodeValuePair code)
        //{
        //    string handle = string.Empty;
        //    Vector3f basePoint = Vector3f.Zero;
        //    Vector3f normal = Vector3f.UnitZ;
        //    Vector3f scale = new Vector3f(1, 1, 1);
        //    float rotation = 0.0f;
        //    Block block = null;
        //    Layer layer = Layer.Default;
        //    AciColor color = AciColor.ByLayer;
        //    LineType lineType = LineType.ByLayer;
        //    List<Attribute> attributes = new List<Attribute>();
        //    Dictionary<ApplicationRegistry, XData> xData = new Dictionary<ApplicationRegistry, XData>();
        //    code = this.ReadCodePair();
        //    while (code.Code != 0)
        //    {
        //        switch (code.Code)
        //        {
        //            case 5:
        //                handle = code.Value;
        //                code = this.ReadCodePair();
        //                break;
        //            case 2:
        //                block = this.GetBlock(code.Value);
        //                if (block == null)
        //                    throw new DxfEntityException(DxfObjectCode.Insert, this.file, "Block " + code.Value + " not defined line " + this.fileLine);
        //                code = this.ReadCodePair();
        //                break;
        //            case 8: //layer code
        //                layer = this.GetLayer(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 62: //aci color code
        //                color = new AciColor(short.Parse(code.Value));
        //                code = this.ReadCodePair();
        //                break;
        //            case 6: //type line code
        //                lineType = this.GetLineType(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 10:
        //                basePoint.X = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 20:
        //                basePoint.Y = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 30:
        //                basePoint.Z = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 41:
        //                scale.X = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 42:
        //                scale.X = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 43:
        //                scale.X = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 50:
        //                rotation = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 210:
        //                normal.X = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 220:
        //                normal.Y = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 230:
        //                normal.Z = float.Parse(code.Value);
        //                code = this.ReadCodePair();
        //                break;
        //            case 1001:
        //                XData xDataItem = this.ReadXDataRecord(code.Value, ref code);
        //                xData.Add(xDataItem.ApplicationRegistry, xDataItem);
        //                break;
        //            default:
        //                if (code.Code >= 1000 && code.Code <= 1071)
        //                    throw new DxfInvalidCodeValueEntityException(code.Code, code.Value, this.file,
        //                                                                 "The extended data of an entity must start with the application registry code " + this.fileLine);
        //                code = this.ReadCodePair();
        //                break;
        //        }
        //    }
        //    // if there are attributes
        //    string endSequenceHandle = string.Empty;
        //    Layer endSequenceLayer = Layer.Default;
        //    if (code.Value == DxfObjectCode.Attribute)
        //    {
        //        while (code.Value != StringCode.EndSequence)
        //        {
        //            if (code.Value == DxfObjectCode.Attribute)
        //            {
        //                Debug.Assert(code.Code == 0);
        //                Attribute attribute = this.ReadAttribute(block, ref code);
        //                attributes.Add(attribute);
        //            }
        //        }
        //        // read the end end sequence object until a new element is found
        //        code = this.ReadCodePair();
        //        while (code.Code != 0)
        //        {
        //            switch (code.Code)
        //            {
        //                case 5:
        //                    endSequenceHandle = code.Value;
        //                    code = this.ReadCodePair();
        //                    break;
        //                case 8:
        //                    endSequenceLayer = this.GetLayer(code.Value);
        //                    code = this.ReadCodePair();
        //                    break;
        //                default:
        //                    code = this.ReadCodePair();
        //                    break;
        //            }
        //        }
        //    }
        //    Insert insert = new Insert(block)
        //    {
        //        Color = color,
        //        Layer = layer,
        //        LineType = lineType,
        //        InsertionPoint = basePoint,
        //        Rotation = rotation,
        //        Scale = scale,
        //        Normal = normal,
        //        Handle = handle
        //    };
        //    insert.EndSequence.Handle = endSequenceHandle;
        //    insert.EndSequence.Layer = endSequenceLayer;
        //    insert.Attributes.Clear();
        //    insert.Attributes.AddRange(attributes);
        //    insert.XData = xData;
        //    return insert;
        //}
        private Linea ReadLinea(ref ParCodigoValor cod)
        {
            var linea = new Linea();
            Vector3f inicio = Vector3f.Nulo;
            Vector3f fin = Vector3f.Nulo;
            Vector3f normal = Vector3f.UnitarioZ ;
            //Dictionary<ApplicationRegistry, XData> xData = new Dictionary<ApplicationRegistry, XData>();

            cod = this.ReadCodePair();
            while (cod.Cod != 0)
            {
                switch (cod.Cod)
                {
                    case 5:
                        linea.Handle = cod.Val;
                        cod = this.ReadCodePair();
                        break;
                    //case 8: //layer code
                    //    linea.Layer = this.GetLayer(cod.Val);
                    //    cod = this.ReadCodePair();
                    //    break;
                    //case 62: //aci color code
                    //    linea.Color = new AciColor(short.Parse(cod.Val));
                    //    cod = this.ReadCodePair();
                    //    break;
                    //case 6: //type line code
                    //    linea.LineType = this.GetLineType(cod.Val);
                    //    cod = this.ReadCodePair();
                    //    break;
                    case 10:
                        inicio.X = float.Parse(cod.Val);
                        cod = this.ReadCodePair();
                        break;
                    case 20:
                        inicio.Y = float.Parse(cod.Val);
                        cod = this.ReadCodePair();
                        break;
                    case 30:
                        inicio.Z = float.Parse(cod.Val);
                        cod = this.ReadCodePair();
                        break;
                    case 11:
                        fin.X = float.Parse(cod.Val);
                        cod = this.ReadCodePair();
                        break;
                    case 21:
                        fin.Y = float.Parse(cod.Val);
                        cod = this.ReadCodePair();
                        break;
                    case 31:
                        fin.Z = float.Parse(cod.Val);
                        cod = this.ReadCodePair();
                        break;
                    //case 39:
                    //    linea.Thickness = float.Parse(cod.Val);
                    //    cod = this.ReadCodePair();
                    //    break;
                    case 210:
                        normal.X = float.Parse(cod.Val);
                        cod = this.ReadCodePair();
                        break;
                    case 220:
                        normal.Y = float.Parse(cod.Val);
                        cod = this.ReadCodePair();
                        break;
                    case 230:
                        normal.Z = float.Parse(cod.Val);
                        cod = this.ReadCodePair();
                        break;
                    //case 1001:
                    //    XData xDataItem = this.ReadXDataRecord(cod.Val, ref cod);
                    //    xData.Add(xDataItem.ApplicationRegistry, xDataItem);
                    //    break;
                    default:
                        if (cod.Cod >= 1000 && cod.Cod <= 1071)
                            throw new DxfInvalidCodeValueEntityException(cod.Cod, cod.Val, this.archivo,
                                                                         "The extended data of an entity must start with the application registry code " + this.fileLine);

                        cod = this.ReadCodePair();
                        break;
                }
            }

            linea.PuntoInicio  = inicio;
            linea.PuntoFinal = fin;
            linea.Normal = normal;
            //linea.XData = xData;

            return linea;
        }
Ejemplo n.º 2
0
        public static List<string> Linea(Linea l)
        {
            G01_Lineal mov;
            List<string> movs = new List<string>();

            mov = new G01_Lineal();

            mov.Inicio.X = l.PuntoInicio.X;
            mov.Inicio.Y = l.PuntoInicio.Y;
            mov.Inicio.Z = l.PuntoInicio.Z;

            mov.Fin.X = l.PuntoFinal.X;
            mov.Fin.Y = l.PuntoFinal.Y;
            mov.Fin.Z = l.PuntoFinal.Z;

            movs.Add(mov.ToString());

            return movs;
        }