|
qHexWalker 0.0.1
Hexagonal Grid Pathfinding & Maze Visualization on Interactive Maps
|
Worker thread for asynchronous H3 operations. More...
#include <h3Worker.h>
Inheritance diagram for H3_VIEWER::H3Worker:
Collaboration diagram for H3_VIEWER::H3Worker:Classes | |
| struct | PendingRequest |
| Structure holding queued cell computation requests. More... | |
Public Member Functions | |
| H3Worker (QObject *parent=nullptr) | |
| Constructs an H3Worker. | |
| ~H3Worker () override | |
| Destructor. | |
| void | doWork () |
| Main work loop executed in the worker thread. | |
| void | requestCell (const std::vector< H3Index > &index) |
| Requests computation for a set of H3 cells. | |
| void | setWalls (const std::unordered_set< H3Index > &mazeWalls) |
| Sets maze walls for pathfinding obstacle avoidance. | |
| void | cellComputed (quint8 res, H3Index id, const QVariantList &polygon, bool isSearching) |
| Emitted when a single cell computation completes. | |
| 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 | searchStats (int exploredCells, double timeMs, int pathLength) |
| Emitted with pathfinding statistics after search completes. | |
| void | pathCellsBatch (const std::vector< std::tuple< quint8, H3Index, QVariantList > > &cells) |
| Emitted with batch of path cells for efficient rendering. | |
Public Attributes | |
| : void finished() | |
Private Member Functions | |
| void | onAStarNewCell (H3Index cell) |
| Handles cell exploration events from A* algorithm. | |
Private Attributes | |
| std::unordered_set< H3Index > | walls |
| Maze wall cells for obstacle avoidance. | |
| H3AStar * | astar_ {} |
| A* pathfinding algorithm instance. | |
| std::atomic_bool | isRequested {false} |
| Flag indicating a request is pending. | |
| std::mutex | mutex_ |
| Mutex for thread synchronization. | |
| std::condition_variable | cv_ |
| Condition variable for efficient waiting. | |
| PendingRequest | pending_ |
| Currently pending request. | |
| std::atomic< int > | exploredCellsCount_ {0} |
| Counter for explored cells during current search. | |
Worker thread for asynchronous H3 operations.
H3Worker handles CPU-intensive operations in a background thread:
Definition at line 54 of file h3Worker.h.
| struct H3_VIEWER::H3Worker::PendingRequest |
Structure holding queued cell computation requests.
Definition at line 74 of file h3Worker.h.
Collaboration diagram for H3_VIEWER::H3Worker::PendingRequest:| Class Members | ||
|---|---|---|
| bool | has {} | Flag indicating pending request. |
| vector< H3Index > | indexes | Cell indices to process. |
|
explicit |
Constructs an H3Worker.
| parent | Optional parent QObject. |
Definition at line 8 of file h3Worker.cpp.
References astar_, and onAStarNewCell().
Here is the call graph for this function:
|
overridedefault |
Destructor.
| void H3_VIEWER::H3Worker::cellComputed | ( | quint8 | res, |
| H3Index | id, | ||
| const QVariantList & | polygon, | ||
| bool | isSearching | ||
| ) |
Emitted when a single cell computation completes.
| res | Cell resolution (3-15). |
| id | H3 cell index. |
| polygon | Cell boundary polygon coordinates. |
| isSearching | true if emitted during active pathfinding. |
Referenced by doWork(), H3Model::Init(), and onAStarNewCell().
Here is the caller graph for this function:| void H3_VIEWER::H3Worker::cellsComputed | ( | const QVariantList & | polygon | ) |
Emitted when batch cell computation completes.
| polygon | List of computed polygon data. |
Referenced by H3Model::Init().
Here is the caller graph for this function:| void H3Worker::doWork | ( | ) |
Main work loop executed in the worker thread.
Continuously processes pending requests and performs pathfinding. Uses condition variable to wait efficiently when no work is available.
Definition at line 17 of file h3Worker.cpp.
References astar_, cellComputed(), cv_, exploredCellsCount_, H3AStar::findShortestPath(), H3_VIEWER::H3Worker::PendingRequest::has, H3_VIEWER::H3Worker::PendingRequest::indexes, H3_VIEWER::Helper::indexToPolygon(), isRequested, mutex_, pending_, and searchStats().
Referenced by H3Model::Init().
Here is the call graph for this function:
Here is the caller graph for this function:| void H3_VIEWER::H3Worker::mazePolygonsComputed | ( | const std::vector< QVariantList > & | polygons | ) |
Emitted with merged maze wall polygons for rendering.
Polygons are pre-merged for efficient map rendering.
| polygons | Vector of polygon coordinate lists. |
Referenced by H3Model::Init().
Here is the caller graph for this function:
|
private |
Handles cell exploration events from A* algorithm.
Called during pathfinding to enable real-time visualization.
| cell | The H3 index of the newly explored cell. |
Definition at line 104 of file h3Worker.cpp.
References cellComputed(), exploredCellsCount_, and H3_VIEWER::Helper::indexToPolygon().
Referenced by H3Worker().
Here is the call graph for this function:
Here is the caller graph for this function:| void H3_VIEWER::H3Worker::pathCellsBatch | ( | const std::vector< std::tuple< quint8, H3Index, QVariantList > > & | cells | ) |
Emitted with batch of path cells for efficient rendering.
| cells | Vector of cell data tuples (resolution, index, polygon). |
| void H3Worker::requestCell | ( | const std::vector< H3Index > & | index | ) |
Requests computation for a set of H3 cells.
Queues cells for polygon computation and pathfinding. Thread-safe - can be called from any thread.
| index | Vector of H3 cell indices to process. |
Definition at line 79 of file h3Worker.cpp.
References cv_, H3_VIEWER::H3Worker::PendingRequest::has, H3_VIEWER::H3Worker::PendingRequest::indexes, isRequested, mutex_, and pending_.
Referenced by H3Model::requestCells().
Here is the caller graph for this function:| void H3_VIEWER::H3Worker::searchStats | ( | int | exploredCells, |
| double | timeMs, | ||
| int | pathLength | ||
| ) |
Emitted with pathfinding statistics after search completes.
| exploredCells | Number of cells explored during search. |
| timeMs | Search duration in milliseconds. |
| pathLength | Number of cells in the found path. |
Referenced by doWork(), and H3Model::Init().
Here is the caller graph for this function:| void H3Worker::setWalls | ( | const std::unordered_set< H3Index > & | mazeWalls | ) |
Sets maze walls for pathfinding obstacle avoidance.
| mazeWalls | Set of H3 cell indices representing walls. |
Definition at line 93 of file h3Worker.cpp.
References astar_, mutex_, H3AStar::setBlockedCells(), and walls.
Referenced by H3Model::Init().
Here is the call graph for this function:
Here is the caller graph for this function:| H3_VIEWER::H3Worker::__pad0__ |
Definition at line 113 of file h3Worker.h.
|
private |
A* pathfinding algorithm instance.
Definition at line 167 of file h3Worker.h.
Referenced by H3Worker(), doWork(), and setWalls().
|
private |
Condition variable for efficient waiting.
Definition at line 176 of file h3Worker.h.
Referenced by doWork(), and requestCell().
|
private |
Counter for explored cells during current search.
Definition at line 182 of file h3Worker.h.
Referenced by doWork(), and onAStarNewCell().
|
private |
Flag indicating a request is pending.
Definition at line 170 of file h3Worker.h.
Referenced by doWork(), and requestCell().
|
private |
Mutex for thread synchronization.
Definition at line 173 of file h3Worker.h.
Referenced by doWork(), requestCell(), and setWalls().
|
private |
Currently pending request.
Definition at line 179 of file h3Worker.h.
Referenced by doWork(), and requestCell().
|
private |
Maze wall cells for obstacle avoidance.
Definition at line 164 of file h3Worker.h.
Referenced by setWalls().