コード例 #1
0
 private void add(Edge edge, Object edgeSet) {
   Coordinate[] pts = edge.getCoordinates();
   for (int i = 0; i < pts.length - 1; i++) {
     SweepLineSegment ss = new SweepLineSegment(edge, i);
     SweepLineEvent insertEvent = new SweepLineEvent(edgeSet, ss.getMinX(), null, ss);
     events.add(insertEvent);
     events.add(new SweepLineEvent(edgeSet, ss.getMaxX(), insertEvent, ss));
   }
 }
コード例 #2
0
 private void processOverlaps(int start, int end, SweepLineEvent ev0, SegmentIntersector si) {
   SweepLineSegment ss0 = (SweepLineSegment) ev0.getObject();
   /**
    * 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 ev1 = (SweepLineEvent) events.get(i);
     if (ev1.isInsert()) {
       SweepLineSegment ss1 = (SweepLineSegment) ev1.getObject();
       if (ev0.edgeSet == null || (ev0.edgeSet != ev1.edgeSet)) {
         ss0.computeIntersections(ss1, si);
         nOverlaps++;
       }
     }
   }
 }