![]() |
Prusa Slicer 2.6.0
|
#include <src/libslic3r/Arachne/utils/SquareGrid.hpp>
Inheritance diagram for Slic3r::Arachne::SquareGrid:Public Types | |
| using | GridPoint = Point |
| using | grid_coord_t = coord_t |
Public Member Functions | |
| SquareGrid (const coord_t cell_size) | |
| Constructs a grid with the specified cell size. | |
| coord_t | getCellSize () const |
| bool | processLineCells (const std::pair< Point, Point > line, const std::function< bool(GridPoint)> &process_cell_func) |
Process cells along a line indicated by line. | |
| bool | processLineCells (const std::pair< Point, Point > line, const std::function< bool(GridPoint)> &process_cell_func) const |
Process cells along a line indicated by line. | |
| bool | processNearby (const Point &query_pt, coord_t radius, const std::function< bool(const GridPoint &)> &process_func) const |
| Process cells that might contain sought after points. | |
| GridPoint | toGridPoint (const Vec2i64 &point) const |
| Compute the grid coordinates of a point. | |
| grid_coord_t | toGridCoord (const int64_t &coord) const |
| Compute the grid coordinate of a real space coordinate. | |
| coord_t | toLowerCoord (const grid_coord_t &grid_coord) const |
| Compute the lowest coord in a grid cell. The lowest point is the point in the grid cell closest to the origin. | |
Protected Member Functions | |
| grid_coord_t | nonzeroSign (grid_coord_t z) const |
Protected Attributes | |
| coord_t | cell_size |
| The cell (square) size. | |
Helper class to calculate coordinates on a square grid, and providing some utility functions to process grids.
Doesn't contain any data, except cell size. The purpose is only to automatically generate coordinates on a grid, and automatically feed them to functions. The grid is theoretically infinite (bar integer limits).
| coord_t SquareGrid::getCellSize | ( | ) | const |
|
protected |
Compute the sign of a number.
The number 0 will result in a positive sign (1).
| z | The number to find the sign of. |
Referenced by processLineCells().
Here is the caller graph for this function:| bool SquareGrid::processLineCells | ( | const std::pair< Point, Point > | line, |
| const std::function< bool(GridPoint)> & | process_cell_func | ||
| ) |
Process cells along a line indicated by line.
| line | The line along which to process cells. |
| process_func | Processes each cell. process_func(elem) is called for each cell. Processing stops if function returns false. |
References processLineCells().
Referenced by Slic3r::Arachne::SparseLineGrid< ElemT, Locator >::insert(), and processLineCells().
Here is the call graph for this function:
Here is the caller graph for this function:| bool SquareGrid::processLineCells | ( | const std::pair< Point, Point > | line, |
| const std::function< bool(GridPoint)> & | process_cell_func | ||
| ) | const |
Process cells along a line indicated by line.
| line | The line along which to process cells |
| process_func | Processes each cell. process_func(elem) is called for each cell. Processing stops if function returns false. |
References Slic3r::area(), nonzeroSign(), toGridCoord(), toGridPoint(), and toLowerCoord().
Here is the call graph for this function:| bool SquareGrid::processNearby | ( | const Point & | query_pt, |
| coord_t | radius, | ||
| const std::function< bool(const GridPoint &)> & | process_func | ||
| ) | const |
Process cells that might contain sought after points.
Processes cells that might be within a square with twice radius as width, centered around query_pt. May process elements that are up to radius + cell_size from query_pt.
| query_pt | The point to search around. |
| radius | The search radius. |
| process_func | Processes each cell. process_func(loc) is called for each cell coord within range. Processing stops if function returns false. |
References toGridPoint().
Referenced by Slic3r::Arachne::SparseGrid< ElemT >::processNearby().
Here is the call graph for this function:
Here is the caller graph for this function:| SquareGrid::grid_coord_t SquareGrid::toGridCoord | ( | const int64_t & | coord | ) | const |
Compute the grid coordinate of a real space coordinate.
| coord | The actual location. |
coord. References cell_size.
Referenced by processLineCells(), and toGridPoint().
Here is the caller graph for this function:| SquareGrid::GridPoint SquareGrid::toGridPoint | ( | const Vec2i64 & | point | ) | const |
Compute the grid coordinates of a point.
| point | The actual location. |
point. References toGridCoord().
Referenced by Slic3r::Arachne::SparsePointGrid< ElemT, Locator >::insert(), processLineCells(), and processNearby().
Here is the call graph for this function:
Here is the caller graph for this function:| coord_t SquareGrid::toLowerCoord | ( | const grid_coord_t & | grid_coord | ) | const |
Compute the lowest coord in a grid cell. The lowest point is the point in the grid cell closest to the origin.
| grid_coord | The grid coordinate. |
grid_coord. References cell_size.
Referenced by processLineCells().
Here is the caller graph for this function:
|
protected |
The cell (square) size.
Referenced by SquareGrid(), getCellSize(), toGridCoord(), and toLowerCoord().