Skip to content

Instantly share code, notes, and snippets.

@liesen
Created November 8, 2010 17:22
Show Gist options
  • Save liesen/667960 to your computer and use it in GitHub Desktop.
Save liesen/667960 to your computer and use it in GitHub Desktop.
CGAL bugs: Sweep line algorithm does not respect the report_endpoints argument
--- CGAL/Sweep_line_2/Sweep_line_2_visitors.h 2010-11-08 18:45:53.000000000 +0100
+++ /Users/liesen/crap/Sweep_line_2_visitors.h 2010-11-08 18:45:45.000000000 +0100
@@ -99,9 +99,7 @@
Status_line_iterator /* iter */,
bool /* flag */)
{
- if ((m_includeEndPoints ||
- event->is_intersection() ||
- event->is_weak_intersection()) && event->is_closed())
+ if ((event->is_intersection() || (event->is_weak_intersection() && m_includeEndPoints)) && event->is_closed())
{
*m_out = event->point();
++m_out;
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Cartesian.h>
#include <CGAL/Gmpq.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Sweep_line_2_algorithms.h>
#include <list>
#include <set>
typedef CGAL::Gmpq NT;
typedef CGAL::Simple_cartesian<NT> Kernel;
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
typedef Traits_2::Curve_2 Segment_2;
typedef Traits_2::Point_2 Point_2;
int main() {
const int kNumSegments = 2;
Segment_2 segments[kNumSegments] = {
Segment_2(Point_2(-2, 2), Point_2(2, -2)),
Segment_2(Point_2(-2, -2), Point_2(0, 0))
};
std::set<Point_2> intersection_points;
CGAL::compute_intersection_points(
segments,
segments + kNumSegments,
std::inserter(intersection_points, intersection_points.end()),
/* report_endpoints */ false);
std::copy(intersection_points.begin(), intersection_points.end(),
std::ostream_iterator<Point_2>(std::cout, "\n"));
assert(intersection_points.size() == 0);
return 0;
}
Display the source blob
Display the rendered blob
Raw
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="6" height="6" viewBox="-3 -3 6 6">
<line x1="-2" y1="2" x2="2" y2="-2" style="stroke: black;"/>
<line x1="-2" y1="-2" x2="0" y2="0" style="stroke: red;"/>
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment