Esempio n. 1
0
        /// <summary>
        /// Fix a single check result.
        /// </summary>
        /// <param name="result"></param>
        /// <param name="updateScreen"></param>
        public void FixCheckResult(CheckResult result, bool updateScreen)
        {
            if (result.Status != Status.Pending)
            {
                return;
            }

            var agent = _actionAgents[result.ActionType];

            // Must lock document because it's not in a model command.
            using (var docLock = Document.LockDocument())
            {
                List <ObjectId> resultIds = null;
                result.Status = agent.Action.Fix(result, out resultIds);
                if (result.Status == Status.Fixed)
                {
                    result.TargetIds = resultIds.ToArray();

                    // Update some check results to be invalid if they contains same ObjectIds.
                    foreach (var sourceId in result.SourceIds)
                    {
                        var relatedResults = _checkResultIndices[sourceId];
                        foreach (var relatedResult in relatedResults)
                        {
                            if (relatedResult == result)
                            {
                                continue;
                            }

                            relatedResult.Status = Status.Invalid;
                        }
                    }

                    // Update screen
                    if (updateScreen)
                    {
                        Document.Editor.UpdateScreen();
                    }
                }
            }
        }
        protected override Status FixImpl(CheckResult checkResult, out List <ObjectId> resultIds)
        {
            resultIds = new List <ObjectId>();
            var clusteredNodesCheckResult = checkResult as ClusteredNodesCheckResult;

            if (clusteredNodesCheckResult == null)
            {
                return(Status.Rejected);
            }

            var clusteredNodesInfo = clusteredNodesCheckResult.ClusteredNodes;

            using (var transaction = Document.Database.TransactionManager.StartTransaction())
            {
                // 每个clusteredNode的Postions都移动到key(Point3d)的位置, 暂时只处理Polyline
                foreach (var curveVertex in clusteredNodesInfo.Vertices)
                {
                    var curve = transaction.GetObject(curveVertex.Id, OpenMode.ForWrite) as Polyline;
                    if (curve == null)
                    {
                        continue;
                    }

                    // 比较curve的start point和end point到聚合点的距离。哪个短就在它的位置上插入一个节点用来连接线和聚合点
                    if ((curve.StartPoint - curveVertex.Point).Length < (curve.EndPoint - curveVertex.Point).Length)
                    {
                        double bulge = curve.GetBulgeAt(0);
                        curve.RemoveVertexAt(0);
                        curve.AddVertexAt(0, new Point2d(curveVertex.Point.X, curveVertex.Point.Y), bulge, 0, 0);
                    }
                    else
                    {
                        double bulge = curve.GetBulgeAt(curve.NumberOfVertices - 1);
                        curve.RemoveVertexAt(curve.NumberOfVertices - 1);
                        curve.AddVertexAt(curve.NumberOfVertices, new Point2d(curveVertex.Point.X, curveVertex.Point.Y), bulge, 0, 0);
                    }
                }
                transaction.Commit();
            }
            return(Status.Fixed);
        }
Esempio n. 3
0
        protected override Status FixImpl(CheckResult checkResult, out List <ObjectId> resultIds)
        {
            resultIds = new List <ObjectId>();
            var danglingCheckResult = checkResult as DanglingCheckResult;

            if (danglingCheckResult == null)
            {
                return(Status.Rejected);
            }

            using (var transaction = Document.Database.TransactionManager.StartTransaction())
            {
                foreach (var sourceId in checkResult.SourceIds)
                {
                    var entity = transaction.GetObject(sourceId, OpenMode.ForWrite);
                    entity.Erase();
                }
                transaction.Commit();
            }
            return(Status.Fixed);
        }
Esempio n. 4
0
        protected override Status FixImpl(CheckResult checkResult, out List <ObjectId> resultIds)
        {
            resultIds = new List <ObjectId>();
            var duplicateEntitiesCheckResult = checkResult as DuplicateEntitiesCheckResult;

            if (duplicateEntitiesCheckResult == null)
            {
                return(Status.Rejected);
            }

            // Fix 就是 Erase
            using (var transaction = Document.Database.TransactionManager.StartTransaction())
            {
                var crossInfo = duplicateEntitiesCheckResult.CrossingInfo;
                var entity    = transaction.GetObject(crossInfo.SourceId, OpenMode.ForWrite);
                entity.Erase();
                checkResult.TargetIds = new ObjectId[] { crossInfo.TargetId };
                transaction.Commit();
            }
            return(Status.Fixed);
        }
Esempio n. 5
0
        /// <summary>
        /// Highlight a check result.
        /// </summary>
        /// <param name="result"></param>
        public void HighlightCheckResult(CheckResult result)
        {
            // Set current check result.
            var previousCheckResult = CurrentCheckResult;

            CurrentCheckResult = result;

            using (var transaction = Document.Database.TransactionManager.StartTransaction())
            {
                if (previousCheckResult != null)
                {
                    HighlightCheckResultEntities(previousCheckResult, false, transaction);
                }

                if (result.HighlightEntity)
                {
                    HighlightCheckResultEntities(result, true, transaction);
                }
                transaction.Commit();
            }

            // Create transient graphics
            ShowTransientErrorMark(result);

            // Zoom the entities
            //var marksize = result.BaseSize;
            //var vector = new Vector3d(1, 1, 0).GetNormal()*marksize/2;
            //var position = result.Position;
            //var minPoint = position - vector;
            //var maxPoint = position + vector;
            //var extents = new Extents3d(minPoint, maxPoint);
            var extents = result.GeometricExtents;

            if (extents.HasValue)
            {
                Document.Editor.ZoomToWin(extents.Value, factor: 1.2);
            }
        }
Esempio n. 6
0
 protected override Status FixImpl(CheckResult checkResult, out List <ObjectId> resultIds)
 {
     resultIds = new List <ObjectId>();
     // Do nothing
     return(Status.NoFixMethod);
 }
Esempio n. 7
0
        public static string ToChineseName(this CheckResult checkResult)
        {
            string result = String.Empty;

            switch (checkResult.ActionType)
            {
            case ActionType.NoneZeroElevation:
                result = "高程不为0对象";
                break;

            case ActionType.DuplicateVertexPline:
                result = "多段线重复点";
                break;

            case ActionType.DeleteDuplicates:
                result = "重复对象";
                break;

            case ActionType.EraseShort:
                result = "短对象";
                break;

            case ActionType.BreakCrossing:
                result = "交叉对象";
                break;

            case ActionType.ExtendUndershoots:
                result = "未及点";
                break;

            case ActionType.ApparentIntersection:
                result = "外观交点";
                break;

            case ActionType.SnapClustered:
                result = "节点簇";
                break;

            case ActionType.DissolvePseudo:
                result = "伪节点";
                break;

            case ActionType.EraseDangling:
                result = "悬挂对象";
                break;

            case ActionType.ZeroLength:
                result = "零长度对象";
                break;

            case ActionType.ZeroAreaLoop:
                result = "零面积闭合线";
                break;

            case ActionType.SmallPolygon:
                result = "小面积多边形";
                break;

            case ActionType.UnclosedPolygon:
                result = "非闭合多段线";
                break;

            case ActionType.IntersectPolygon:
                result = "相交多边形";
                break;

            case ActionType.DuplicatePolygon:
                result = "重复多边形";
                break;

            case ActionType.SmallPolygonGap:
                result = "狭小地块缝隙";
                break;

            case ActionType.PolygonHole:
                result = "地块间孔洞";
                break;

            case ActionType.SelfIntersect:
                result = "自相交或回头线";
                break;

            case ActionType.MissingVertexInPolygon:
                result = "三岔口缺顶点";
                break;

            case ActionType.SelfIntersect2:
                result = "自相交";
                break;

            case ActionType.AntiClockwisePolygon:
                result = "逆时针多边形";
                break;

            case ActionType.FindDangling:
                result = "悬挂线";
                break;

            case ActionType.OverlapPolygon:
                result = "多边形重叠";
                break;

            case ActionType.AnnotationOverlap:
                result = "地块标注重叠";
                break;

            case ActionType.FindIslandPolygon:
                result = "未处理孔洞";
                break;

            case ActionType.ArcSegment:
                result = "弧段";
                break;

            case ActionType.RectifyPointDeviation:
                result = "极近点";
                break;

            case ActionType.SharpCornerPolygon:
                result = "狭长角多边形";
                break;
            }
            return(result);
        }
Esempio n. 8
0
 protected override Status FixImpl(CheckResult checkResult, out List <Autodesk.AutoCAD.DatabaseServices.ObjectId> resultIds)
 {
     resultIds = new List <ObjectId>();
     return(Status.NoFixMethod);
 }
 protected override Status FixImpl(CheckResult checkResult, out List <ObjectId> resultIds)
 {
     throw new System.NotImplementedException();
 }
Esempio n. 10
0
 protected abstract MapClean.Status FixImpl(CheckResult checkResult, out List <ObjectId> resultIds);