consume (other) {
    let consumer = this
    let consumee = other
    while (consumer.consumedBy) consumer = consumer.consumedBy
    while (consumee.consumedBy) consumee = consumee.consumedBy

    const cmp = Segment.compare(consumer, consumee)
    if (cmp === 0) return  // already consumed
    // the winner of the consumption is the earlier segment
    // according to sweep line ordering
    if (cmp  > 0) {
      const tmp = consumer
      consumer = consumee
      consumee = tmp
    }

    // make sure a segment doesn't consume it's prev
    if (consumer.prev === consumee) {
      const tmp = consumer
      consumer = consumee
      consumee = tmp
    }

    for (let i = 0, iMax = consumee.ringsIn.length; i < iMax; i++) {
      consumer.ringsIn.push(consumee.ringsIn[i])
    }
    consumee.ringsIn = null
    consumee.consumedBy = consumer

    // mark sweep events consumed as to maintain ordering in sweep event queue
    consumee.leftSE.consumedBy = consumer.leftSE
    consumee.rightSE.consumedBy = consumer.rightSE
  }
/* Consume another segment. We take their ringsIn under our wing
   * and mark them as consumed. Use for perfectly overlapping segments */
Consume another segment. We take their ringsIn under our wing
and mark them as consumed. Use for perfectly overlapping segments
Consume another segment . We take their ringsIn under our wing and mark them as consumed . Use for perfectly overlapping segments
consume (other) {
    let consumer = this
    let consumee = other
    while (consumer.consumedBy) consumer = consumer.consumedBy
    while (consumee.consumedBy) consumee = consumee.consumedBy
    const cmp = Segment.compare(consumer, consumee)
    if (cmp === 0) return  
    if (cmp  > 0) {
      const tmp = consumer
      consumer = consumee
      consumee = tmp
    }
    if (consumer.prev === consumee) {
      const tmp = consumer
      consumer = consumee
      consumee = tmp
    }
    for (let i = 0, iMax = consumee.ringsIn.length; i < iMax; i++) {
      consumer.ringsIn.push(consumee.ringsIn[i])
    }
    consumee.ringsIn = null
    consumee.consumedBy = consumer
    consumee.leftSE.consumedBy = consumer.leftSE
    consumee.rightSE.consumedBy = consumer.rightSE
  }
consume ( other ) { let consumer = this let consumee = other while ( consumer . consumedBy ) consumer = consumer . consumedBy while ( consumee . consumedBy ) consumee = consumee . consumedBy const cmp = Segment . compare ( consumer , consumee ) if ( cmp === 0 ) return if ( cmp > 0 ) { const tmp = consumer consumer = consumee consumee = tmp } if ( consumer . prev === consumee ) { const tmp = consumer consumer = consumee consumee = tmp } for ( let i = 0 , iMax = consumee . ringsIn . length ; i < iMax ; i ++ ) { consumer . ringsIn . push ( consumee . ringsIn [ i ] ) } consumee . ringsIn = null consumee . consumedBy = consumer consumee . leftSE . consumedBy = consumer . leftSE consumee . rightSE . consumedBy = consumer . rightSE }
Consume another segment.
Consume another segment .
// already consumed // the winner of the consumption is the earlier segment // according to sweep line ordering // make sure a segment doesn't consume it's prev // mark sweep events consumed as to maintain ordering in sweep event queue