Beispiel #1
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);
            }
Beispiel #2
0
            /// <summary>
            /// Create a new block from an external container
            /// </summary>
            /// <param name="container">An object of a class that implements the <see cref="IEntityContainerInterface"/>. Either a <see cref="PicFactory"/> or a <see cref="PicBlock"/> instance.</param>
            /// <param name="transf">Transformation applied to all drawable entities</param>
            /// <returns></returns>
            public PicBlock AddBlock(IEntityContainer container, Transform2D transf)
            {
                PicBlock block = PicBlock.CreateNewBlock(GetNewEntityId(), container, transf);

                AddEntity(block);
                return(block);
            }
Beispiel #3
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);
                }
            }
        }
Beispiel #4
0
            public PicBlockRef AddBlockRef(PicBlock block, Transform2D transf)
            {
                PicBlockRef blockRef = PicBlockRef.CreateNewBlockRef(GetNewEntityId(), block, transf);

                AddEntity(blockRef);
                return(blockRef);
            }
Beispiel #5
0
 protected PicBlockRef(uint id, PicBlock block, Vector2D coord, double angle)
     : base(id)
 {
     _block = block;
     _coord = coord;
     _angle = angle;
     SetModified();
 }
Beispiel #6
0
 protected PicBlockRef(uint id, PicBlock block, Vector2D coord, double angle)
     : base(id)
 {
     Block    = block;
     Position = coord;
     Angle    = angle;
     SetModified();
 }
Beispiel #7
0
        public static PicBlock CreateNewBlock(uint id, IEntityContainer container, Transform2D transf)
        {
            PicBlock block = new PicBlock(id);

            // copies each entity from container (either block or factory) in block
            foreach (PicEntity entity in container)
            {
                PicTypedDrawable entityNew = entity.Clone(block) as PicTypedDrawable;
                entityNew.Transform(transf);
                block._entities.Add(entityNew);
            }
            return(block);
        }
        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 void CreateEntities(PicFactory factory)
        {
            // sanity check
            if (_positions.Count == 0)
            {
                return; // solution has no position -> exit
            }
            // get first position
            BPosition pos0 = _positions[0];
            // block
            PicBlock block = factory.AddBlock(_container, pos0.Transformation);

            // blockrefs
            for (int i = 1; i < _positions.Count; ++i) // do not insert first position as the block is now displayed
            {
                BPosition pos = _positions[i];
                factory.AddBlockRef(block, pos.Transformation * pos0.Transformation.Inverse());
            }
        }
        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;
            }
        }
        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);
            }
        }
Beispiel #13
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;
            }
        }
Beispiel #14
0
 public static PicBlockRef CreateNewBlockRef(uint id, PicBlock block, Vector2D coord, double angle)
 {
     return(new PicBlockRef(id, block, coord, angle));
 }
        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
                        , 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!");
            }
        }
Beispiel #17
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
                 *      , (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!");
            }
        }
Beispiel #19
0
 public static PicBlockRef CreateNewBlockRef(uint id, PicBlock block, Transform2D transf)
 {
     return(new PicBlockRef(id, block, transf.TranslationVector, transf.RotationAngle));
 }