Ejemplo n.º 1
0
        //--------------------------------------------------------------------------------------------------

        void _ReadHeader(DxfReader reader)
        {
            while (reader.GroupCode > 0)
            {
                if (reader.GroupCode != 9)
                {
                    reader.Skip();
                    continue;
                }

                var variableName = reader.ReadString()?.ToUpper();
                if (variableName == null)
                {
                    continue;
                }

                switch (variableName)
                {
/*                    case "$MEASUREMENT":
 *                      var measurement = reader.ReadInteger();
 *                      break;*/

                default:
                    reader.Skip();
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        //--------------------------------------------------------------------------------------------------

        #endregion

        #region Reader

        public bool ReadFromStream(Stream stream, double scale)
        {
            var reader = new DxfReader(stream, scale);

            _Read(reader);
            reader.Close();
            return(Entities.Count > 0);
        }
Ejemplo n.º 3
0
        //--------------------------------------------------------------------------------------------------

        public override bool Read(DxfReader reader)
        {
            var readBits = new BitVector32(0);

            while (reader.GroupCode > 0)
            {
                switch (reader.GroupCode)
                {
                case 10:
                    CenterPoint.X = reader.ReadCoord();
                    readBits[0b1] = true;
Ejemplo n.º 4
0
        //--------------------------------------------------------------------------------------------------

        public override bool Read(DxfReader reader)
        {
            Pnt2d controlPoint      = default;
            int   controlPointCount = 0;
            var   controlPointList  = new List <Pnt2d>();
            var   controlReadBits   = new BitVector32(0);

            int knotCount  = 0;
            var knotList   = new List <double>();
            var weightList = new List <double>();

            Pnt2d fitPoint      = default;
            int   fitPointCount = 0;
            var   fitPointList  = new List <Pnt2d>();
            var   fitReadBits   = new BitVector32(0);

            var tanReadBits = new BitVector32(0);

            Flags = SplineFlags.None;

            while (reader.GroupCode > 0)
            {
                switch (reader.GroupCode)
                {
                case 70:
                    Flags = (SplineFlags)reader.ReadInteger();
                    break;

                case 71:
                    Degree = reader.ReadInteger();
                    break;

                case 72:
                    knotCount = reader.ReadInteger();
                    break;

                case 73:
                    controlPointCount = reader.ReadInteger();
                    break;

                case 74:
                    fitPointCount = reader.ReadInteger();
                    break;

                case 10:
                    controlPoint.X        = reader.ReadCoord();
                    controlReadBits[0b01] = true;
        //--------------------------------------------------------------------------------------------------

        public override bool Read(DxfReader reader)
        {
            var   pointList      = new List <Pnt2d>();
            Pnt2d point          = default;
            bool  skipNextVertex = false;
            var   readBits       = new BitVector32(0);

            // read POLYLINE
            while (reader.GroupCode > 0)
            {
                switch (reader.GroupCode)
                {
                case 70:
                    int flags = reader.ReadInteger();
                    if (flags > 1)
                    {
                        Messages.Warning($"DxfReader: Entity POLYGON has flags set in line {reader.Line} which are not supported for import. The polygon will be imported using straight lines between vertices.");
                    }
                    break;

                default:
                    reader.Skip();
                    break;
                }
            }

            // read VERTEX
            var type = reader.ReadString().ToUpper();

            while (type.Equals("VERTEX"))
            {
                while (reader.GroupCode > 0)
                {
                    switch (reader.GroupCode)
                    {
                    case 70:
                        int flags = reader.ReadInteger();
                        if (flags != 0)
                        {
                            skipNextVertex = true;
                        }
                        break;

                    case 10:
                        point.X        = reader.ReadCoord();
                        readBits[0b01] = true;
Ejemplo n.º 6
0
        //--------------------------------------------------------------------------------------------------

        public override bool Read(DxfReader reader)
        {
            var   pointList  = new List <Pnt2d>();
            Pnt2d point      = default;
            var   pointCount = 0;
            var   readBits   = new BitVector32(0);

            while (reader.GroupCode > 0)
            {
                switch (reader.GroupCode)
                {
                case 90:
                    pointCount = reader.ReadInteger();
                    break;

                case 10:
                    point.X        = reader.ReadCoord();
                    readBits[0b01] = true;
Ejemplo n.º 7
0
        //--------------------------------------------------------------------------------------------------

        void _Read(DxfReader reader)
        {
            while (reader.GroupCode >= 0)
            {
                if (reader.GroupCode != 0)
                {
                    reader.Skip();
                    continue;
                }

                var type = reader.ReadString()?.ToUpper();
                if (type == null)
                {
                    continue;
                }

                if (type.Equals("EOF"))
                {
                    break;
                }

                if (type.Equals("SECTION") && reader.GroupCode == 2)
                {
                    var name = reader.ReadString()?.ToUpper();
                    if (name == null)
                    {
                        continue;
                    }

                    if (name.Equals("HEADER"))
                    {
                        _ReadHeader(reader);
                    }
                    else if (name.Equals("ENTITIES"))
                    {
                        _ReadEntities(reader);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        //--------------------------------------------------------------------------------------------------

        void _ReadEntities(DxfReader reader)
        {
            while (reader.GroupCode >= 0)
            {
                if (reader.GroupCode != 0)
                {
                    reader.Skip();
                    continue;
                }

                var type = reader.ReadString()?.ToUpper();
                if (type == null)
                {
                    continue;
                }

                DxfDomEntity entity = null;
                switch (type)
                {
                case "ENDSEC":
                    return;

                case "LINE":
                    entity = new DxfDomLine();
                    break;

                case "CIRCLE":
                case "ARC":
                    entity = new DxfDomCircle();
                    break;

                case "ELLIPSE":
                    entity = new DxfDomEllipse();
                    break;

                case "LWPOLYLINE":
                    entity = new DxfDomLwPolyline();
                    break;

                case "POLYLINE":
                    entity = new DxfDomPolyline();
                    break;

                case "SPLINE":
                    entity = new DxfDomSpline();
                    break;
                }

                if (entity == null)
                {
                    continue;
                }

                if (entity.Read(reader))
                {
                    Entities.Add(entity);
                }
                else
                {
                    Messages.Error($"DxfReader: Incomplete entity description at line {reader.Line}.");
                }
            }
        }
Ejemplo n.º 9
0
 public abstract bool Read(DxfReader reader);