GetPerpendicularSegmentPairs()
            {
                for (var baseIndex = 0; baseIndex < _sortedHorizontalSegments.Count; baseIndex++)
                {
                    AzimuthSegment baseSegment = _sortedHorizontalSegments[baseIndex];

                    double baseAzimuth = baseSegment.Azimuth;

                    WKSPointZ baseStart =
                        QaGeometryUtils.GetWksPoint(baseSegment.Segment.GetStart(true));

                    WKSPointZ baseEnd =
                        QaGeometryUtils.GetWksPoint(baseSegment.Segment.GetEnd(true));

                    double exactPerpendicularAzimuth = baseAzimuth + Math.PI / 2;
                    double minSearchAzimuth          = exactPerpendicularAzimuth - NearAngleRad;
                    double maxSearchAzimuth          = exactPerpendicularAzimuth + NearAngleRad;

                    for (int perpendicularIndex = baseIndex + 1;
                         perpendicularIndex < _sortedHorizontalSegments.Count;
                         perpendicularIndex++)
                    {
                        AzimuthSegment candidate = _sortedHorizontalSegments[perpendicularIndex];

                        if (candidate.Azimuth <= minSearchAzimuth)
                        {
                            continue;
                        }

                        if (candidate.Azimuth >= maxSearchAzimuth)
                        {
                            break;
                        }

                        WKSPointZ candidateStart =
                            QaGeometryUtils.GetWksPoint(candidate.Segment.GetStart(true));

                        WKSPointZ candidateEnd =
                            QaGeometryUtils.GetWksPoint(candidate.Segment.GetEnd(true));

                        if (IsConnected(baseStart, candidateStart) ||
                            IsConnected(baseStart, candidateEnd) ||
                            IsConnected(baseEnd, candidateStart) ||
                            IsConnected(baseEnd, candidateEnd))
                        {
                            yield return(new PerpendicularSegmentPair(baseSegment, candidate));
                        }
                    }
                }
            }
Exemple #2
0
        private static WKSPointZ[] GetWksPointZs(
            [NotNull] IIndexedSegments indexedSegments,
            int partIndex)
        {
            int partSegmentCount = indexedSegments.GetPartSegmentCount(partIndex);

            var segments = new List <SegmentProxy>(partSegmentCount);

            for (int segmentIndex = 0; segmentIndex < partSegmentCount; segmentIndex++)
            {
                segments.Add(indexedSegments.GetSegment(partIndex, segmentIndex));
            }

            var wksPoints = new List <WKSPointZ>(partSegmentCount + 1);

            foreach (Pnt point in QaGeometryUtils.GetPoints(segments))
            {
                wksPoints.Add(QaGeometryUtils.GetWksPoint(point));
            }

            return(wksPoints.ToArray());
        }