コード例 #1
0
ファイル: PolygonMerger.cs プロジェクト: tumcms/QL4BIM
        private void ComputeIntersections(Polygon polygonA, Polygon polygonB)
        {
            var polyCountA = polygonA.PointCount;
            var polyCountB = polygonB.PointCount;

            //todo close polygon

            var dictSecPointsA = new Dictionary <PolygonPoint, List <PolygonPoint> >();
            var dictSecPointsB = new Dictionary <PolygonPoint, List <PolygonPoint> >();

            for (int i = 0; i < polyCountA - 1; i++)
            {
                var pointA1 = polygonA[i];
                var pointA2 = polygonA[i + 1];

                for (int j = 0; j < polyCountB - 1; j++)
                {
                    var pointB1 = polygonB[j];
                    var pointB2 = polygonB[j + 1];

                    PolygonPoint intersectionPointA;
                    PolygonPoint intersectionPointB;
                    var          doesIntersect = triangleIntersector.EdgeAgainsEdge(pointA1, pointA2, pointB1, pointB2, 0, 1, out intersectionPointA, out intersectionPointB);

                    if (!doesIntersect)
                    {
                        continue;
                    }

                    AddIntersectionPoint(dictSecPointsA, pointA1, intersectionPointA);
                    AddIntersectionPoint(dictSecPointsB, pointB1, intersectionPointB);
                }
            }

            polygonA.AddIntersectionPoints(dictSecPointsA);
            polygonA.AddIntersectionPoints(dictSecPointsB);
        }