Ejemplo n.º 1
0
        private static bool ReshapeSinglePolygonInUnion(ReshapeInfo reshapeInfo)
        {
            bool reshaped;

            if (reshapeInfo.CutReshapePath != null)
            {
                if (reshapeInfo.CutReshapePath.Path.Length > 0)
                {
                    // reshape the known polygon part with the known cut reshape path
                    reshaped = ReshapeUtils.ReshapePolygonOrMultipatch(reshapeInfo);
                }
                else
                {
                    _msg.DebugFormat(
                        "No need to reshape geometry with 0-length reshape path at {0} | {1}",
                        reshapeInfo.CutReshapePath.Path.FromPoint.X,
                        reshapeInfo.CutReshapePath.Path.FromPoint.Y);
                    reshaped = false;
                }
            }
            else
            {
                Assert.NotNull(reshapeInfo.ReshapePath,
                               "Reshape path and cut reshape path are undefined");

                // try reshape if possible (typically for union-reshapes to the inside)
                var requiredPartIndexToReshape =
                    (int)Assert.NotNull(reshapeInfo.PartIndexToReshape);

                IList <int> currentlyReshapableParts;
                reshapeInfo.IdentifyUniquePartIndexToReshape(out currentlyReshapableParts);

                if (currentlyReshapableParts.Contains(requiredPartIndexToReshape))
                {
                    // reset to make sure no other parts are reshaped here:
                    reshapeInfo.PartIndexToReshape = requiredPartIndexToReshape;
                    reshaped = ReshapeUtils.ReshapeGeometryPart(reshapeInfo.GeometryToReshape,
                                                                reshapeInfo);
                }
                else
                {
                    reshaped = false;
                }
            }

            return(reshaped);
        }
Ejemplo n.º 2
0
        private static ReshapeInfo Reshape(IGeometry geometryToReshape,
                                           IGeometry reshapeLine,
                                           bool tryReshapeNonDefaultSide)
        {
            var reshapePath = (IPath)((IGeometryCollection)reshapeLine).get_Geometry(0);

            var reshapeInfo = new ReshapeInfo(geometryToReshape, reshapePath, null);

            reshapeInfo.ReshapeResultFilter = new ReshapeResultFilter(tryReshapeNonDefaultSide);

            IList <int> allParts;

            reshapeInfo.IdentifyUniquePartIndexToReshape(out allParts);

            Assert.IsTrue(ReshapeUtils.ReshapePolygonOrMultipatch(reshapeInfo));

            GeometryUtils.Simplify(geometryToReshape);

            return(reshapeInfo);
        }