Exemple #1
0
        public override void ProcessEntity(PicEntity entity)
        {
            PicDrawable drawable = entity as PicDrawable;

            // non drawable not taken into account
            if (null == drawable)
            {
                return;
            }
            if (drawable is PicBlockRef)
            {
                PicBlockRef blockRef = entity as PicBlockRef;
                _box.Extend(blockRef.Box);
            }
            else if ((drawable is PicBlock))
            {
                if (_takePicBlocsIntoAccount)
                {
                    PicBlock block = entity as PicBlock;
                    _box.Extend(block.Box);
                }
            }
            else
            {
                PicTypedDrawable typedDrawable = drawable as PicTypedDrawable;
                if (null != typedDrawable && typedDrawable.LineType != PicGraphics.LT.LT_CONSTRUCTION)
                {
                    _box.Extend(drawable.Box);
                }
            }
        }
Exemple #2
0
            /// <summary>
            /// Create a new block reference
            /// </summary>
            /// <param name="block">An instance of the <see cref="PicBlock2D"/> class</param>
            /// <param name="pt">A <see cref="Vector2D"/> point to be used as translation from the origin of block coordinates</param>
            /// <param name="angle">A double angle value</param>
            /// <returns>A <see cref="PicBlockRef"/> entity</returns>
            public PicBlockRef AddBlockRef(PicBlock block, Vector2D pt, double angle)
            {
                PicBlockRef blockRef = PicBlockRef.CreateNewBlockRef(GetNewEntityId(), block, pt, angle);

                AddEntity(blockRef);
                return(blockRef);
            }
Exemple #3
0
            public PicBlockRef AddBlockRef(PicBlock block, Transform2D transf)
            {
                PicBlockRef blockRef = PicBlockRef.CreateNewBlockRef(GetNewEntityId(), block, transf);

                AddEntity(blockRef);
                return(blockRef);
            }
Exemple #4
0
        private static List <Segment> BlockRefToSegmentList(PicBlockRef blockRef, double angle)
        {
            Transform2D transform = Transform2D.Rotation(angle);

            List <Segment> segList = new List <Segment>();

            Transform2D transformBlock = transform * blockRef.BlockTransformation;

            // convert bolckRef1 to segList1
            foreach (PicEntity entity1 in blockRef._block)
            {
                PicSegment picSeg1 = entity1 as PicSegment;
                if (null != picSeg1)
                {
                    Segment seg = new Segment(picSeg1.Pt0, picSeg1.Pt1);
                    seg.Transform(transformBlock);
                    segList.Add(seg);
                }

                PicArc picArc1 = entity1 as PicArc;
                if (null != picArc1)
                {
                    Arc            arc         = new Arc(picArc1.Center, (float)picArc1.Radius, (float)(picArc1.AngleBeg), (float)(picArc1.AngleEnd));
                    List <Segment> arcExploded = arc.Explode(20);
                    foreach (Segment seg in arcExploded)
                    {
                        seg.Transform(transformBlock);
                        segList.Add(seg);
                    }
                }
            }
            return(segList);
        }
        public override void ProcessEntity(PicEntity entity)
        {
            if (PicEntity.ECode.PE_BLOCKREF == entity.Code)
            {
                PicBlockRef blockRef = entity as PicBlockRef;
                PicBlock    block    = blockRef.Block;

                foreach (var blockEntity in block)
                {
                    if (blockEntity is PicTypedDrawable innerDrawable)
                    {
                        double totalLength = innerDrawable.Length;
                        if (_dictionnaryLength.ContainsKey(innerDrawable.LineType))
                        {
                            totalLength += _dictionnaryLength[innerDrawable.LineType];
                        }
                        _dictionnaryLength[innerDrawable.LineType] = totalLength;
                    }
                }
            }
            else if (PicEntity.ECode.PE_BLOCK == entity.Code)
            {
                PicBlock block = entity as PicBlock;
                foreach (var blockEntity in block)
                {
                    if (blockEntity is PicTypedDrawable innerDrawable)
                    {
                        double totalLength = innerDrawable.Length;
                        if (_dictionnaryLength.ContainsKey(innerDrawable.LineType))
                        {
                            totalLength += _dictionnaryLength[innerDrawable.LineType];
                        }
                        _dictionnaryLength[innerDrawable.LineType] = totalLength;
                    }
                }
            }
            else if (entity is PicTypedDrawable drawable)
            {
                double totalLength = drawable.Length;
                if (_dictionnaryLength.ContainsKey(drawable.LineType))
                {
                    totalLength += _dictionnaryLength[drawable.LineType];
                }
                _dictionnaryLength[drawable.LineType] = totalLength;
            }
        }
        public override void GeneratePattern(IEntityContainer container, Vector2D minDistance, Vector2D impositionOffset, bool ortho)
        {
            using (PicFactory factory = new PicFactory())
            {
                // instantiate block and BlockRef
                PicBlock    block      = factory.AddBlock(container);
                PicBlockRef blockRef00 = factory.AddBlockRef(block, new Vector2D(0.0, 0.0), ortho ? 90.0 : 0.0);

                // compute bounding box
                PicVisitorBoundingBox visitor = new PicVisitorBoundingBox();
                visitor.TakePicBlocksIntoAccount = false;
                factory.ProcessVisitor(visitor, !PicFilter.FilterCotation);
                Box2D boxEntities = visitor.Box;

                // compute default X step
                PicBlockRef blockRef01         = factory.AddBlockRef(block, new Vector2D(5.0 * boxEntities.Width + minDistance.X, 0.0), ortho ? 90.0 : 0.0);
                double      horizontalDistance = 0.0;
                if (!PicBlockRef.Distance(blockRef00, blockRef01, PicBlockRef.DistDirection.HORIZONTAL_RIGHT, out horizontalDistance))
                {
                    throw new Exception("Failed to compute distance between to block refs");
                }
                _patternStep.X = 5.0 * boxEntities.Width - horizontalDistance + 2.0 * minDistance.X;

                // compute default Y step
                PicBlockRef blockRef10       = factory.AddBlockRef(block, new Vector2D(0.0, 5.0 * boxEntities.Height + minDistance.Y), ortho ? 90.0 : 0.0);
                double      verticalDistance = 0.0;
                if (!PicBlockRef.Distance(blockRef00, blockRef10, PicBlockRef.DistDirection.VERTICAL_TOP, out verticalDistance))
                {
                    throw new Exception("Failed to compute distance between to block refs");
                }
                _patternStep.Y = 5.0 * boxEntities.Height - verticalDistance + 2.0 * minDistance.Y;

                // positions
                _relativePositions = new BPosition[1, 1];
                BPosition position = new BPosition(Vector2D.Zero, ortho ? 90.0 : 0.0);
                _relativePositions[0, 0] = position;

                // bboxes
                _bboxes       = new Box2D[1, 1];
                _bboxes[0, 0] = blockRef00.Box;//boxEntities;
            }
        }
Exemple #7
0
        public static bool Distance(PicBlockRef blockRef1, PicBlockRef blockRef2, DistDirection direction, out double distance)
        {
            // compute needed rotation
            double angle = 0.0;

            switch (direction)
            {
            case DistDirection.HORIZONTAL_RIGHT: angle = 90.0;  break;

            case DistDirection.HORIZONTAL_LEFT: angle = 270.0;  break;

            case DistDirection.VERTICAL_TOP: angle = 0.0;       break;

            case DistDirection.VERTICAL_BOTTOM: angle = 180.0;  break;

            default:
                break;
            }

            List <Segment> segList1 = BlockRefToSegmentList(blockRef1, angle);
            List <Segment> segList2 = BlockRefToSegmentList(blockRef2, angle);

            // search distance between 2 BlockRef
            distance = double.MaxValue;
            bool success = false;

            foreach (Segment seg1 in segList1)
            {
                foreach (Segment seg2 in segList2)
                {
                    double dist = double.MaxValue;
                    if (VerticalDistance.SegmentToAboveSegment(seg1, seg2, ref dist))
                    {
                        distance = System.Math.Min(distance, dist);
                        success  = true;
                    }
                }
            }
            return(success);
        }
        public override void ProcessEntity(PicEntity entity)
        {
            if (entity.Code != PicEntity.eCode.PE_BLOCKREF)
            {
                PicTypedDrawable drawable = entity as PicTypedDrawable;
                if (null == drawable)
                {
                    return;
                }
                double totalLength = drawable.Length;
                if (_dictionnaryLength.ContainsKey(drawable.LineType))
                {
                    totalLength += _dictionnaryLength[drawable.LineType];
                }
                _dictionnaryLength[drawable.LineType] = totalLength;
            }
            else
            {
                PicBlockRef blockRef = entity as PicBlockRef;
                PicBlock    block    = blockRef.Block;

                foreach (PicEntity blockEntity in block)
                {
                    PicTypedDrawable innerDrawable = blockEntity as PicTypedDrawable;
                    if (null == innerDrawable)
                    {
                        continue;
                    }

                    double totalLength = innerDrawable.Length;
                    if (_dictionnaryLength.ContainsKey(innerDrawable.LineType))
                    {
                        totalLength += _dictionnaryLength[innerDrawable.LineType];
                    }
                    _dictionnaryLength[innerDrawable.LineType] = totalLength;
                }
            }
        }
        public override void ProcessEntity(PicEntity entity)
        {
            PicDrawable drawable = entity as PicDrawable;

            if (null == drawable)
            {
                return;
            }
            PicBlock picBlock = drawable as PicBlock;

            if (null != picBlock)
            {
                foreach (PicEntity e in picBlock)
                {
                    if (e is PicTypedDrawable)
                    {
                        AddEntityLength(e as PicTypedDrawable, Transform2D.Identity);
                    }
                }
            }
            PicBlockRef blockRef = drawable as PicBlockRef;

            if (null != blockRef)
            {
                PicBlock block = blockRef.Block;
                foreach (PicEntity e in block)
                {
                    if (e is PicTypedDrawable)
                    {
                        AddEntityLength(e as PicTypedDrawable, blockRef.BlockTransformation);
                    }
                }
            }
            else if (drawable is PicTypedDrawable)
            {
                AddEntityLength(drawable as PicTypedDrawable, Transform2D.Identity);
            }
        }
Exemple #10
0
        public override void ProcessEntity(PicEntity entity)
        {
            PicTypedDrawable drawable = entity as PicTypedDrawable;

            if (entity is PicSegment || entity is PicArc)
            {
                ExpBlock defblock = _exporter.GetBlockOrCreate("default");
                ExportEntity(defblock, entity);
            }
            PicBlock block = entity as PicBlock;

            if (null != block)
            {
                // create block
                ExpBlock expBlock = _exporter.CreateBlock(string.Format("Block_{0}", block.Id));
                // create _x=0.0 _y=0.0
                ExpBlockRef expBlockRef = _exporter.CreateBlockRef(expBlock);
                // create entities
                foreach (PicEntity blockEntity in block.Entities)
                {
                    ExportEntity(expBlock, blockEntity);
                }
            }
            PicBlockRef blockRef = entity as PicBlockRef;

            if (null != blockRef)
            {
                // retrieve previously created block
                ExpBlock    expBlock    = _exporter.GetBlock(string.Format("Block_{0}", blockRef.Block.Id));
                ExpBlockRef expBlockRef = _exporter.CreateBlockRef(expBlock);
                expBlockRef._x      = blockRef.Position.X;
                expBlockRef._y      = blockRef.Position.Y;
                expBlockRef._dir    = blockRef.Angle;
                expBlockRef._scaleX = 1.0;
                expBlockRef._scaleY = 1.0;
            }
        }
        public override void GeneratePattern(IEntityContainer container, Vector2D minDistance, Vector2D impositionOffset, bool ortho)
        {
            using (PicFactory factory = new PicFactory())
            {
                // 20 21
                // 10 11 12
                // 00 01 02
                //

                // instantiate block and BlockRef
                PicBlock    block      = factory.AddBlock(container);
                PicBlockRef blockRef00 = factory.AddBlockRef(block, new Vector2D(0.0, 0.0), ortho ? 90.0 : 0.0);

                // compute bounding box
                PicVisitorBoundingBox visitor = new PicVisitorBoundingBox();
                visitor.TakePicBlocksIntoAccount = false;
                factory.ProcessVisitor(visitor, new PicFilter());
                Box2D boxEntities = visitor.Box;

                // compute second entity position
                PicBlockRef blockRef10 = factory.AddBlockRef(block
                                                             , new Vector2D(
                                                                 boxEntities.XMin + boxEntities.XMax + (ortho ? 0.0 : 1.0) * impositionOffset.X
                                                                 , boxEntities.YMin + boxEntities.YMax + 5.0 * boxEntities.Height + minDistance.Y + (ortho ? 1.0 : 0.0) * impositionOffset.Y
                                                                 ), ortho ? 270.0 : 180.0);
                double verticalDistance = 0.0;
                if (!PicBlockRef.Distance(blockRef00, blockRef10, PicBlockRef.DistDirection.VERTICAL_TOP, out verticalDistance))
                {
                    throw new Exception("Failed to compute distance between to block refs");
                }
                Vector2D vecPosition = new Vector2D(
                    boxEntities.XMin + boxEntities.XMax + (ortho ? 0.0 : 1.0) * impositionOffset.X
                    , boxEntities.YMin + boxEntities.YMax + 5.0 * boxEntities.Height + 2.0 * minDistance.Y - verticalDistance + (ortho ? 1.0 : 0.0) * impositionOffset.Y);
                blockRef10.Position = vecPosition;

                // positions
                _relativePositions       = new BPosition[2, 1];
                _relativePositions[0, 0] = new BPosition(Vector2D.Zero, ortho ? 90.0 : 0.0);
                _relativePositions[1, 0] = new BPosition(vecPosition, ortho ? 270.0 : 180.0);
                // bboxes
                _bboxes       = new Box2D[2, 1];
                _bboxes[0, 0] = blockRef00.Box;//boxEntities;
                _bboxes[1, 0] = blockRef10.Box;

                // compute X step (col1 / col0)
                // col0
                List <PicBlockRef> listCol0 = new List <PicBlockRef>();
                listCol0.Add(blockRef00);
                listCol0.Add(blockRef10);

                // col1
                PicBlockRef blockRef01 = factory.AddBlockRef(block
                                                             , new Vector2D(5.0 * boxEntities.Width + minDistance.X, 0.0)
                                                             , ortho ? 90.0 : 0.0);
                PicBlockRef blockRef11 = factory.AddBlockRef(block
                                                             , new Vector2D(5.0 * boxEntities.Width + minDistance.X + vecPosition.X, vecPosition.Y)
                                                             , ortho ? 270.0 : 180.0);
                List <PicBlockRef> listCol1 = new List <PicBlockRef>();
                listCol1.Add(blockRef01);
                listCol1.Add(blockRef11);
                double horizontalDistance = 0.0;
                if (!PicBlockRef.Distance(listCol0, listCol1, PicBlockRef.DistDirection.HORIZONTAL_RIGHT, out horizontalDistance))
                {
                    throw new Exception("Failed to compute distance between to block refs");
                }
                _patternStep.X      = 5.0 * boxEntities.Width - horizontalDistance + 2.0 * minDistance.X;
                blockRef01.Position = vecPosition;
                blockRef11.Position = new Vector2D(vecPosition.X + _patternStep.X, vecPosition.Y);

                // compute Y step (row2 / row1)
                // row1
                List <PicBlockRef> listRow1 = new List <PicBlockRef>();
                listRow1.Add(blockRef10);
                listRow1.Add(blockRef11);

                PicBlockRef blockRef20 = factory.AddBlockRef(block
                                                             , new Vector2D(0.0, 5.0 * (boxEntities.Height + minDistance.Y))
                                                             , ortho ? 90.0 : 0.0);
                PicBlockRef blockRef21 = factory.AddBlockRef(block
                                                             , new Vector2D(_patternStep.X, 5.0 * (boxEntities.Height + minDistance.Y))
                                                             , ortho ? 90.0 : 0.0);

                List <PicBlockRef> listRow2 = new List <PicBlockRef>();
                listRow2.Add(blockRef20);
                listRow2.Add(blockRef21);

                verticalDistance = 0.0;
                if (!PicBlockRef.Distance(listRow1, listRow2, PicBlockRef.DistDirection.VERTICAL_TOP, out verticalDistance))
                {
                    throw new Exception("Failed to compute distance between to block refs");
                }
                _patternStep.Y = 5.0 * boxEntities.Height - verticalDistance + 6.0 * minDistance.Y;
            }
        }
        /// <summary>
        /// ProcessEntity : write entity corresponding des description
        /// </summary>
        /// <param name="entity"></param>
        public override void ProcessEntity(PicEntity entity)
        {
            switch (entity.Code)
            {
            case PicEntity.eCode.PE_POINT:
                break;

            case PicEntity.eCode.PE_SEGMENT:
            {
                PicSegment seg = (PicSegment)entity;
                _desWriter.WriteSegment(
                    new DES_Segment(
                        (float)seg.Pt0.X
                        , (float)seg.Pt0.Y
                        , (float)seg.Pt1.X
                        , (float)seg.Pt1.Y
                        , LineTypeToDesPen(seg.LineType)
                        , (byte)seg.Group
                        , (byte)seg.Layer
                        )
                    );
            }
            break;

            case PicEntity.eCode.PE_ARC:
            {
                PicArc arc = (PicArc)entity;
                _desWriter.WriteArc(
                    new DES_Arc(
                        (float)arc.Center.X
                        , (float)arc.Center.Y
                        , (float)arc.Radius
                        , (float)arc.AngleBeg
                        , (float)arc.AngleEnd
                        , LineTypeToDesPen(arc.LineType)
                        , (byte)arc.Group
                        , (byte)arc.Layer
                        )
                    );
            }
            break;

            case PicEntity.eCode.PE_COTATIONDISTANCE:
            {
                PicCotationDistance cotation = entity as PicCotationDistance;

                /*
                 * _desWriter.WriteCotationDistance(
                 *  new DES_CotationDistance(
                 *      (float)cotation.Pt0.X
                 *      , (float)cotation.Pt0.Y
                 *      , (float)cotation.Pt1.X
                 *      , (float)cotation.Pt1.Y
                 *      , (float)cotation.Offset
                 *      , (byte)cotation.Group
                 *      , (byte)cotation.Layer
                 *      )
                 *  );
                 */
            }
            break;

            case PicEntity.eCode.PE_COTATIONHORIZONTAL:
            {
            }
            break;

            case PicEntity.eCode.PE_COTATIONVERTICAL:
            {
            }
            break;

            case PicEntity.eCode.PE_COTATIONRADIUSEXT:
            {
            }
            break;

            case PicEntity.eCode.PE_COTATIONRADIUSINT:
            {
            }
            break;

            case PicEntity.eCode.PE_BLOCK:
            {
                PicBlock block = entity as PicBlock;
                foreach (PicEntity blockEntity in block)
                {
                    ProcessEntity(blockEntity);
                }
            }
            break;

            case PicEntity.eCode.PE_BLOCKREF:
            {
                PicBlockRef blockRef = entity as PicBlockRef;
                _desWriter.WriteBlockRef(
                    new DES_Pose(
                        (float)blockRef.Position.X
                        , (float)blockRef.Position.Y
                        , (float)blockRef.Angle
                        , (byte)blockRef.Block.ExportedGroup)
                    );
            }
            break;

            case PicEntity.eCode.PE_CARDBOARDFORMAT:
            {
            }
            break;

            default:
                throw new Exception("Can not export this kind of entity!");
            }
        }
Exemple #13
0
        public override void GeneratePattern(IEntityContainer container, Vector2D minDistance, Vector2D impositionOffset, bool ortho)
        {
            //
            // 10 11 12
            // 00 01 02
            //
            using (PicFactory factory = new PicFactory())
            {
                // instantiate block and BlockRef
                PicBlock    block      = factory.AddBlock(container);
                PicBlockRef blockRef00 = factory.AddBlockRef(block
                                                             , Vector2D.Zero
                                                             , ortho ? 90.0 : 0.0);

                // compute bounding box
                Box2D boxEntities = Tools.BoundingBox(factory, 0.0, false);

                // compute second entity position on row 0
                PicBlockRef blockRef01 = factory.AddBlockRef(block
                                                             , new Vector2D(
                                                                 boxEntities.XMax + boxEntities.XMin + 5.0 * boxEntities.Width + (ortho ? 1.0 : 0.0) * impositionOffset.X
                                                                 , boxEntities.YMax + boxEntities.YMin + (ortho ? 0.0 : 1.0) * impositionOffset.Y)
                                                             , ortho ? 270.0 : 180.0);
                if (!PicBlockRef.Distance(blockRef00, blockRef01, PicBlockRef.DistDirection.HORIZONTAL_RIGHT, out double horizontalDistance))
                {
                    throw new Exception("Failed to compute distance between to block refs");
                }
                Vector2D vecPosition = new Vector2D(
                    boxEntities.XMax + boxEntities.XMin + 5.0 * boxEntities.Width + minDistance.X - horizontalDistance + (ortho ? 1.0 : 0.0) * impositionOffset.X
                    , boxEntities.YMax + boxEntities.YMin + (ortho ? 0.0 : 1.0) * impositionOffset.Y);
                blockRef01.Position = vecPosition;

                // positions
                _relativePositions       = new BPosition[1, 2];
                _relativePositions[0, 0] = new BPosition(Vector2D.Zero, ortho ? 90.0 : 0.0);
                _relativePositions[0, 1] = new BPosition(vecPosition, ortho ? 270.0 : 180.0);
                // bboxes
                _bboxes       = new Box2D[1, 2];
                _bboxes[0, 0] = blockRef00.Box;//boxEntities;
                _bboxes[0, 1] = blockRef01.Box;

                // compute Y step (row1 / row0)
                // row0
                List <PicBlockRef> listRow0 = new List <PicBlockRef>
                {
                    blockRef00,
                    blockRef01
                };
                // row1
                List <PicBlockRef> listRow1   = new List <PicBlockRef>();
                PicBlockRef        blockRef10 = factory.AddBlockRef(
                    block
                    , new Vector2D(0.0, 5.0 * boxEntities.Height + minDistance.Y)
                    , ortho ? 90.0 : 0.0);
                PicBlockRef blockRef11 = factory.AddBlockRef(
                    block
                    , new Vector2D(vecPosition.X, vecPosition.Y + 5.0 * boxEntities.Height + minDistance.Y)
                    , ortho ? 270.0 : 180.0);
                listRow1.Add(blockRef10);
                listRow1.Add(blockRef11);

                if (!PicBlockRef.Distance(listRow0, listRow1, PicBlockRef.DistDirection.VERTICAL_TOP, out double verticalDistance))
                {
                    throw new Exception("Failed to compute distance between to block refs");
                }
                _patternStep.Y = 5.0 * boxEntities.Height - verticalDistance + 2.0 * minDistance.Y;

                blockRef10.Position = new Vector2D(0.0, _patternStep.Y);
                blockRef11.Position = new Vector2D(vecPosition.X, vecPosition.Y + _patternStep.Y);

                // compute X step (col1 / col2)
                PicBlockRef blockRef02 = factory.AddBlockRef(
                    block
                    , new Vector2D(boxEntities.XMin + 5.0 * boxEntities.Width + minDistance.X
                                   , 0.0)
                    , ortho ? 90.0 : 0.0);
                PicBlockRef blockRef12 = factory.AddBlockRef(
                    block
                    , new Vector2D(boxEntities.XMin + 5.0 * boxEntities.Width + minDistance.X
                                   , _patternStep.Y)
                    , ortho ? 90.0 : 0.0);

                List <PicBlockRef> listCol1 = new List <PicBlockRef> {
                    blockRef01, blockRef11
                };
                List <PicBlockRef> listCol2 = new List <PicBlockRef> {
                    blockRef02, blockRef12
                };

                horizontalDistance = 0.0;
                if (!PicBlockRef.Distance(listCol1, listCol2, PicBlockRef.DistDirection.HORIZONTAL_RIGHT, out horizontalDistance))
                {
                    throw new Exception("Failed to compute distance between to block refs");
                }
                _patternStep.X = boxEntities.XMin + 5.0 * boxEntities.Width - horizontalDistance + 2.0 * minDistance.X;
            }
        }
        /// <summary>
        /// ProcessEntity : write entity corresponding des description
        /// </summary>
        /// <param name="entity"></param>
        public override void ProcessEntity(PicEntity entity)
        {
            switch (entity.Code)
            {
            case PicEntity.ECode.PE_POINT:
                break;

            case PicEntity.ECode.PE_SEGMENT:
            {
                PicSegment seg = (PicSegment)entity;
                _desWriter.WriteSegment(
                    new DES_Segment(
                        (float)seg.Pt0.X
                        , (float)seg.Pt0.Y
                        , (float)seg.Pt1.X
                        , (float)seg.Pt1.Y
                        , LineTypeToDesPen(seg.LineType)
                        , (byte)seg.Group
                        , (byte)seg.Layer
                        )
                    );
            }
            break;

            case PicEntity.ECode.PE_ARC:
            {
                PicArc arc = (PicArc)entity;
                _desWriter.WriteArc(
                    new DES_Arc(
                        (float)arc.Center.X
                        , (float)arc.Center.Y
                        , (float)arc.Radius
                        , (float)arc.AngleBeg
                        , (float)arc.AngleEnd
                        , LineTypeToDesPen(arc.LineType)
                        , (byte)arc.Group
                        , (byte)arc.Layer
                        )
                    );
            }
            break;

            case PicEntity.ECode.PE_COTATIONDISTANCE:
            {
                PicCotationDistance cotation = entity as PicCotationDistance;
                _desWriter.WriteCotationDistance(
                    new DES_CotationDistance(
                        (float)cotation.Pt0.X, (float)cotation.Pt0.Y, (float)cotation.Pt1.X, (float)cotation.Pt1.Y
                        , LineTypeToDesPen(cotation.LineType)
                        , (byte)cotation.Group
                        , (byte)cotation.Layer
                        , (float)cotation.Offset
                        , 0.0f
                        , 0.0f
                        , 0.0f
                        , false, false, false, false, 1, cotation.Text, ' ')
                    );
            }
            break;

            case PicEntity.ECode.PE_COTATIONHORIZONTAL:
            {
                PicCotationHorizontal cotation = entity as PicCotationHorizontal;
                // get offset points
                Vector2D offsetPt0, offsetPt1;
                cotation.GetOffsetPoints(out offsetPt0, out offsetPt1);

                _desWriter.WriteCotationDistance(
                    new DES_CotationDistance(
                        (float)offsetPt0.X, (float)offsetPt0.Y, (float)offsetPt1.X, (float)offsetPt1.Y
                        , LineTypeToDesPen(cotation.LineType)
                        , (byte)cotation.Group
                        , (byte)cotation.Layer
                        , (float)(cotation.Pt0.Y - offsetPt0.Y + cotation.Offset)
                        , 0.0f
                        , 0.0f
                        , 0.0f
                        , false, false, false, false, 1, cotation.Text, ' ')
                    );
            }
            break;

            case PicEntity.ECode.PE_COTATIONVERTICAL:
            {
                PicCotationVertical cotation = entity as PicCotationVertical;
                // get offset points
                Vector2D offsetPt0, offsetPt1;
                cotation.GetOffsetPoints(out offsetPt0, out offsetPt1);

                _desWriter.WriteCotationDistance(
                    new DES_CotationDistance(
                        (float)offsetPt0.X, (float)offsetPt0.Y, (float)offsetPt1.X, (float)offsetPt1.Y
                        , LineTypeToDesPen(cotation.LineType)
                        , (byte)cotation.Group
                        , (byte)cotation.Layer
                        , (float)(offsetPt0.X - cotation.Pt0.X + cotation.Offset)
                        , 0.0f
                        , 0.0f
                        , 0.0f
                        , false, false, false, false, 1, cotation.Text, ' ')
                    );
            }
            break;

            case PicEntity.ECode.PE_COTATIONRADIUSEXT:
            {
            }
            break;

            case PicEntity.ECode.PE_COTATIONRADIUSINT:
            {
            }
            break;

            case PicEntity.ECode.PE_BLOCK:
            {
                PicBlock block = entity as PicBlock;
                foreach (PicEntity blockEntity in block)
                {
                    ProcessEntity(blockEntity);
                }
            }
            break;

            case PicEntity.ECode.PE_BLOCKREF:
            {
                PicBlockRef blockRef = entity as PicBlockRef;
                _desWriter.WriteBlockRef(
                    new DES_Pose(
                        (float)blockRef.Position.X
                        , (float)blockRef.Position.Y
                        , (float)blockRef.Angle
                        , (byte)blockRef.Block.ExportedGroup)
                    );
            }
            break;

            case PicEntity.ECode.PE_CARDBOARDFORMAT:
            {
            }
            break;

            default:
                throw new Exception("Can not export this kind of entity!");
            }
        }