diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoTab.cpp b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoTab.cpp index 16af8df2000..27a9a5aaeed 100644 --- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoTab.cpp +++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementDemoTab.cpp @@ -62,7 +62,7 @@ void ArrangementDemoTabBase::setupUi( ) double wh = MAX_WIDTH; scene->setSceneRect(xymin, xymin, wh, wh); - this->getView()->installEventFilter(this->navigation.get()); + this->getView()->viewport()->installEventFilter(this->navigation.get()); } QGraphicsView* ArrangementDemoTabBase::getView() const diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/CMakeLists.txt b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/CMakeLists.txt index 3b07a04831c..efb33dbd69f 100644 --- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/CMakeLists.txt +++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/CMakeLists.txt @@ -93,5 +93,5 @@ if (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND) cgal_add_compilation_test(arrangement_2) else() - message(STATUS "NOTICE: This demo requires CGAL, CGAL-Core and Qt5, and will not be compiled.") + message(STATUS "NOTICE: This demo requires CGAL and Qt5, and will not be compiled.") endif() diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ConstructBoundingBox.cpp b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ConstructBoundingBox.cpp index c8f7c3bc847..b6fa672ec8e 100644 --- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ConstructBoundingBox.cpp +++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ConstructBoundingBox.cpp @@ -38,7 +38,8 @@ struct ConstructBoundingBox_impl // We currently avoid using bbox function in Arr_sgegment_2 because it creates // its own kernel object -// TODO: remove this class once it's fixed +// TODO: remove this class and the polyline one once it's fixed +// and use bbox directly template struct ConstructBoundingBox_impl> { @@ -49,12 +50,17 @@ struct ConstructBoundingBox_impl> CGAL::Bbox_2 operator()(const X_monotone_curve_2& curve) + { + return this->operator()(curve.source(), curve.target()); + } + + CGAL::Bbox_2 operator()(const Point_2& p1, const Point_2& p2) { CGAL::Bbox_2 bbox; - double x1 = CGAL::to_double(curve.source().x()); - double y1 = CGAL::to_double(curve.source().y()); - double x2 = CGAL::to_double(curve.target().x()); - double y2 = CGAL::to_double(curve.target().y()); + double x1 = CGAL::to_double(p1.x()); + double y1 = CGAL::to_double(p1.y()); + double x2 = CGAL::to_double(p2.x()); + double y2 = CGAL::to_double(p2.y()); double min_x, max_x, min_y, max_y; if (x1 < x2) @@ -89,14 +95,11 @@ struct ConstructBoundingBox_impl> } }; -template < - typename RatKernel_, typename AlgKernel_, typename NtTraits_, - typename BoundingTraits_> -struct ConstructBoundingBox_impl> +template +struct ConstructBoundingBox_impl> { - using Traits = typename CGAL::Arr_Bezier_curve_traits_2< - RatKernel_, AlgKernel_, NtTraits_, BoundingTraits_>; + using Traits = CGAL::Arr_polyline_traits_2; + using SegmentTraits_2 = SegmentTraits_2_; using X_monotone_curve_2 = typename Traits::X_monotone_curve_2; using Curve_2 = typename Traits::Curve_2; using Point_2 = typename Traits::Point_2; @@ -104,16 +107,54 @@ struct ConstructBoundingBox_impl construct_bounding_box; + + auto n = curve.number_of_subcurves(); + CGAL::Bbox_2 bbox; + for (std::size_t i = 0; i < n; ++i) + bbox += construct_bounding_box(curve[i]); + + return bbox; + } + + CGAL::Bbox_2 operator()(const Point_2& p1, const Point_2& p2) + { + CGAL::Bbox_2 bbox; + double x1 = CGAL::to_double(p1.x()); + double y1 = CGAL::to_double(p1.y()); + double x2 = CGAL::to_double(p2.x()); + double y2 = CGAL::to_double(p2.y()); + + double min_x, max_x, min_y, max_y; + if (x1 < x2) + { + min_x = x1; + max_x = x2; + } + else + { + min_x = x2; + max_x = x1; + } + if (y1 < y2) + { + min_y = y1; + max_y = y2; + } + else + { + min_y = y2; + max_y = y1; + } + return {min_x, min_y, max_x, max_y}; } CGAL::Bbox_2 operator()(const Point_2& point) { - std::pair p = point.approximate(); - return {p.first, p.second, p.first, p.second}; + double x = CGAL::to_double(point.x()); + double y = CGAL::to_double(point.y()); + return {x, y, x, y}; } }; @@ -130,7 +171,8 @@ struct ConstructBoundingBox_impl> { if (curve.is_segment()) { - return curve.bbox(); + return ConstructBoundingBox_impl>{}( + curve.source(), curve.target()); } else if (curve.is_line()) { @@ -166,6 +208,35 @@ struct ConstructBoundingBox_impl> } }; + +template < + typename RatKernel_, typename AlgKernel_, typename NtTraits_, + typename BoundingTraits_> +struct ConstructBoundingBox_impl> +{ + using Traits = typename CGAL::Arr_Bezier_curve_traits_2< + RatKernel_, AlgKernel_, NtTraits_, BoundingTraits_>; + using X_monotone_curve_2 = typename Traits::X_monotone_curve_2; + using Curve_2 = typename Traits::Curve_2; + using Point_2 = typename Traits::Point_2; + + CGAL::Bbox_2 + operator()(const X_monotone_curve_2& curve) + { + // TODO: find a way to find bounding box of a X_monotone_curve of bezier + // arrangements + return curve.supporting_curve().bbox(); + } + + CGAL::Bbox_2 + operator()(const Point_2& point) + { + std::pair p = point.approximate(); + return {p.first, p.second, p.first, p.second}; + } +}; + template struct ConstructBoundingBox_impl< CGAL::Arr_rational_function_traits_2>