Esempio n. 1
0
        /// <summary>
        /// Compute self-nodes, taking advantage of the Geometry type to
        /// minimize the number of intersection tests.  (E.g. rings are
        /// not tested for self-intersection, since they are assumed to be valid).
        /// </summary>
        /// <param name="li">The <c>LineIntersector</c> to use.</param>
        /// <param name="computeRingSelfNodes">If <c>false</c>, intersection checks are optimized to not test rings for self-intersection.</param>
        /// <returns>The SegmentIntersector used, containing information about the intersections found.</returns>
        public SegmentIntersector ComputeSelfNodes(LineIntersector li, bool computeRingSelfNodes)
        {
            SegmentIntersector si  = new SegmentIntersector(li, true, false);
            EdgeSetIntersector esi = CreateEdgeSetIntersector();

            // optimized test for Polygons and Rings
            if (!computeRingSelfNodes &&
                (parentGeom is ILinearRing || parentGeom is IPolygon || parentGeom is IMultiPolygon))
            {
                esi.ComputeIntersections(edges, si, false);
            }
            else
            {
                esi.ComputeIntersections(edges, si, true);
            }
            AddSelfIntersectionNodes(argIndex);
            return(si);
        }
Esempio n. 2
0
        /// <summary>
        /// Compute self-nodes, taking advantage of the Geometry type to
        /// minimize the number of intersection tests.  (E.g.rings are
        /// not tested for self-intersection, since they are assumed to be valid).
        /// </summary >
        /// <param name="li">The <c>LineIntersector</c> to use</param>
        /// <param name="computeRingSelfNodes">If <value>false</value>, intersection checks are optimized to not test rings for self-intersection</param>
        /// <param name="isDoneIfProperInt">Short-circuit the intersection computation if a proper intersection is found</param>
        public SegmentIntersector ComputeSelfNodes(LineIntersector li, bool computeRingSelfNodes, bool isDoneIfProperInt)
        {
            SegmentIntersector si = new SegmentIntersector(li, true, false);

            si.IsDoneIfProperInt = isDoneIfProperInt;
            EdgeSetIntersector esi = CreateEdgeSetIntersector();
            // optimize intersection search for valid Polygons and LinearRings
            var isRings = _parentGeom is ILinearRing ||
                          _parentGeom is IPolygon ||
                          _parentGeom is IMultiPolygon;
            var computeAllSegments = computeRingSelfNodes || !isRings;

            esi.ComputeIntersections(Edges, si, computeAllSegments);

            //System.out.println("SegmentIntersector # tests = " + si.numTests);
            AddSelfIntersectionNodes(_argIndex);
            return(si);
        }