private void addLine(Coordinate[] pts) {
   SegmentString segStr = new BasicSegmentString(pts, null);
   List segChains = MonotoneChainBuilder.getChains(segStr.getCoordinates(), segStr);
   for (Iterator i = segChains.iterator(); i.hasNext(); ) {
     MonotoneChain mc = (MonotoneChain) i.next();
     index.insert(mc.getEnvelope(), mc);
   }
 }
 private void init(Geometry geom) {
   List lines = LinearComponentExtracter.getLines(geom);
   for (Iterator i = lines.iterator(); i.hasNext(); ) {
     LineString line = (LineString) i.next();
     Coordinate[] pts = line.getCoordinates();
     addLine(pts);
   }
 }
 private void countSegs(
     RayCrossingCounter rcc, Envelope rayEnv, List monoChains, MCSegmentCounter mcSegCounter) {
   for (Iterator i = monoChains.iterator(); i.hasNext(); ) {
     MonotoneChain mc = (MonotoneChain) i.next();
     mc.select(rayEnv, mcSegCounter);
     // short-circuit if possible
     if (rcc.isOnSegment()) return;
   }
 }