Bentley-Otmann Algorithm 2.0
An implementation of Bentley-Ottmann algorithm in order to count the m,n-cubes
Bentley-Otmann Algorithm Documentation

This project implements Bentley-Ottmann's algorithm. For a set of segment lines, it computes and returns all the intersections of segment lines of this set. In order to do that, we use the generalized algorithm given in M.de Berg, 0.Cheong, M.van Kreveld and M.Overmars, Computational Geometry: Algorithms and Applications, Third Edition.

This algorithm is based on the principle of sweeping line. We sweep a line from the left to the right (in some papers, it can be found from the top to the bottom) in the 2D plan. At every position of the line, the intersections on the left of the line has been computed and those on the right are waiting to be treated. The interesting positions for the sweeping line are the endpoints of the segment lines of the set and the crossing points. We call those points events.

We treat each event in a natural way :

(Of course, a single event can be of more than one type.)

In order to realize that, we have to maintain two structures : one which gives the presently involved segment (those which are crossing the sweeping line) called the Y-structure and one giving the next event at every time called the X-structure. Since we want to compute all the intersections with a time complexity $ O((n+k) \log n) $ with $ n,k $ respectively the number of segments and the number of intersections, we have to compute all the actions on the X,Y-structures with a time complexity $ O(\log n) $. Naturally, we choose to work with some trees. The X-structure is a priority queue determining the next event at every time. For some algorithmic reasons (we want to be able to know if an object is a member of the X-structure in a logarithmic way), we will use a binary search tree with the lexographic order on the (x,y)-coordinates of the events. For the Y-structure, a binary search tree is a natural choice to order the segment, insert and remove them.

bo_event.png
An example of event with the three types of treatment.
At start, we push in the queue all the events corresponding to the endpoints of the segment lines of the set. Then, for each event :

(Of course, the several researches for neighboors depend of the existence of those neighboors. If they don't, we just have nothing to do relatively to it.)

The files bentley_ottmann.hpp and bentley_ottmann.cpp implement this algorithm. structures.hpp deals with the X,Y-structures using the STL and some customizations. All of that depends of a representation of some geometric objects, what is done in geometry.hpp and geometry.cpp.

 All Classes Files Functions Variables Typedefs Enumerations