Implementation of Bentley-Ottmann algorithm