Hi,
i'm having a set of segments (each defined with two points; 2D) and want to know for every segment x, how many other segments y1,..., yn are intersecting x. How would you do that efficiently in CGAL?
I don't have any experience with the CGAL library and Computer Geometry at all. I just need an algorithm for doing the stuff mentioned above. Therefore i thought, instead of implementing a customized function, it would be better/more efficient to use this library.
The CGAL example sweep_line.cpp shows me how to get all the intersection points of a set o segments. Because i'm not interested in the points, i would have to check the points and segments to get the number of intersections for each segment. But i don't know how to do it in CGAL. And i'm also assuming that there is a more efficient way of doing it; meaning: avoiding calculating the points and iterating over all segments with a new check if this one is intersecting any found point.
Any tips? Thanks for your input!
sascha
PS: one more quick newbie question: why are the results of the following printed out with negative signs?
Segment_2 segments[] = {Segment_2 (Point_2 (1, 5), Point_2 (8, 5)),
Segment_2 (Point_2 (1, 1), Point_2 (8, 8)),
Segment_2 (Point_2 (3, 1), Point_2 (3, 8)),
Segment_2 (Point_2 (8, 5), Point_2 (8, 8))};
std::vector<Point_2> pts;
CGAL::compute_intersection_points (segments, segments + 4,
std::back_inserter (pts));
Found 3 intersection points: -21/-7 -21/-7 -3/-1 -5/-1 -35/-7 -35/-7
PS2: I recognized that my title an my first lines are not describing the same problem. I dont't need to know which segments interect x, but only the number of segments, like described in the text.