예제 #1
0
        public void Prepare(IEnumerable <IFeature> sourceFeatures,
                            IList <IFeature> targetFeatures,
                            IEnvelope processingExtent,
                            bool useMinimalTolerance,
                            ReshapeCurveFilterOptions filterOptions)
        {
            ClipExtent          = processingExtent;
            UseMinimumTolerance = useMinimalTolerance;

            IList <IGeometry> sourceGeometries =
                GdbObjectUtils.GetGeometries(sourceFeatures);

            // Consider remembering the pre-processed sources. But clipping is really fast.
            List <IPolyline> preprocessedSource =
                sourceGeometries
                .Select(
                    g => ChangeGeometryAlongUtils.GetPreprocessedGeometryForExtent(
                        g, processingExtent))
                .ToList();

            var targetGeometries = GdbObjectUtils.GetGeometries(targetFeatures);

            SubcurveFilter.PrepareFilter(
                preprocessedSource, targetGeometries, useMinimalTolerance, filterOptions);

            foreach (IGeometry sourceGeometry in sourceGeometries)
            {
                Marshal.ReleaseComObject(sourceGeometry);
            }

            foreach (IGeometry targetGeometry in targetGeometries)
            {
                Marshal.ReleaseComObject(targetGeometry);
            }
        }
예제 #2
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);
        }