Пример #1
0
        public static void FindOverlapingPolylines(ObjectId[] objectIds)
        {
            // 1. 建立拓扑关系
            var topoData = BuildTopology(objectIds);

            // 2. 清理掉所有的临时图形
            PolylineTransientGraphics.ClearTransientGraphics();

            var findOverlap = new FindOverlap();

            // 3. 查找重叠的几何图元
            var polygonOverlaps = FindOverlappingGeometries(findOverlap, topoData, objectIds);

            // 4. 画出所有几何图元
            DrawOverlappingGeometries(topoData, polygonOverlaps);

            findOverlap.ReleaseRegions();

            // 5. 输出到窗口
            var document = Application.DocumentManager.MdiActiveDocument;

            document.Editor.WriteMessage(String.Format("一共有{0}处重叠", polygonOverlaps.GeometryOverlaps.Count));

            OutputMessage(polygonOverlaps.CannotCreateRegions, "不能造区");
            OutputMessage(polygonOverlaps.CannotBooleanRegions, "不能作布尔运算");
            OutputMessage(topoData.WrongEnvelopeObjects, "包围盒计算错误,可能有重复点");
            OutputMessage(topoData.InvalidObjects, "内部拓扑错误");
        }
Пример #2
0
        public static void DrawOverlappingGeometries(TopologyData topoData, PolygonOverlaps overlaps)
        {
            if (!overlaps.GeometryOverlaps.Any())
            {
                return;
            }

            var regions  = new List <Region>();
            var database = overlaps.GeometryOverlaps[0].ThisGeometry.Database;

            // 读取CAD图元,并且绘制出来
            foreach (var overlap in overlaps.GeometryOverlaps)
            {
                regions.Add(overlap.IntersectRegion);
            }

            // 画出来
            PolylineTransientGraphics.CreateTransientRegions(database, regions);
        }