Esempio n. 1
0
        public static void ShowPoints()
        {
            var p1 = Interaction.GetPoint("坐标1");
            var p2 = Interaction.GetPoint("坐标2");

            Interaction.WriteLine(string.Format("({0} {1})", p1, p2));
            PointInfo pi1 = GetRoomsCommand.GetPointInfo(p1);
            PointInfo pi2 = GetRoomsCommand.GetPointInfo(p2);

            Interaction.WriteLine(string.Format("({0} {1})", pi1, pi2));
        }
Esempio n. 2
0
        /// <summary>
        /// 根据图形获取该图形内的名称
        /// </summary>
        /// <param name="sp"></param>
        /// <returns></returns>
        public static string getShapeName(CADShape sp)
        {
            string name = "";

            double pMinX = double.MaxValue;
            double pMinY = double.MaxValue;
            double pMaxX = double.MinValue;
            double pMaxY = double.MinValue;

            //查找 多边型 最小的点,和最大点的坐标
            foreach (CADPoint p1 in sp.Points)
            {
                if (p1.X < pMinX)
                {
                    pMinX = p1.X;
                }
                if (p1.Y < pMinY)
                {
                    pMinY = p1.Y;
                }

                if (p1.Y > pMaxY)
                {
                    pMaxY = p1.Y;
                }
                if (p1.X > pMaxX)
                {
                    pMaxX = p1.X;
                }
            }

            Point3d pMin = new Point3d(pMinX, pMinY, 0);
            Point3d pMax = new Point3d(pMaxX, pMaxY, 0);

            if (sp.Points.Count == 2)
            {
                pMin = new Point3d(sp.Points[0].X, sp.Points[0].Y, 0);
                pMax = new Point3d(sp.Points[1].X, sp.Points[1].Y, 0);
            }



            name = GetRoomsCommand.GetText(pMin, pMax);


            return(name);
        }
        public static void GetOneFloorWithRoot(string floorLayer, string parkName)
        {
            DateTime start = DateTime.Now;

            TopoInfo floor = GetOneFloorOpt(floorLayer);
            string   xml   = "";

            if (!string.IsNullOrEmpty(parkName))
            {
                InitInfo initInfo = GetRoomsCommand.CreateParkInitInfoByFloors(parkName, floorLayer, floor);
                xml = XmlSerializeHelper.GetXmlText(initInfo);
                MyTool.TextReport("获取一个楼层和园区", xml, 700, 500);
            }
            else
            {
                xml = XmlSerializeHelper.GetXmlText(floor, true);
                MyTool.TextReport("获取一个楼层", xml, 700, 500);
            }

            DateTime end = DateTime.Now;
            TimeSpan t   = end - start;
        }
        /// <summary>
        /// Thickness:厚度,层高
        /// IsRelative="true"
        /// BottomHeight:离地面高度,0层为0,6.5层为:6500
        /// </summary>
        /// <param name="name"></param>

        //获取楼层内的房间 //add by qclei 2020-07-10
        public static void GetAllFloors(string buildingName, int buildingFloorCount, string parkName)
        {
            DateTime        start  = DateTime.Now;
            List <TopoInfo> floors = GetFloorList(buildingName, buildingFloorCount);
            string          xml    = "";

            if (!string.IsNullOrEmpty(parkName))
            {
                InitInfo initInfo = GetRoomsCommand.CreateParkInitInfoByFloors(parkName, buildingName, floors.ToArray());
                xml = XmlSerializeHelper.GetXmlText(initInfo);
                MyTool.TextReport("获取整个大楼和园区", xml, 700, 500);
            }
            else
            {
                TopoInfo initInfo = GetRoomsCommand.CreateBuildingInitInfoByFloors(buildingName, floors.ToArray());
                xml = XmlSerializeHelper.GetXmlText(initInfo, true);
                MyTool.TextReport("获取整个大楼", xml, 700, 500);
            }


            DateTime end = DateTime.Now;
            TimeSpan t   = end - start;
        }
Esempio n. 5
0
 public static void GetInitInfoEx()
 {
     GetRoomsCommand.GetInitInfoEx();
 }
Esempio n. 6
0
 public static void GetRooms()
 {
     GetRoomsCommand.GetRoomsInfo();
 }
        private static InitInfo CreateInitInfo(string parkName, int maxFloorCount)
        {
            InitInfo initInfo = new InitInfo();
            TopoInfo root     = new TopoInfo("根节点", AreaTypes.区域);

            initInfo.TopoInfo = root;

            try
            {
                //"园区"
                ShapesDefine parkpoint = GetParkLayerByName("园区", false);

                TopoInfo park = new TopoInfo(parkName, AreaTypes.园区);//todo:可以扩展成园区、大楼手动设置

                if (parkpoint.shapelist.Count > 0)
                {
                    List <PointInfo> point = new List <PointInfo>();

                    foreach (CADShape vl in parkpoint.shapelist)
                    {
                        Dictionary <string, int> repoint = new Dictionary <string, int>(); //去除重复的点

                        foreach (CADPoint p in vl.Points)
                        {
                            PointInfo sub = new PointInfo((float)p.X, (float)p.Y);

                            string key = p.X.ToString() + "_" + p.Y.ToString();

                            if (!repoint.ContainsKey(key))
                            {
                                repoint[key] = 1;
                                point.Add(sub);
                            }
                        }
                        break;
                    }

                    BoundInfo boundInfo = GetRoomsCommand.NewBoundInfo();

                    List <PointInfo> newpoint = new List <PointInfo>();
                    ToPointFromClockwise(point, ref newpoint);
                    boundInfo.Points.AddRange(newpoint);
                    //boundInfo.Points.AddRange(point);

                    park.BoundInfo = boundInfo;
                    park.Name      = parkName;
                    park.Type      = AreaTypes.园区;
                }

                root.AddChild(park);

                // TopoInfo building = new TopoInfo("大楼", AreaTypes.大楼);
                //  park.AddChild(building);

                ShapesDefine floorpoint = GetParkLayerByName("大楼", true);

                TopoInfo group = new TopoInfo();
                group.Type = AreaTypes.分组;
                group.Name = "生产区域";

                park.AddChild(group);

                if (parkpoint.shapelist.Count > 0)
                {
                    foreach (CADShape vl in floorpoint.shapelist)
                    {
                        List <PointInfo>         point   = new List <PointInfo>();
                        Dictionary <string, int> repoint = new Dictionary <string, int>(); //去除重复的点

                        foreach (CADPoint p in vl.Points)
                        {
                            PointInfo sub = new PointInfo((float)p.X, (float)p.Y);
                            string    key = p.X.ToString() + "_" + p.Y.ToString();

                            if (!repoint.ContainsKey(key))
                            {
                                repoint[key] = 1;
                                point.Add(sub);
                            }
                        }
                        //break;

                        if (point.Count > 0)
                        {
                            List <PointInfo> newpoint = new List <PointInfo>();
                            ToPointFromClockwise(point, ref newpoint);


                            BoundInfo boundInfo = GetRoomsCommand.NewBoundInfo();
                            //boundInfo.Points.AddRange(point);
                            boundInfo.Points.AddRange(newpoint);

                            TopoInfo topoInfo = new TopoInfo();
                            topoInfo.BoundInfo = boundInfo;
                            topoInfo.Name      = vl.Name;
                            topoInfo.Type      = AreaTypes.大楼;
                            group.AddChild(topoInfo);

                            List <TopoInfo> floors = GetFloorList(vl.Name, maxFloorCount);//cww,合并 全厂_大楼_楼层_房间
                            foreach (var floor in floors)
                            {
                                topoInfo.AddChild(floor);
                            }
                        }
                    }
                }
            }
            catch
            {
            }
            root.SetAbsolute();
            return(initInfo);
        }
        public static TopoInfo GetOneFloorOpt(string floorLayer)
        {
            //InitInfo initInfo = new InitInfo();

            //TopoInfo root = new TopoInfo("根节点", AreaTypes.区域);
            //initInfo.TopoInfo = root;
            string   floorBoundLayer = floorLayer + "-边界";
            TopoInfo floor           = new TopoInfo(floorLayer, AreaTypes.楼层);//todo:可以扩展成园区、大楼手动设置

            try
            {
                //"园区"
                ShapesDefine parkpoint = GetParkLayerByName(floorBoundLayer, false);
                if (parkpoint.shapelist.Count > 0)
                {
                    List <PointInfo> point = new List <PointInfo>();

                    foreach (CADShape vl in parkpoint.shapelist)
                    {
                        Dictionary <string, int> repoint = new Dictionary <string, int>(); //去除重复的点

                        foreach (CADPoint p in vl.Points)
                        {
                            PointInfo sub = new PointInfo((float)p.X, (float)p.Y);

                            string key = p.X.ToString() + "_" + p.Y.ToString();

                            if (!repoint.ContainsKey(key))
                            {
                                repoint[key] = 1;
                                point.Add(sub);
                            }
                        }
                        break;
                    }
                    BoundInfo boundInfo = GetRoomsCommand.NewBoundInfo();
                    //boundInfo.Points.AddRange(point);
                    List <PointInfo> newpoint = new List <PointInfo>();
                    ToPointFromClockwise(point, ref newpoint);
                    boundInfo.Points.AddRange(newpoint);
                    boundInfo.IsRelative = true;
                    floor.BoundInfo      = boundInfo;
                    floor.Name           = floorLayer;
                    floor.Type           = AreaTypes.楼层;
                }
                //root.AddChild(floor);

                // TopoInfo building = new TopoInfo("大楼", AreaTypes.大楼);
                //  park.AddChild(building);

                ShapesDefine floorpoint = GetParkLayerByName(floorLayer, true);//房间都在楼层的Layer里面

                if (parkpoint.shapelist.Count > 0)
                {
                    foreach (CADShape vl in floorpoint.shapelist)
                    {
                        if (vl.Layer == floorBoundLayer)
                        {
                            //
                            continue;
                        }

                        List <PointInfo>         point   = new List <PointInfo>();
                        Dictionary <string, int> repoint = new Dictionary <string, int>(); //去除重复的点

                        foreach (CADPoint p in vl.Points)
                        {
                            PointInfo sub = new PointInfo((float)p.X, (float)p.Y);
                            string    key = p.X.ToString() + "_" + p.Y.ToString();

                            if (!repoint.ContainsKey(key))
                            {
                                repoint[key] = 1;
                                point.Add(sub);
                            }
                        }
                        //break;

                        if (point.Count > 0)
                        {
                            BoundInfo boundInfo = GetRoomsCommand.NewBoundInfo();
                            //  boundInfo.Points.AddRange(point);
                            boundInfo.IsRelative = false;//这里是true的话,楼层有偏移会导致房间整体偏移。

                            List <PointInfo> newpoint = new List <PointInfo>();
                            ToPointFromClockwise(point, ref newpoint);
                            boundInfo.Points.AddRange(newpoint);

                            TopoInfo topoInfo = new TopoInfo();
                            topoInfo.BoundInfo = boundInfo;
                            topoInfo.Name      = vl.Name;
                            if (vl.Name == "floorLayer")
                            {
                                topoInfo.Name = "机房_NoName";
                            }
                            topoInfo.Type = AreaTypes.机房;


                            floor.AddChild(topoInfo);
                        }
                    }
                }
            }
            catch
            {
            }

            return(floor);
        }
        private static InitInfo CreateInitInfo()
        {
            InitInfo initInfo = new InitInfo();
            TopoInfo root     = new TopoInfo("根节点", AreaTypes.区域);

            initInfo.TopoInfo = root;

            try
            {
                //"园区"
                ShapesDefine parkpoint = GetParkLayerByName("园区", false);

                TopoInfo park = new TopoInfo("园区", AreaTypes.园区);//todo:可以扩展成园区、大楼手动设置

                if (parkpoint.shapelist.Count > 0)
                {
                    List <PointInfo> point = new List <PointInfo>();

                    foreach (CADShape vl in parkpoint.shapelist)
                    {
                        foreach (CADPoint p in vl.Points)
                        {
                            PointInfo sub = new PointInfo((float)p.X, (float)p.Y);
                            point.Add(sub);
                        }
                        break;
                    }

                    BoundInfo boundInfo = GetRoomsCommand.NewBoundInfo();
                    boundInfo.Points.AddRange(point);

                    park.BoundInfo = boundInfo;
                    park.Name      = "园区";
                    park.Type      = AreaTypes.园区;
                }

                root.AddChild(park);

                // TopoInfo building = new TopoInfo("大楼", AreaTypes.大楼);
                //  park.AddChild(building);

                ShapesDefine floorpoint = GetParkLayerByName("大楼", true);

                if (parkpoint.shapelist.Count > 0)
                {
                    foreach (CADShape vl in floorpoint.shapelist)
                    {
                        List <PointInfo> point = new List <PointInfo>();

                        foreach (CADPoint p in vl.Points)
                        {
                            PointInfo sub = new PointInfo((float)p.X, (float)p.Y);
                            point.Add(sub);
                        }
                        //break;

                        if (point.Count > 0)
                        {
                            BoundInfo boundInfo = GetRoomsCommand.NewBoundInfo();
                            boundInfo.Points.AddRange(point);

                            TopoInfo topoInfo = new TopoInfo();
                            topoInfo.BoundInfo = boundInfo;
                            topoInfo.Name      = vl.Name;
                            topoInfo.Type      = AreaTypes.大楼;
                            park.AddChild(topoInfo);
                        }
                    }
                }
            }
            catch
            {
            }

            return(initInfo);
        }