|
1 | 1 | #ifndef WARTHOG_DOMAIN_ROTATE_GRIDMAP_H |
2 | 2 | #define WARTHOG_DOMAIN_ROTATE_GRIDMAP_H |
3 | 3 |
|
4 | | -// domain::gridmap.h |
5 | 4 | // |
6 | | -// A uniform cost domain::gridmap implementation. The map is stored in |
7 | | -// a compact matrix form. Nodes are represented as single bit quantities. |
| 5 | +// jps/domain/rotate_gridmap.h |
| 6 | +// |
| 7 | +// An extended domain of gridmap that uses 2 gridmaps, one rotated |
| 8 | +// for use in JPS block-based jump-point location. |
| 9 | +// |
| 10 | +// Class rotate_gridmap is the main implementation. |
| 11 | +// It supports pointing to a user-supplied gridmap and rotated gridmap, |
| 12 | +// or just a user provided gridmap, which it would generate and own the |
| 13 | +// rotated gridmap. |
| 14 | +// |
| 15 | +// Small copyable storage of these maps are provided in utility structs: |
| 16 | +// gridmap_rotate_ptr, gridmap_rotate_ptr_convs: 2 pointers to gridmap, |
| 17 | +// accessing the grid would require 2-level of indirects (gridmap->data[i]) |
| 18 | +// gridmap_rotate_table, gridmap_rotate_table_convs: 2 gridmap::bitarray, |
| 19 | +// accessing the grid is only a single redirect |
| 20 | +// Use of these datatypes do not copy the tables themselves, and are quite |
| 21 | +// compact. The non _convs variants should be 2-pointer sized (16-bytes). The |
| 22 | +// _convs variants are supplied with width and height, allowing for x/y and |
| 23 | +// grid_id and rgrid_id conversions between the two grid (24-bytes). |
| 24 | +// |
| 25 | +// @author Ryan Hechenberger |
| 26 | +// @created 2025-11-20 |
8 | 27 | // |
9 | 28 |
|
10 | 29 | #include <array> |
@@ -385,7 +404,8 @@ struct gridmap_rotate_ptr : std::array<domain::gridmap*, 2> |
385 | 404 | } |
386 | 405 | operator bool() const noexcept { return (*this)[0]; } |
387 | 406 | }; |
388 | | -/// @brief a copy-by-value class pointing to grid/rgrid with conversions |
| 407 | +/// @brief a copy-by-value class pointing to grid/rgrid with id conversions |
| 408 | +/// functions |
389 | 409 | struct gridmap_rotate_ptr_convs : gridmap_rotate_ptr, |
390 | 410 | rgridmap_point_conversions |
391 | 411 | { |
@@ -429,7 +449,8 @@ struct gridmap_rotate_table : std::array<domain::gridmap::bitarray, 2> |
429 | 449 | } |
430 | 450 | operator bool() const noexcept { return (*this)[0].data(); } |
431 | 451 | }; |
432 | | -/// @brief a copy-by-value class for fast access to grid/rgrid with conversions |
| 452 | +/// @brief a copy-by-value class for fast access to grid/rgrid with id |
| 453 | +/// conversions functions |
433 | 454 | struct gridmap_rotate_table_convs : gridmap_rotate_table, |
434 | 455 | rgridmap_point_conversions |
435 | 456 | { |
@@ -462,6 +483,14 @@ struct gridmap_rotate_table_convs : gridmap_rotate_table, |
462 | 483 | } |
463 | 484 | }; |
464 | 485 |
|
| 486 | +/// The main rotate gridmap class. |
| 487 | +/// Stores a pointer to a gridmap and rotated gridmap. |
| 488 | +/// The rotated gridmap memory may be created and owned by this class, or |
| 489 | +/// provided and controlled by the user. |
| 490 | +/// |
| 491 | +/// Supports static_cast operations for all gridmap_rotate_(ptr|table)(_conv)?. |
| 492 | +/// They will act as valid small pointer classes (16-24 bytes) with various |
| 493 | +/// levels if indirection to the grid data. |
465 | 494 | class rotate_gridmap : public rgridmap_point_conversions |
466 | 495 | { |
467 | 496 | private: |
@@ -589,6 +618,12 @@ class rotate_gridmap : public rgridmap_point_conversions |
589 | 618 | return gridmap_rotate_table_convs( |
590 | 619 | *this, static_cast<rgridmap_point_conversions>(*this)); |
591 | 620 | } |
| 621 | + |
| 622 | + size_t |
| 623 | + mem() const noexcept |
| 624 | + { |
| 625 | + return rmap_obj != nullptr ? rmap_obj->mem() : 0; |
| 626 | + } |
592 | 627 | }; |
593 | 628 |
|
594 | 629 | } // namespace warthog::grid |
|
0 commit comments