From e7bc51e4c5c07389c1d028e7a42c238688ca43ee Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Mon, 25 Oct 2021 12:47:39 +0200 Subject: QtLocation: adapt to build with external QtPositioning This includes fixing some includes to use the full path to QtPositioing/private/header_name_p.h and also fixes related to the reworked clipper wrapper. Task-number: QTBUG-97084 Change-Id: I15ce8d739beb2f190df9f5af01a7cb1642a6b2a2 Reviewed-by: Alex Blasche --- .../qdeclarativepolylinemapitem.cpp | 27 ++++------------------ 1 file changed, 4 insertions(+), 23 deletions(-) (limited to 'src/location/declarativemaps/qdeclarativepolylinemapitem.cpp') diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp index 9d5472ab..88ebef25 100644 --- a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp +++ b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp @@ -38,11 +38,11 @@ #include "qdeclarativepolylinemapitem_p_p.h" #include "qdeclarativerectanglemapitem_p_p.h" #include "qdeclarativecirclemapitem_p_p.h" -#include "qlocationutils_p.h" +#include #include "qdeclarativegeomapitemutils_p.h" #include "error_messages_p.h" #include "locationvaluetypehelper_p.h" -#include "qdoublevector2d_p.h" +#include #include #include @@ -87,18 +87,6 @@ struct ThreadPool // to have a thread pool with max 1 thread for geometry proces Q_GLOBAL_STATIC(ThreadPool, threadPool) -static const double kClipperScaleFactor = 281474976710656.0; // 48 bits of precision - -static inline IntPoint toIntPoint(const double x, const double y) -{ - return IntPoint(cInt(x * kClipperScaleFactor), cInt(y * kClipperScaleFactor)); -} - -static IntPoint toIntPoint(const QDoubleVector2D &p) -{ - return toIntPoint(p.x(), p.y()); -} - static bool get_line_intersection(const double p0_x, const double p0_y, const double p1_x, @@ -161,13 +149,6 @@ static QList > clipLine( edges.push_back({ { poly.at(i-1).x(), poly.at(i-1).y(), poly.at(i).x(), poly.at(i).y() } }); edges.push_back({ { poly.at(poly.size()-1).x(), poly.at(poly.size()-1).y(), poly.at(0).x(), poly.at(0).y() } }); - // Build Path to check for containment, for edges not intersecting - // This step could be speeded up by forcing the orientation of the polygon, and testing the cross products in the step - // below, thus avoiding to resort to clipper. - Path clip; - for (const auto &v: poly) - clip.push_back(toIntPoint(v)); - // Step 2: check each segment against each edge QList subLine; std::array intersections = { { 0.0, 0.0, 0.0, 0.0 } }; @@ -178,8 +159,8 @@ static QList > clipLine( double previousT = t; double i_x, i_y; - const int firstContained = c2t::clip2tri::pointInPolygon(toIntPoint(l.at(i).x(), l.at(i).y()), clip); - const int secondContained = c2t::clip2tri::pointInPolygon(toIntPoint(l.at(i+1).x(), l.at(i+1).y()), clip); + const int firstContained = QClipperUtils::pointInPolygon(l.at(i), poly); + const int secondContained = QClipperUtils::pointInPolygon(l.at(i+1), poly); if (firstContained && secondContained) { // Second most common condition, test early and skip inner loop if possible if (!subLine.size()) -- cgit v1.2.1