qHexWalker 0.0.1
Hexagonal Grid Pathfinding & Maze Visualization on Interactive Maps
Loading...
Searching...
No Matches
h3Worker.h
Go to the documentation of this file.
1
12#ifndef Q_HEX_WALKER_H3WORKER_H
13#define Q_HEX_WALKER_H3WORKER_H
14
15#include "astar.h"
16
21namespace H3_VIEWER {
22
54class H3Worker final : public QObject {
55 Q_OBJECT
56 Q_DISABLE_COPY_MOVE(H3Worker)
57
58public:
63 explicit H3Worker(QObject *parent = nullptr);
64
68 ~H3Worker() override;
69
75 std::vector<H3Index> indexes;
76 bool has{};
77 };
78
79public slots:
86 void doWork();
87
96 void requestCell(const std::vector<H3Index> &index);
97
103 void setWalls(const std::unordered_set<H3Index> &mazeWalls);
104
105private slots:
113 void onAStarNewCell(H3Index cell);
114
115signals:
119 void finished();
120
129 void cellComputed(quint8 res, H3Index id, const QVariantList &polygon, bool isSearching);
130
135 void cellsComputed(const QVariantList &polygon);
136
144 void mazePolygonsComputed(const std::vector<QVariantList> &polygons);
145
153 void searchStats(int exploredCells, double timeMs, int pathLength);
154
160 void pathCellsBatch(const std::vector<std::tuple<quint8, H3Index, QVariantList>> &cells);
161
162private:
164 std::unordered_set<H3Index> walls;
165
168
170 std::atomic_bool isRequested{false};
171
173 std::mutex mutex_;
174
176 std::condition_variable cv_;
177
180
182 std::atomic<int> exploredCellsCount_{0};
183};
184
185} // namespace H3_VIEWER
186
187#endif // Q_HEX_WALKER_H3WORKER_H
Bidirectional A* pathfinding algorithm for H3 hexagonal grids.
Bidirectional A* pathfinding algorithm for H3 hexagonal cells.
Definition astar.h:45
Worker thread for asynchronous H3 operations.
Definition h3Worker.h:54
std::condition_variable cv_
Condition variable for efficient waiting.
Definition h3Worker.h:176
void cellsComputed(const QVariantList &polygon)
Emitted when batch cell computation completes.
void mazePolygonsComputed(const std::vector< QVariantList > &polygons)
Emitted with merged maze wall polygons for rendering.
void requestCell(const std::vector< H3Index > &index)
Requests computation for a set of H3 cells.
Definition h3Worker.cpp:79
std::atomic< int > exploredCellsCount_
Counter for explored cells during current search.
Definition h3Worker.h:182
void onAStarNewCell(H3Index cell)
Handles cell exploration events from A* algorithm.
Definition h3Worker.cpp:104
H3AStar * astar_
A* pathfinding algorithm instance.
Definition h3Worker.h:167
void searchStats(int exploredCells, double timeMs, int pathLength)
Emitted with pathfinding statistics after search completes.
void cellComputed(quint8 res, H3Index id, const QVariantList &polygon, bool isSearching)
Emitted when a single cell computation completes.
std::atomic_bool isRequested
Flag indicating a request is pending.
Definition h3Worker.h:170
void setWalls(const std::unordered_set< H3Index > &mazeWalls)
Sets maze walls for pathfinding obstacle avoidance.
Definition h3Worker.cpp:93
~H3Worker() override
Destructor.
bool has
Flag indicating pending request.
Definition h3Worker.h:76
void doWork()
Main work loop executed in the worker thread.
Definition h3Worker.cpp:17
std::unordered_set< H3Index > walls
Maze wall cells for obstacle avoidance.
Definition h3Worker.h:164
PendingRequest pending_
Currently pending request.
Definition h3Worker.h:179
std::mutex mutex_
Mutex for thread synchronization.
Definition h3Worker.h:173
std::vector< H3Index > indexes
Cell indices to process.
Definition h3Worker.h:75
void pathCellsBatch(const std::vector< std::tuple< quint8, H3Index, QVariantList > > &cells)
Emitted with batch of path cells for efficient rendering.
Structure holding queued cell computation requests.
Definition h3Worker.h:74
Namespace containing H3 visualization components.
Definition h3Model.h:20