92 #define PTK_GRID_OK ((uint32_t)0) 99 #define PTK_GRID_CELL_INVALID ((uint32_t)-1) 106 #define PTK_GRID_CONFIG_TYPE_INVALID ((uint32_t)-2) 113 #define PTK_GRID_CELL_COUNT_INVALID ((uint32_t)-3) 334 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
340 float *f32 = (
float *)((uint8_t*)og + og->
dataOffset);
346 uint8_t *user = (uint8_t *)og + og->
dataOffset;
412 if(src->config.type != dst->config.type)
417 if(src->dataCellCount != dst->dataCellCount)
422 switch(src->config.type)
427 size =
sizeof(uint32_t);
430 size =
sizeof(float);
433 size = src->config.dataSize;
437 srcUser = (uint8_t *)src + src->dataOffset;
438 dstUser = (uint8_t *)dst + dst->dataOffset;
440 memcpy(dstUser, srcUser, size * src->dataCellCount);
445 static inline uint32_t
computeCell(
float c,
float min,
float invsize, uint32_t count)
451 cell = (uint32_t) ((c - min) * invsize);
638 if (cell < og->dataCellCount)
640 float *f32 = (
float *)((uint8_t*)og + og->
dataOffset);
662 if (cell < og->dataCellCount)
664 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
686 if (cell < og->dataCellCount)
688 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
710 if (cell < og->dataCellCount)
712 float *f32 = (
float *)((uint8_t*)og + og->
dataOffset);
736 if (cell < og->dataCellCount)
738 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
742 return (uint32_t) -1;
762 if (cell < og->dataCellCount)
764 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
790 if (cell < og->dataCellCount)
792 float *f32 = (
float *)((uint8_t*)og + og->
dataOffset);
816 if (cell < og->dataCellCount)
818 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
842 if (cell < og->dataCellCount)
844 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
868 if (cell < og->dataCellCount)
870 float *f32 = (
float *)((uint8_t*)og + og->
dataOffset);
896 if (cell < og->dataCellCount)
898 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
902 return (uint32_t) -1;
924 if (cell < og->dataCellCount)
926 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
955 if (cell < og->dataCellCount)
957 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
958 return (ui32[cell] & bits) > 0;
988 if (cell < og->dataCellCount)
990 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
991 return (ui32[cell] & bits) > 0;
1019 if (cell < og->dataCellCount)
1021 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
1022 return (ui32[cell] & bits) == bits;
1052 if (cell < og->dataCellCount)
1054 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
1055 return (ui32[cell] & bits) == bits;
1082 if (cell < og->dataCellCount)
1084 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
1085 ui32[cell] &= ~bits;
1112 if (cell < og->dataCellCount)
1114 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
1115 ui32[cell] &= ~bits;
1140 if (cell < og->dataCellCount)
1142 float *f32 = (
float *)((uint8_t*)og + og->
dataOffset);
1172 if (cell < og->dataCellCount)
1174 float *f32 = (
float *)((uint8_t*)og + og->
dataOffset);
1202 if (cell < og->dataCellCount)
1204 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
1234 if (cell < og->dataCellCount)
1236 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
1264 if (cell < og->dataCellCount)
1266 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
1296 if (cell < og->dataCellCount)
1298 uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->
dataOffset);
1326 if (cell < og->dataCellCount)
1328 uint8_t *user = (uint8_t *)og + og->
dataOffset;
1358 if (cell < og->dataCellCount)
1360 uint8_t *user = (uint8_t *)og + og->
dataOffset;
static void PTK_Grid_setf2d(PTK_Grid *og, uint32_t x, uint32_t y, float value)
Sets the data of type PTK_GRID_TYPE_FLOAT in the specified cell.
Definition: grid.h:634
static void PTK_Grid_setu3d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z, uint32_t value)
Sets the data of type PTK_GRID_TYPE_UINT32 in the specified cell.
Definition: grid.h:812
PTK_GridConfig config
Definition: grid.h:236
static uint32_t PTK_Grid_copy(PTK_Grid *__restrict dst, const PTK_Grid *__restrict src)
Copy data from the given source PTK Grid to the destination PTK_Grid. The two must have the same conf...
Definition: grid.h:406
static void PTK_Grid_clearb2d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t bits)
This removes the specified flags from the specified cell. Any flags not mentioned in flags are left...
Definition: grid.h:1078
static uint32_t PTK_Grid_userClear(PTK_Grid *og, void *def)
This clears a PTK Grid that is storing user data, resetting it to the default data supplied...
Definition: grid.h:371
static uint32_t PTK_Grid_allb2d(const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t bits)
Test if all of the flags set for the specified cell match all of the given flags. Returns 0 if any of...
Definition: grid.h:1015
static uint32_t PTK_Grid_getb2d(const PTK_Grid *og, uint32_t x, uint32_t y)
Returns the data of type PTK_GRID_TYPE_BITS in the specified cell.
Definition: grid.h:758
static uint32_t PTK_Grid_getLinearIndex3d(const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
This is a mostly-internal function that is used for converting a triple of integer cell indices into ...
Definition: grid.h:565
Grid configuration.
Definition: grid.h:162
float yDir
Definition: grid.h:286
static void PTK_Grid_setb3d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z, uint32_t bits)
Sets the data of type PTK_GRID_TYPE_BITS in the specified cell.
Definition: grid.h:838
static void PTK_Grid_setf3d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z, float value)
Sets the data of type PTK_GRID_TYPE_FLOAT in the specified cell.
Definition: grid.h:786
float zInvCellSize
Definition: grid.h:245
float yOffset
Definition: grid.h:274
float xMin
Definition: grid.h:190
static float PTK_Grid_getf2d(const PTK_Grid *og, uint32_t x, uint32_t y)
Returns the data of type PTK_GRID_TYPE_FLOAT in the specified cell.
Definition: grid.h:706
Defines a rectangle in a target coordinate system. In local coordinate system, the vertices are (0|0)...
Definition: grid.h:268
static float PTK_Grid_getX(const PTK_Grid *og, uint32_t x)
Definition: grid.h:582
static uint32_t computeCell(float c, float min, float invsize, uint32_t count)
Definition: grid.h:445
static uint32_t * PTK_Grid_refb3d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
Returns a reference to the data of type PTK_GRID_TYPE_BITS in the specified cell. ...
Definition: grid.h:1292
float zCellSize
Definition: grid.h:187
static uint32_t PTK_Grid_getu3d(const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
Returns the data of type PTK_GRID_TYPE_UINT32 in the specified cell.
Definition: grid.h:892
static uint32_t PTK_Grid_anyb2d(const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t bits)
Tests if the flags set for the specified cell contain any of the given flags values. Returns 1 if any of the flags match.
Definition: grid.h:951
float yCellSize
Definition: grid.h:182
static uint32_t * PTK_Grid_refu3d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
Returns a reference to the data of type PTK_GRID_TYPE_UINT32 in the specified cell.
Definition: grid.h:1230
static float PTK_Grid_getf3d(const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
Returns the data of type PTK_GRID_TYPE_FLOAT in the specified cell.
Definition: grid.h:864
static float PTK_Grid_getY(const PTK_Grid *og, uint32_t y)
Definition: grid.h:599
PTK_Grid * PTK_Grid_init(uint8_t *mem, const PTK_GridConfig *config)
Initialize an externally allocated piece of memory to be a valid PTK Grid instance.
float xWidth
Definition: grid.h:277
uint32_t PTK_Grid_getSize(const PTK_GridConfig *config)
Compute how much memory is required to store the complete PTK Grid described by the given configurati...
static uint32_t PTK_Grid_getZCell(const PTK_Grid *og, float z)
This converts a real-valued z coordinate given in meters to an index for the grid access function...
Definition: grid.h:520
static void PTK_Grid_setb2d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t bits)
Sets the data of type PTK_GRID_TYPE_BITS in the specified cell.
Definition: grid.h:682
#define PTK_GRID_CONFIG_TYPE_INVALID
Type specidied in the Gird config is not what is expected.
Definition: grid.h:106
float yMin
Definition: grid.h:193
uint32_t xCells
Definition: grid.h:168
static uint32_t PTK_Grid_anyb3d(const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z, uint32_t bits)
Tests if the flags set for the specified cell contain any of the given flags values. Returns 1 if any of the flags match.
Definition: grid.h:984
static float * PTK_Grid_reff3d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
Returns a reference to the data of type PTK_GRID_TYPE_FLOAT in the specified cell.
Definition: grid.h:1168
#define PTK_GRID_CELL_INVALID
Invalid value used for any computed cell that does nto fit on the map.
Definition: grid.h:99
#define PTK_GRID_OK
Error codes.
Definition: grid.h:92
uint32_t dataCellCount
Definition: grid.h:248
static uint32_t PTK_Grid_allb3d(const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z, uint32_t bits)
Test if all of the flags set for the specified cell match all of the given flags. Returns 0 if any of...
Definition: grid.h:1048
static void PTK_Grid_setu2d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t value)
Sets the data of type PTK_GRID_TYPE_UINT32 in the specified cell.
Definition: grid.h:658
PTK_GridType
Grid data type definition.
Definition: grid.h:120
float yWidth
Definition: grid.h:280
float yInvCellSize
Definition: grid.h:242
static float PTK_Grid_getZ(const PTK_Grid *og, uint32_t z)
Definition: grid.h:616
static uint32_t * PTK_Grid_refb2d(PTK_Grid *og, uint32_t x, uint32_t y)
Returns a reference to the data of type PTK_GRID_TYPE_BITS in the specified cell. ...
Definition: grid.h:1260
static uint32_t PTK_Grid_getb3d(const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
Returns the data of type PTK_GRID_TYPE_BITS in the specified cell.
Definition: grid.h:920
static uint32_t * PTK_Grid_refu2d(PTK_Grid *og, uint32_t x, uint32_t y)
Returns a reference to the data of type PTK_GRID_TYPE_UINT32 in the specified cell.
Definition: grid.h:1198
static void PTK_Grid_clear(PTK_Grid *og)
This clears a PTK_Grid, resetting all cell contents back to 0, including user data types...
Definition: grid.h:326
static uint32_t PTK_Grid_getYCell(const PTK_Grid *og, float y)
This converts a real-valued y coordinate given in meters to an index for the grid access function...
Definition: grid.h:499
uint32_t dataSize
Definition: grid.h:203
static float * PTK_Grid_reff2d(PTK_Grid *og, uint32_t x, uint32_t y)
Returns a reference to the data of type PTK_GRID_TYPE_FLOAT in the specified cell.
Definition: grid.h:1136
float xCellSize
Definition: grid.h:179
#define PTK_GRID_CELL_COUNT_INVALID
Grid cell count invalid.
Definition: grid.h:113
float xDir
Definition: grid.h:283
float xOffset
Definition: grid.h:271
static uint32_t PTK_Grid_getu2d(const PTK_Grid *og, uint32_t x, uint32_t y)
Returns the data of type PTK_GRID_TYPE_UINT32 in the specified cell.
Definition: grid.h:732
static void * PTK_Grid_refv2d(PTK_Grid *og, uint32_t x, uint32_t y)
Returns a reference to the data of type PTK_GRID_TYPE_USER in the specified cell. ...
Definition: grid.h:1322
float zMin
Definition: grid.h:198
uint32_t yCells
Definition: grid.h:171
float xInvCellSize
Definition: grid.h:239
Grid definition.
Definition: grid.h:233
static uint32_t PTK_Grid_getLinearIndex2d(const PTK_Grid *og, uint32_t x, uint32_t y)
This is a mostly-internal function that is used for converting a pair of integer cell indices into a ...
Definition: grid.h:542
uint32_t zCells
Definition: grid.h:176
uint32_t dataOffset
Definition: grid.h:251
PTK_GridType type
Definition: grid.h:165
static void * PTK_Grid_refv3d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
Returns a reference to the data of type PTK_GRID_TYPE_USER in the specified cell. ...
Definition: grid.h:1354
PTK_GridMetaData metaData
Definition: grid.h:254
static void PTK_GridRoi_setDefault(PTK_GridRoi *roi)
Sets the default values for the ROI. The values are set as follows:
Definition: grid.h:1380
static uint32_t PTK_Grid_getXCell(const PTK_Grid *og, float x)
This converts a real-valued x coordinate given in meters to an index for the grid access function...
Definition: grid.h:478
static void PTK_Grid_clearb3d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z, uint32_t bits)
This removes the specified flags from the specified cell. Any flags not mentioned in flags are left...
Definition: grid.h:1108