#pragma once #include #include #include #include #include #include #include "GeoPolygonArray.h" #include "PolygonArray.h" typedef QList QVariantList; typedef struct Result{ QVector waypoints; GeoPolygonArray tiles; PolygonArray tilesLocal; QVariantList tileCenterPoints; QGeoCoordinate origin; QVector arrivalPathIdx; QVector returnPathIdx; bool success; QString errorMessage; void clear(); }WorkerResult_t; class SnakeWorker : public QThread{ Q_OBJECT public: SnakeWorker(QObject *parent = nullptr); ~SnakeWorker() override; template class Container> void setMeasurementArea (const Container &measurementArea); template class Container> void setServiceArea (const Container &serviceArea); template class Container> void setCorridor (const Container &corridor); template class Container, class IntType> void setProgress (const Container &progress); WorkerResult_t &result(); double lineDistance() const; void setLineDistance(double lineDistance); double minTransectLength() const; void setMinTransectLength(double minTransectLength); double minTileArea() const; void setMinTileArea(double minTileArea); double tileHeight() const; void setTileHeight(double tileHeight); double tileWidth() const; void setTileWidth(double tileWidth); protected: void run() override; private: bool precondition() const; std::vector _mArea; std::vector _sArea; std::vector _corridor; std::vector _progress; double _lineDistance; double _minTransectLength; double _tileWidth; double _tileHeight; double _minTileArea; WorkerResult_t _result; }; template class Container> void SnakeWorker::setCorridor(const Container &corridor) { _corridor.clear(); for (auto vertex : corridor) { _corridor.push_back(vertex); } } template class Container> void SnakeWorker::setMeasurementArea(const Container &measurementArea) { _mArea.clear(); for (auto vertex : measurementArea) { _mArea.push_back(vertex); } } template class Container> void SnakeWorker::setServiceArea(const Container &serviceArea) { _sArea.clear(); for (auto vertex : serviceArea) { _sArea.push_back(vertex); } } template class Container, class IntType> void SnakeWorker::setProgress(const Container &progress) { _progress.clear(); for (auto p : progress) { assert(p >= -1 && p <= 100); _progress.push_back(p); } }