The Bentley-Ottoman algorithm finds all crossings in a set of line segments. For a well known and important algorithm, it seems quite weird that a C++ implementation of Bentley-Ottmann algorithm — the implementation that can handle all the degenerated cases (i.e., no special assumption on the sweeping line and the number of intersection points, and so on) — is simply not available. The only code I can found is here, but it doesn't seem to handle the generalized case.
Is Bentley-Ottmann algorithm already implemented in any well-tested library, such as Boost or LEDA? If yes, may I have the reference to it?
http://geomalgorithms.com/a09-_intersect-3.html has a discussion of the Bentley-Ottmann and Shamos-Hoey algorithms and their relationship. It ends with a C++ implementation based on binary trees. Interesting reference material if you do not want to link to CGAL or boost.
CGAL has something in there with the same complexity as Bentley-Ottmann,
O((n + k)*log(n))
wheren
is the number of segments andk
is the number of intersections (not sure which algorithm they used):http://doc.cgal.org/latest/Sweep_line_2/index.html
CGAL has an implementation of the Bently-Ottmann algorithm. You can find more about it in the 2D Sweep Line of Planar Curves section in the manual.