コード例 #1
0
        private IEnumerable <CurveCrossingInfo> SearchDuplicateEntities2(ObjectId curveId, CurveVertexKdTree <CurveVertex> kdTree,
                                                                         HashSet <KeyValuePair <ObjectId, ObjectId> > visited, Transaction transaction)
        {
            var result = new List <CurveCrossingInfo>();
            var curve  = transaction.GetObject(curveId, OpenMode.ForRead) as Curve;

            if (curve == null)
            {
                return(new List <CurveCrossingInfo>());
            }
            var extents      = curve.GeometricExtents;
            var nearVertices = kdTree.BoxedRange(extents.MinPoint.ToArray(), extents.MaxPoint.ToArray());

            foreach (var nearVertex in nearVertices)
            {
                if (nearVertex.Id == curveId ||
                    visited.Contains(new KeyValuePair <ObjectId, ObjectId>(curveId, nearVertex.Id)) ||
                    visited.Contains(new KeyValuePair <ObjectId, ObjectId>(nearVertex.Id, curveId)))
                {
                    continue;
                }
                var sourceVertices = CurveUtils.GetDistinctVertices(curve, transaction);
                var targetVertices = CurveUtils.GetDistinctVertices(nearVertex.Id, transaction);
                var identical      = PolygonIncludeSearcher.AreIdenticalCoordinates(sourceVertices, targetVertices);
                if (identical)
                {
                    result.Add(new CurveCrossingInfo(curveId, nearVertex.Id, sourceVertices.ToArray()));
                }
                visited.Add(new KeyValuePair <ObjectId, ObjectId>(curveId, nearVertex.Id));
            }
            return(result);
        }
コード例 #2
0
        bool AnalyzePolygonsUnionable(List <Point3d> sourcePolygon, List <Point3d> targetPolygon,
                                      out List <Point3d> unionPolygon)
        {
            unionPolygon = sourcePolygon;
            var unionResult = MinimalLoopSearcher2.ClipperBoolean(new List <List <Point3d> >()
            {
                sourcePolygon
            },
                                                                  new List <List <Point3d> >()
            {
                targetPolygon
            }, ClipType.ctUnion);

            if (unionResult.Count > 1)
            {
                if (unionResult.Count == 2)
                {
                    if ((PolygonIncludeSearcher.AreIdenticalCoordinates(sourcePolygon, unionResult[0]) ||
                         PolygonIncludeSearcher.AreIdenticalCoordinates(sourcePolygon, unionResult[1])))
                    {
                        return(false);
                    }
                }

                unionResult = unionResult
                              .OrderByDescending(it => ComputerGraphics.PolygonArea(it.ToArray()))
                              .ToList();
                var source = new List <List <Point3d> >()
                {
                    unionResult[0]
                };
                // 如果存在多于一个布尔运算结果的情况,需要分析他们是否有包含关系
                for (int i = 1; i < unionResult.Count; i++)
                {
                    var subUnionResult = MinimalLoopSearcher2.ClipperBoolean(
                        source, new List <List <Point3d> >()
                    {
                        unionResult[i]
                    }, ClipType.ctUnion);
                    if (subUnionResult.Count > 1 || subUnionResult.Count <= 0)
                    {
                        return(false);
                    }
                    source = subUnionResult;
                }

                unionResult = source;
            }

            if (unionResult.Count != 1)
            {
                return(false);
            }
            unionPolygon = unionResult[0];
            return(true);
        }
コード例 #3
0
        protected override bool IsIntersectQualified(ObjectId sourceId, List <Point3d> sourceVertices, ObjectId targetId,
                                                     List <Point3d> targetVertices, List <Point3d> intersectPoints, Transaction transaction)
        {
            var duplicate = PolygonIncludeSearcher.AreDuplicateEntities(sourceVertices, targetVertices);

            if (duplicate)
            {
                return(true);
            }
            return(false);
        }
コード例 #4
0
        protected override bool IsIntersectQualified(ObjectId sourceId, List <Point3d> sourceVertices, ObjectId targetId,
                                                     List <Point3d> targetVertices, List <Point3d> intersectPoints, Transaction transaction)
        {
            var duplicateWithSource = PolygonIncludeSearcher.AreDuplicateEntities(sourceVertices, intersectPoints);
            var duplicateWithTarget = PolygonIncludeSearcher.AreDuplicateEntities(targetVertices, intersectPoints);

            // 确保它们不是软件认为的孔洞
            if (duplicateWithSource && !duplicateWithTarget && PolygonHoleHelper.IsHoleReferenced(transaction, sourceId) ||
                !duplicateWithSource && duplicateWithTarget && PolygonHoleHelper.IsHoleReferenced(transaction, targetId))
            {
                return(false);
            }
            return(true);
        }
コード例 #5
0
 protected virtual bool IsIntersectQualified(ObjectId sourceId, List <Point3d> sourceVertices, ObjectId targetId,
                                             List <Point3d> targetVertices, List <Point3d> intersectPoints, Transaction transaction)
 {
     // 是否将包含的情况排除
     if (ExceptInclude)
     {
         var duplicateWithSource = PolygonIncludeSearcher.AreDuplicateEntities(sourceVertices, intersectPoints);
         var duplicateWithTarget = PolygonIncludeSearcher.AreDuplicateEntities(targetVertices, intersectPoints);
         if (duplicateWithSource && !duplicateWithTarget || !duplicateWithSource && duplicateWithTarget)
         {
             return(false);
         }
     }
     return(true);
 }