Example #1
0
        public object Clone()
        {
            CEntity entity;

            entity = new CEntity();

            CloneEntity(entity);

            return(entity);
        }
Example #2
0
        public void CloneEntity(CEntity entity)
        {
            CGroupCode gc;

            entity.EntityName = EntityName;
            entity.LayerName  = LayerName;
            entity.Handle     = Handle;
            entity.LineType   = LineType;

            entity.X0 = X0;
            entity.Y0 = Y0;
            entity.Z0 = Z0;

            entity.X1 = X1;
            entity.Y1 = Y1;
            entity.Z1 = Z1;

            entity.X2 = X2;
            entity.Y2 = Y2;
            entity.Z2 = Z2;

            entity.X3 = X3;
            entity.Y3 = Y3;
            entity.Z3 = Z3;

            entity.X4 = X4;
            entity.Y4 = Y4;
            entity.Z4 = Z4;

            entity.Radius     = Radius;
            entity.StartAngle = StartAngle;
            entity.EndAngle   = EndAngle;

            entity.GroupCodeList = new ArrayList();

            if (GroupCodeList != null)
            {
                foreach (CGroupCode tmp in GroupCodeList)
                {
                    gc = (CGroupCode)tmp.Clone();
                    entity.GroupCodeList.Add(gc);
                }
            }

            entity.ChildTypeList = new ArrayList();

            if (ChildTypeList != null)
            {
                foreach (string tmp in ChildTypeList)
                {
                    entity.ChildTypeList.Add(tmp);
                }
            }
        }
Example #3
0
        public void FindComplexShapes(
            CEntityComplexShape fShape,
            double yOffset,
            double tolerance)
        {
            try
            {
                if (fShape.BasePointObject == null || fShape.BasePointEntity == null)
                {
                    return;
                }

                do
                {
                    CEntity basePointEntity = null;
                    #region find the base point entity
                    foreach (object obj in EntityList)
                    {
                        if (obj.GetType() == fShape.BasePointObject.GetType())
                        {
                            if (obj is CEntity)
                            {
                                CEntity entity = obj as CEntity;
                                if (!entity.PartOfComplexShape && !entity.Ignore)
                                {
                                    if (entity != null && fShape.BasePointEntity != null)
                                    {
                                        if (obj is CEntityLine)
                                        {
                                            if (entity.StartAngle == fShape.BasePointEntity.StartAngle &&
                                                entity.EndAngle == fShape.BasePointEntity.EndAngle &&
                                                Math.Round(entity.X1 - entity.X0, 3) == Math.Round(fShape.BasePointEntity.X1 - fShape.BasePointEntity.X0, 3) &&
                                                Math.Round(entity.Y1 - entity.Y0, 3) == Math.Round(fShape.BasePointEntity.Y1 - fShape.BasePointEntity.Y0, 3) &&
                                                Math.Round(entity.Radius, 3) + tolerance >= Math.Round(fShape.BasePointEntity.Radius, 3) &&
                                                Math.Round(entity.Radius, 3) - tolerance <= Math.Round(fShape.BasePointEntity.Radius, 3))
                                            {
                                                basePointEntity = entity;
                                                break;
                                            }
                                        }
                                        else if (obj is CEntityCircle || obj is CEntityArc)
                                        {
                                            if (entity.StartAngle == fShape.BasePointEntity.StartAngle &&
                                                entity.EndAngle == fShape.BasePointEntity.EndAngle &&
                                                Math.Round(entity.Radius, 3) + tolerance >= Math.Round(fShape.BasePointEntity.Radius, 3) &&
                                                Math.Round(entity.Radius, 3) - tolerance <= Math.Round(fShape.BasePointEntity.Radius, 3))
                                            {
                                                basePointEntity = entity;
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (basePointEntity == null)
                    {
                        break;
                    }
                    #endregion

                    #region find the shapes
                    bool foundShape = true;
                    foreach (object fObj in fShape.EntityList)
                    {
                        if (fObj is CEntity)
                        {
                            CEntity fEntity   = fObj as CEntity;
                            bool    foundLine = false;
                            PointF  fBegin    = new PointF((float)Math.Round(fEntity.X0 - fShape.BasePointEntity.X0, 3), (float)Math.Round(fEntity.Y0 - fShape.BasePointEntity.Y0, 3));
                            PointF  fEnd      = new PointF((float)Math.Round(fEntity.X1 - fShape.BasePointEntity.X1, 3), (float)Math.Round(fEntity.Y1 - fShape.BasePointEntity.Y1, 3));
                            foreach (object obj in EntityList)
                            {
                                if (obj.GetType() == fObj.GetType())
                                {
                                    CEntity entity = obj as CEntity;
                                    if (!entity.PartOfComplexShape)
                                    {
                                        PointF eBegin = new PointF((float)Math.Round(entity.X0 - basePointEntity.X0, 3), (float)Math.Round(entity.Y0 - basePointEntity.Y0, 3));
                                        PointF eEnd   = new PointF((float)Math.Round(entity.X1 - basePointEntity.X1, 3), (float)Math.Round(entity.Y1 - basePointEntity.Y1, 3));
                                        if (ArePointsEquivalent(fBegin, eBegin, (float)tolerance) && ArePointsEquivalent(fEnd, eEnd, (float)tolerance))
                                        {
                                            foundLine      = true;
                                            entity.InScope = true;
                                            break;
                                        }
                                    }
                                }
                            }
                            if (!foundLine)
                            {
                                foundShape             = false;
                                basePointEntity.Ignore = true;
                                foreach (object obj in EntityList)
                                {
                                    if (obj is CEntity)
                                    {
                                        ((CEntity)obj).InScope = false;
                                    }
                                }
                                break;
                            }
                        }
                    }
                    #endregion

                    #region shape is found
                    if (foundShape)
                    {
                        CEntityComplexShape shapeAdd = new CEntityComplexShape();
                        shapeAdd.PK = fShape.PK;
                        foreach (object obj in EntityList)
                        {
                            if (obj is CEntity)
                            {
                                CEntity entity = obj as CEntity;
                                if (!entity.PartOfComplexShape && entity.InScope)
                                {
                                    entity.PartOfComplexShape = true;
                                    if (obj is CEntityLine)
                                    {
                                        shapeAdd.LineList.Add((CEntityLine)obj);
                                    }
                                    else if (obj is CEntityCircle)
                                    {
                                        shapeAdd.CircleList.Add((CEntityCircle)obj);
                                    }
                                    else if (obj is CEntityArc)
                                    {
                                        shapeAdd.ArcList.Add((CEntityArc)obj);
                                    }
                                }
                            }
                        }
                        if (yOffset + tolerance >= shapeAdd.CenterPoint_Vertical &&
                            yOffset - tolerance <= shapeAdd.CenterPoint_Vertical)
                        {
                            ComplexShapeList.Add(shapeAdd);
                        }
                        else
                        {
                            basePointEntity.Ignore = true;
                            foreach (CEntityLine line in shapeAdd.LineList)
                            {
                                line.PartOfComplexShape = false;
                                //line.Ignore = true;
                                line.InScope = false;
                            }
                            foreach (CEntityCircle circle in shapeAdd.CircleList)
                            {
                                circle.PartOfComplexShape = false;
                                //circle.Ignore = true;
                                circle.InScope = false;
                            }
                            foreach (CEntityArc arc in shapeAdd.ArcList)
                            {
                                arc.PartOfComplexShape = false;
                                //arc.Ignore = true;
                                arc.InScope = false;
                            }
                        }
                    }
                    #endregion
                } while (true);
                foreach (object obj in EntityList)
                {
                    if (obj is CEntity)
                    {
                        ((CEntity)obj).InScope = false;
                        ((CEntity)obj).Ignore  = false;
                    }
                }
            }
            catch
            {
            }
        }