Exemplo n.º 1
0
        /// <summary>
        /// Calculates the DifferenceLines and adds the subcurves to the provided result list.
        /// </summary>
        /// <param name="sourceGeometry"></param>
        /// <param name="targetPolyline"></param>
        /// <param name="resultList">All resulting subcurves including the ones that cannot be used to reshape</param>
        /// <param name="trackCancel"></param>
        /// <returns></returns>
        public ReshapeAlongCurveUsability CalculateSubcurves(
            IGeometry sourceGeometry,
            IPolyline targetPolyline,
            IList <CutSubcurve> resultList,
            ITrackCancel trackCancel)
        {
            Assert.ArgumentNotNull(sourceGeometry);
            Assert.ArgumentNotNull(targetPolyline);
            Assert.ArgumentNotNull(resultList);

            Stopwatch watch = _msg.DebugStartTiming();

            IPolyline preprocessedSourcePolyline =
                ChangeGeometryAlongUtils.GetPreprocessedGeometryForExtent(
                    sourceGeometry, ClipExtent);

            if (preprocessedSourcePolyline.IsEmpty)
            {
                _msg.WarnFormat("Source feature is outside the processing extent.");
                return(ReshapeAlongCurveUsability.NoSource);
            }

            IPointCollection    intersectionPoints;
            IGeometryCollection differences = CalculateDifferences(
                preprocessedSourcePolyline,
                targetPolyline,
                trackCancel,
                out intersectionPoints);

            if (trackCancel != null && !trackCancel.Continue())
            {
                return(ReshapeAlongCurveUsability.Undefined);
            }

            if (differences == null)
            {
                return(ReshapeAlongCurveUsability.AlreadyCongruent);
            }

            SubcurveFilter?.PrepareForSource(sourceGeometry);

            bool canReshape = CalculateReshapeSubcurves(
                preprocessedSourcePolyline, targetPolyline, differences,
                intersectionPoints, resultList, trackCancel);

            JoinNonForkingSubcurves(resultList);

            Marshal.ReleaseComObject(preprocessedSourcePolyline);
            Marshal.ReleaseComObject(differences);

            _msg.DebugStopTiming(
                watch, "RecalculateReshapableSubcurves: Total number of curves: {0}.",
                resultList.Count);

            if (canReshape)
            {
                return(ReshapeAlongCurveUsability.CanReshape);
            }

            return(resultList.Count == 0
                                       ? ReshapeAlongCurveUsability.NoReshapeCurves
                                       : ReshapeAlongCurveUsability.InsufficientOrAmbiguousReshapeCurves);
        }