/// <summary> /// Computes all mutual intersections between two sets of edges. /// </summary> /// <param name="edges0"></param> /// <param name="edges1"></param> /// <param name="si"></param> public override void ComputeIntersections(ArrayList edges0, ArrayList edges1, SegmentIntersector si) { Add(edges0, 0); Add(edges1, 1); ComputeIntersections(si, true); }
/// <summary> /// /// </summary> /// <param name="mce"></param> /// <param name="si"></param> public void ComputeIntersects(MonotoneChainEdge mce, SegmentIntersector si) { for (int i = 0; i < _startIndex.Length - 1; i++) { for (int j = 0; j < mce.StartIndex.Length - 1; j++) { ComputeIntersectsForChain( i, mce, j, si ); } } }
private void ProcessOverlaps(int start, int end, MonotoneChain mc0, SegmentIntersector si, bool doMutualOnly) { // Since we might need to test for self-intersections, // include current insert event object in list of event objects to test. // Last index can be skipped, because it must be a Delete event. for ( int i = start; i < end; i++ ) { SweepLineEvent ev = (SweepLineEvent) _events[i]; if ( ev.IsInsert ) { MonotoneChain mc1 = (MonotoneChain) ev.Object; if ( !doMutualOnly || ( mc0.GeomIndex != mc1.GeomIndex ) ) { mc0.ComputeIntersections( mc1, si ); _nOverlaps++; } } } // for ( int i = start; i < end; i++ ) }
/// <summary> /// Computes all self-intersections between edges in a set of edges. /// </summary> /// <param name="edges">Array of edges from which to compute self-intersections.</param> /// <param name="si">SegmentIntersector object.</param> public override void ComputeIntersections( ArrayList edges, SegmentIntersector si ) { Add(edges, 0); ComputeIntersections(si, false); }
/// <summary> /// Computes the intersections. /// </summary> public void ComputeIntersections(SweepLineSegment sweepLineSegment, SegmentIntersector segmentIntersector) { segmentIntersector.AddIntersections(_edge, _ptIndex, sweepLineSegment.Edge, sweepLineSegment.PointIndex); }
private void ComputeIntersections(SegmentIntersector si, bool doMutualOnly) { _nOverlaps = 0; PrepareEvents(); for( int i = 0; i < _events.Count; i++ ) { SweepLineEvent ev = (SweepLineEvent)_events[i]; MonotoneChain mc = (MonotoneChain) ev.Object; if ( ev.IsInsert ) { ProcessOverlaps( i, ev.DeleteEventIndex, mc, si, doMutualOnly ); } } }
/// <summary> /// /// </summary> /// <param name="g"></param> /// <param name="li"></param> /// <param name="includeProper"></param> /// <returns></returns> public SegmentIntersector ComputeEdgeIntersections( GeometryGraph g, LineIntersector li, bool includeProper) { SegmentIntersector si = new SegmentIntersector( li, includeProper, true); si.SetBoundaryNodes( GetBoundaryNodes(), g.GetBoundaryNodes() ); EdgeSetIntersector esi = new SimpleMCSweepLineIntersector(); esi.ComputeIntersections( _edges, g.Edges, si ); /* foreach ( object obj in g ) { Edge e = (Edge) obj; Trace.WriteLine( e.EdgeIntersectionList.ToString() ); } */ return si; }
/// <summary> /// /// </summary> /// <param name="mc"></param> /// <param name="si"></param> public void ComputeIntersections(MonotoneChain mc, SegmentIntersector si) { _mce.ComputeIntersectsForChain( _chainIndex, mc.MonotoneChainEdge, mc.ChainIndex, si); }
/// <summary> /// Computes all self-intersections between edges in a set of edges. /// </summary> /// <param name="edges">Array of edges from which to compute self-intersections.</param> /// <param name="si">SegmentIntersector object.</param> public override void ComputeIntersections(ArrayList edges, SegmentIntersector si) { Add(edges, 0); ComputeIntersections(si, false); }
} // private void InsertEdgeEnds( ArrayList ee ) /// <summary> /// /// </summary> /// <param name="intersector"></param> /// <param name="im"></param> private void ComputeProperIntersectionIM( SegmentIntersector intersector, IntersectionMatrix im ) { // If a proper intersection is found, we can set a lower bound on the IM. int dimA = _arg[0].Geometry.GetDimension(); int dimB = _arg[1].Geometry.GetDimension(); bool hasProper = intersector.HasProperIntersection; bool hasProperInterior = intersector.HasProperInteriorIntersection; // For Geometrys of dim 0 there can never be proper intersections. // If edge segments of Areas properly intersect, the areas must properly overlap. if ( dimA == 2 && dimB == 2 ) { if ( hasProper ) { im.SetAtLeast( "212101212" ); } } // if ( dimA == 2 && dimB == 2 ) // If an Line segment properly intersects an edge segment of an Area, // it follows that the Interior of the Line intersects the Boundary of the Area. // If the intersection is a proper <i>interior</i> intersection, then // there is an Interior-Interior intersection too. // Note that it does not follow that the Interior of the Line intersects the Exterior // of the Area, since there may be another Area component which contains the rest of the Line. else if ( dimA == 2 && dimB == 1 ) { if ( hasProper ) { im.SetAtLeast( "FFF0FFFF2" ); } if ( hasProperInterior ) { im.SetAtLeast( "1FFFFF1FF" ); } } // else if ( dimA == 2 && dimB == 1 ) else if ( dimA == 1 && dimB == 2 ) { if ( hasProper ) { im.SetAtLeast("F0FFFFFF2"); } if ( hasProperInterior ) { im.SetAtLeast("1F1FFFFFF"); } } // else if ( dimA == 1 && dimB == 2 ) // If edges of LineStrings properly intersect *in an interior point*, all // we can deduce is that // the interiors intersect. (We can NOT deduce that the exteriors intersect, // since some other segments in the geometries might cover the points in the // neighbourhood of the intersection.) // It is important that the point be known to be an interior point of // both Geometries, since it is possible in a self-intersecting geometry to // have a proper intersection on one segment that is also a boundary point of another segment. else if ( dimA == 1 && dimB == 1 ) { if ( hasProperInterior ) { im.SetAtLeast( "0FFFFFFFF" ); } } // else if ( dimA == 1 && dimB == 1 ) } // private void ComputeProperIntersectionIM( SegmentIntersector intersector, IntersectionMatrix im )
/// <summary> /// Computes all mutual intersections between two sets of edges. /// </summary> /// <param name="edges0"></param> /// <param name="edges1"></param> /// <param name="si"></param> public abstract void ComputeIntersections(ArrayList edges0, ArrayList edges1, SegmentIntersector si);
/// <summary> /// /// </summary> /// <param name="mc"></param> /// <param name="si"></param> public void ComputeIntersections(MonotoneChain mc, SegmentIntersector si) { _mce.ComputeIntersectsForChain(_chainIndex, mc.MonotoneChainEdge, mc.ChainIndex, si); }
/// <summary> /// /// </summary> /// <param name="chainIndex0"></param> /// <param name="mce"></param> /// <param name="chainIndex1"></param> /// <param name="si"></param> public void ComputeIntersectsForChain( int chainIndex0, MonotoneChainEdge mce, int chainIndex1, SegmentIntersector si ) { ComputeIntersectsForChain( _startIndex[chainIndex0], _startIndex[chainIndex0 + 1], mce, mce.StartIndex[chainIndex1], mce.StartIndex[chainIndex1 + 1], si ); }
/// <summary> /// /// </summary> /// <param name="li"></param> /// <returns></returns> public SegmentIntersector ComputeSelfNodes(LineIntersector li) { SegmentIntersector si = new SegmentIntersector( li, true, false); //EdgeSetIntersector esi = new MCQuadIntersector(); _edgeSetIntersector.ComputeIntersections( _edges, si ); //Trace.WriteLine( "SegmentIntersector # tests = " + si._numTests ); AddSelfIntersectionNodes( _argIndex ); return si; }
private void ComputeIntersectsForChain( int start0, int end0, MonotoneChainEdge mce, int start1, int end1, SegmentIntersector ei ) { Coordinate p00 = _pts[start0]; Coordinate p01 = _pts[end0]; Coordinate p10 = mce.Coordinates[start1]; Coordinate p11 = mce.Coordinates[end1]; //Debug.println("computeIntersectsForChain:" + p00 + p01 + p10 + p11); // terminating condition for the recursion if (end0 - start0 == 1 && end1 - start1 == 1) { ei.AddIntersections( _e, start0, mce.Edge, start1); return; } // nothing to do if the envelopes of these chains don't overlap _env1.Initialize(p00, p01); _env2.Initialize(p10, p11); if ( !_env1.Intersects( _env2 ) ) return; // the chains overlap, so split each in half and iterate (binary search) int mid0 = (start0 + end0) / 2; int mid1 = (start1 + end1) / 2; // Assert: mid != start or end (since we checked above for end - start <= 1) // check terminating conditions before recursing if (start0 < mid0) { if (start1 < mid1) { ComputeIntersectsForChain( start0, mid0, mce, start1, mid1, ei ); } if (mid1 < end1) { ComputeIntersectsForChain( start0, mid0, mce, mid1, end1, ei ); } } if (mid0 < end0) { if (start1 < mid1) { ComputeIntersectsForChain( mid0, end0, mce, start1, mid1, ei); } if (mid1 < end1) { ComputeIntersectsForChain( mid0, end0, mce, mid1, end1, ei); } } }
/// <summary> /// Computes all mutual intersections between two sets of edges. /// </summary> /// <param name="edges0"></param> /// <param name="edges1"></param> /// <param name="si"></param> abstract public void ComputeIntersections(ArrayList edges0, ArrayList edges1, SegmentIntersector si);