Perception Tool Kit (PTK) API Guide
grid.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2018 Texas Instruments Incorporated
4  *
5  * All rights reserved not granted herein.
6  *
7  * Limited License.
8  *
9  * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
10  * license under copyrights and patents it now or hereafter owns or controls to make,
11  * have made, use, import, offer to sell and sell ("Utilize") this software subject to the
12  * terms herein. With respect to the foregoing patent license, such license is granted
13  * solely to the extent that any such patent is necessary to Utilize the software alone.
14  * The patent license shall not apply to any combinations which include this software,
15  * other than combinations with devices manufactured by or for TI ("TI Devices").
16  * No hardware patent is licensed hereunder.
17  *
18  * Redistributions must preserve existing copyright notices and reproduce this license
19  * (including the above copyright notice and the disclaimer and (if applicable) source
20  * code license limitations below) in the documentation and/or other materials provided
21  * with the distribution
22  *
23  * Redistribution and use in binary form, without modification, are permitted provided
24  * that the following conditions are met:
25  *
26  * * No reverse engineering, decompilation, or disassembly of this software is
27  * permitted with respect to any software provided in binary form.
28  *
29  * * any redistribution and use are licensed by TI for use only with TI Devices.
30  *
31  * * Nothing shall obligate TI to provide you with source code for the software
32  * licensed and provided to you in object code.
33  *
34  * If software source code is provided to you, modification and redistribution of the
35  * source code are permitted provided that the following conditions are met:
36  *
37  * * any redistribution and use of the source code, including any resulting derivative
38  * works, are licensed by TI for use only with TI Devices.
39  *
40  * * any redistribution and use of any object code compiled from the source code
41  * and any resulting derivative works, are licensed by TI for use only with TI Devices.
42  *
43  * Neither the name of Texas Instruments Incorporated nor the names of its suppliers
44  *
45  * may be used to endorse or promote products derived from this software without
46  * specific prior written permission.
47  *
48  * DISCLAIMER.
49  *
50  * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
51  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
52  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
53  * IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
54  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
55  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
56  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
57  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
58  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
59  * OF THE POSSIBILITY OF SUCH DAMAGE.
60  *
61  */
62 #pragma once
63 #ifndef PTK_GRID_H
64 #define PTK_GRID_H
65 
77 #include <stdint.h>
78 #include <stdlib.h>
79 #include <string.h>
80 #include <float.h>
81 
82 #ifdef __cplusplus
83 extern "C" {
84 #endif
85 
87 
92 #define PTK_GRID_OK ((uint32_t)0)
93 
99 #define PTK_GRID_CELL_INVALID ((uint32_t)-1)
100 
106 #define PTK_GRID_CONFIG_TYPE_INVALID ((uint32_t)-2)
107 
113 #define PTK_GRID_CELL_COUNT_INVALID ((uint32_t)-3)
114 
120 typedef enum
121 {
124 
127 
130 
133 
136 
137 } PTK_GridType;
138 
162 typedef struct
163 {
166 
168  uint32_t xCells;
169 
171  uint32_t yCells;
172 
176  uint32_t zCells;
177 
179  float xCellSize;
180 
182  float yCellSize;
183 
187  float zCellSize;
188 
190  float xMin;
191 
193  float yMin;
194 
198  float zMin;
199 
203  uint32_t dataSize;
204 
206 
212 typedef struct
213 {
215  uint32_t minUpdatedCellX;
216 
218  uint32_t minUpdatedCellY;
219 
221  uint32_t maxUpdatedCellX;
222 
224  uint32_t maxUpdatedCellY;
225 
227 
233 typedef struct
234 {
237 
240 
243 
246 
248  uint32_t dataCellCount;
249 
251  uint32_t dataOffset;
252 
255 
256 } PTK_Grid;
257 
268 typedef struct
269 {
271  float xOffset;
272 
274  float yOffset;
275 
277  float xWidth;
278 
280  float yWidth;
281 
283  float xDir;
284 
286  float yDir;
287 
288 } PTK_GridRoi;
289 
300 uint32_t PTK_Grid_getSize(const PTK_GridConfig *config);
301 
315 PTK_Grid * PTK_Grid_init(uint8_t *mem, const PTK_GridConfig *config);
316 
326 static inline void PTK_Grid_clear(PTK_Grid *og)
327 {
328  switch (og->config.type)
329  {
330  default:
332  case PTK_GRID_TYPE_BITS:
333  {
334  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
335  memset(ui32, 0, sizeof(uint32_t) * og->dataCellCount);
336  }
337  break;
338  case PTK_GRID_TYPE_FLOAT:
339  {
340  float *f32 = (float *)((uint8_t*)og + og->dataOffset);
341  memset(f32, 0, sizeof(float) *og->dataCellCount);
342  }
343  break;
344  case PTK_GRID_TYPE_USER:
345  {
346  uint8_t *user = (uint8_t *)og + og->dataOffset;
347  memset(user, 0, og->config.dataSize * og->dataCellCount);
348  }
349  break;
350  }
351 }
352 
353 
371 static inline uint32_t PTK_Grid_userClear(PTK_Grid *og, void *def)
372 {
373  uint8_t *user;
374  uint32_t i;
375 
376  if(PTK_GRID_TYPE_USER != og->config.type)
377  {
379  }
380 
381  user = (uint8_t *)og + og->dataOffset;
382 
383  for (i = 0; i < og->dataCellCount; ++i)
384  {
385  memcpy(user + (i*og->config.dataSize), def, og->config.dataSize);
386  }
387 
388  return(PTK_GRID_OK);
389 }
390 
406 static inline uint32_t PTK_Grid_copy(PTK_Grid *__restrict dst, const PTK_Grid *__restrict src)
407 {
408  void *srcUser;
409  void *dstUser;
410  uint32_t size;
411 
412  if(src->config.type != dst->config.type)
413  {
415  }
416 
417  if(src->dataCellCount != dst->dataCellCount)
418  {
420  }
421 
422  switch(src->config.type)
423  {
424  default:
426  case PTK_GRID_TYPE_BITS:
427  size = sizeof(uint32_t);
428  break;
429  case PTK_GRID_TYPE_FLOAT:
430  size = sizeof(float);
431  break;
432  case PTK_GRID_TYPE_USER:
433  size = src->config.dataSize;
434  break;
435  }
436 
437  srcUser = (uint8_t *)src + src->dataOffset;
438  dstUser = (uint8_t *)dst + dst->dataOffset;
439 
440  memcpy(dstUser, srcUser, size * src->dataCellCount);
441 
442  return(PTK_GRID_OK);
443 }
444 
445 static inline uint32_t computeCell(float c, float min, float invsize, uint32_t count)
446 {
447  uint32_t cell = PTK_GRID_CELL_INVALID;
448 
449  if (c >= min)
450  {
451  cell = (uint32_t) ((c - min) * invsize);
452  }
453 
454  if (cell >= count)
455  {
456  cell = PTK_GRID_CELL_INVALID;
457  }
458 
459  return cell;
460 }
461 
478 static inline uint32_t PTK_Grid_getXCell(const PTK_Grid *og, float x)
479 {
480  return computeCell(x, og->config.xMin, og->xInvCellSize, og->config.xCells);
481 }
482 
499 static inline uint32_t PTK_Grid_getYCell(const PTK_Grid *og, float y)
500 {
501  return computeCell(y, og->config.yMin, og->yInvCellSize, og->config.yCells);
502 }
503 
520 static inline uint32_t PTK_Grid_getZCell(const PTK_Grid *og, float z)
521 {
522  return computeCell(z, og->config.zMin, og->zInvCellSize, og->config.zCells);
523 }
524 
542 static inline uint32_t PTK_Grid_getLinearIndex2d(const PTK_Grid *og, uint32_t x, uint32_t y)
543 {
544  return x + og->config.xCells * y;
545 }
546 
565 static inline uint32_t PTK_Grid_getLinearIndex3d(const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
566 {
567  return x + og->config.xCells * (y + og->config.yCells * z);
568 }
569 
582 static inline float PTK_Grid_getX(const PTK_Grid *og, uint32_t x)
583 {
584  return og->config.xMin + (float)x * og->config.xCellSize;
585 }
586 
599 static inline float PTK_Grid_getY(const PTK_Grid *og, uint32_t y)
600 {
601  return og->config.yMin + (float)y * og->config.yCellSize;
602 }
603 
616 static inline float PTK_Grid_getZ(const PTK_Grid *og, uint32_t z)
617 {
618  return og->config.zMin + (float)z * og->config.zCellSize;
619 }
620 
634 static inline void PTK_Grid_setf2d(PTK_Grid *og, uint32_t x, uint32_t y, float value)
635 {
636  uint32_t cell = PTK_Grid_getLinearIndex2d(og, x, y);
637 
638  if (cell < og->dataCellCount)
639  {
640  float *f32 = (float *)((uint8_t*)og + og->dataOffset);
641  f32[cell] = value;
642  }
643 }
644 
658 static inline void PTK_Grid_setu2d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t value)
659 {
660  uint32_t cell = PTK_Grid_getLinearIndex2d(og, x, y);
661 
662  if (cell < og->dataCellCount)
663  {
664  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
665  ui32[cell] = value;
666  }
667 }
668 
682 static inline void PTK_Grid_setb2d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t bits)
683 {
684  uint32_t cell = PTK_Grid_getLinearIndex2d(og, x, y);
685 
686  if (cell < og->dataCellCount)
687  {
688  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
689  ui32[cell] |= bits;
690  }
691 }
692 
706 static inline float PTK_Grid_getf2d(const PTK_Grid *og, uint32_t x, uint32_t y)
707 {
708  uint32_t cell = PTK_Grid_getLinearIndex2d(og, x, y);
709 
710  if (cell < og->dataCellCount)
711  {
712  float *f32 = (float *)((uint8_t*)og + og->dataOffset);
713  return f32[cell];
714  }
715 
716  return FLT_MAX;
717 }
718 
732 static inline uint32_t PTK_Grid_getu2d(const PTK_Grid *og, uint32_t x, uint32_t y)
733 {
734  uint32_t cell = PTK_Grid_getLinearIndex2d(og, x, y);
735 
736  if (cell < og->dataCellCount)
737  {
738  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
739  return ui32[cell];
740  }
741 
742  return (uint32_t) -1;
743 }
744 
758 static inline uint32_t PTK_Grid_getb2d(const PTK_Grid *og, uint32_t x, uint32_t y)
759 {
760  uint32_t cell = PTK_Grid_getLinearIndex2d(og, x, y);
761 
762  if (cell < og->dataCellCount)
763  {
764  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
765  return ui32[cell];
766  }
767 
768  return 0;
769 }
770 
786 static inline void PTK_Grid_setf3d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z, float value)
787 {
788  uint32_t cell = PTK_Grid_getLinearIndex3d(og, x, y, z);
789 
790  if (cell < og->dataCellCount)
791  {
792  float *f32 = (float *)((uint8_t*)og + og->dataOffset);
793  f32[cell] = value;
794  }
795 }
796 
812 static inline void PTK_Grid_setu3d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z, uint32_t value)
813 {
814  uint32_t cell = PTK_Grid_getLinearIndex3d(og, x, y, z);
815 
816  if (cell < og->dataCellCount)
817  {
818  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
819  ui32[cell] = value;
820  }
821 }
822 
838 static inline void PTK_Grid_setb3d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z, uint32_t bits)
839 {
840  uint32_t cell = PTK_Grid_getLinearIndex3d(og, x, y, z);
841 
842  if (cell < og->dataCellCount)
843  {
844  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
845  ui32[cell] |= bits;
846  }
847 }
848 
864 static inline float PTK_Grid_getf3d(const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
865 {
866  uint32_t cell = PTK_Grid_getLinearIndex3d(og, x, y, z);
867 
868  if (cell < og->dataCellCount)
869  {
870  float *f32 = (float *)((uint8_t*)og + og->dataOffset);
871  return f32[cell];
872  }
873 
874  return FLT_MAX;
875 }
876 
892 static inline uint32_t PTK_Grid_getu3d(const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
893 {
894  uint32_t cell = PTK_Grid_getLinearIndex3d(og, x, y, z);
895 
896  if (cell < og->dataCellCount)
897  {
898  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
899  return ui32[cell];
900  }
901 
902  return (uint32_t) -1;
903 }
904 
920 static inline uint32_t PTK_Grid_getb3d(const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
921 {
922  uint32_t cell = PTK_Grid_getLinearIndex3d(og, x, y, z);
923 
924  if (cell < og->dataCellCount)
925  {
926  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
927  return ui32[cell];
928  }
929 
930  return 0;
931 }
932 
951 static inline uint32_t PTK_Grid_anyb2d(const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t bits)
952 {
953  uint32_t cell = PTK_Grid_getLinearIndex2d(og, x, y);
954 
955  if (cell < og->dataCellCount)
956  {
957  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
958  return (ui32[cell] & bits) > 0;
959  }
960 
961  return 0;
962 }
963 
984 static inline uint32_t PTK_Grid_anyb3d(const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z, uint32_t bits)
985 {
986  uint32_t cell = PTK_Grid_getLinearIndex3d(og, x, y, z);
987 
988  if (cell < og->dataCellCount)
989  {
990  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
991  return (ui32[cell] & bits) > 0;
992  }
993 
994  return 0;
995 }
996 
1015 static inline uint32_t PTK_Grid_allb2d(const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t bits)
1016 {
1017  uint32_t cell = PTK_Grid_getLinearIndex2d(og, x, y);
1018 
1019  if (cell < og->dataCellCount)
1020  {
1021  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
1022  return (ui32[cell] & bits) == bits;
1023  }
1024 
1025  return 0;
1026 }
1027 
1048 static inline uint32_t PTK_Grid_allb3d(const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z, uint32_t bits)
1049 {
1050  uint32_t cell = PTK_Grid_getLinearIndex3d(og, x, y, z);
1051 
1052  if (cell < og->dataCellCount)
1053  {
1054  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
1055  return (ui32[cell] & bits) == bits;
1056  }
1057 
1058  return 0;
1059 }
1060 
1078 static inline void PTK_Grid_clearb2d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t bits)
1079 {
1080  uint32_t cell = PTK_Grid_getLinearIndex2d(og, x, y);
1081 
1082  if (cell < og->dataCellCount)
1083  {
1084  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
1085  ui32[cell] &= ~bits;
1086  }
1087 }
1088 
1108 static inline void PTK_Grid_clearb3d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z, uint32_t bits)
1109 {
1110  uint32_t cell = PTK_Grid_getLinearIndex3d(og, x, y, z);
1111 
1112  if (cell < og->dataCellCount)
1113  {
1114  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
1115  ui32[cell] &= ~bits;
1116  }
1117 }
1118 
1136 static inline float *PTK_Grid_reff2d(PTK_Grid *og, uint32_t x, uint32_t y)
1137 {
1138  uint32_t cell = PTK_Grid_getLinearIndex2d(og, x, y);
1139 
1140  if (cell < og->dataCellCount)
1141  {
1142  float *f32 = (float *)((uint8_t*)og + og->dataOffset);
1143  return &f32[cell];
1144  }
1145 
1146  return 0;
1147 }
1148 
1168 static inline float *PTK_Grid_reff3d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
1169 {
1170  uint32_t cell = PTK_Grid_getLinearIndex3d(og, x, y, z);
1171 
1172  if (cell < og->dataCellCount)
1173  {
1174  float *f32 = (float *)((uint8_t*)og + og->dataOffset);
1175  return &f32[cell];
1176  }
1177 
1178  return 0;
1179 }
1180 
1198 static inline uint32_t *PTK_Grid_refu2d(PTK_Grid *og, uint32_t x, uint32_t y)
1199 {
1200  uint32_t cell = PTK_Grid_getLinearIndex2d(og, x, y);
1201 
1202  if (cell < og->dataCellCount)
1203  {
1204  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
1205  return &ui32[cell];
1206  }
1207 
1208  return 0;
1209 }
1210 
1230 static inline uint32_t *PTK_Grid_refu3d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
1231 {
1232  uint32_t cell = PTK_Grid_getLinearIndex3d(og, x, y, z);
1233 
1234  if (cell < og->dataCellCount)
1235  {
1236  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
1237  return &ui32[cell];
1238  }
1239 
1240  return 0;
1241 }
1242 
1260 static inline uint32_t *PTK_Grid_refb2d(PTK_Grid *og, uint32_t x, uint32_t y)
1261 {
1262  uint32_t cell = PTK_Grid_getLinearIndex2d(og, x, y);
1263 
1264  if (cell < og->dataCellCount)
1265  {
1266  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
1267  return &ui32[cell];
1268  }
1269 
1270  return 0;
1271 }
1272 
1292 static inline uint32_t *PTK_Grid_refb3d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
1293 {
1294  uint32_t cell = PTK_Grid_getLinearIndex3d(og, x, y, z);
1295 
1296  if (cell < og->dataCellCount)
1297  {
1298  uint32_t *ui32 = (uint32_t *)((uint8_t*)og + og->dataOffset);
1299  return &ui32[cell];
1300  }
1301 
1302  return 0;
1303 }
1304 
1322 static inline void *PTK_Grid_refv2d(PTK_Grid *og, uint32_t x, uint32_t y)
1323 {
1324  uint32_t cell = PTK_Grid_getLinearIndex2d(og, x, y);
1325 
1326  if (cell < og->dataCellCount)
1327  {
1328  uint8_t *user = (uint8_t *)og + og->dataOffset;
1329  return (void *)(user + (cell * og->config.dataSize));
1330  }
1331 
1332  return 0;
1333 }
1334 
1354 static inline void *PTK_Grid_refv3d(PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
1355 {
1356  uint32_t cell = PTK_Grid_getLinearIndex3d(og, x, y, z);
1357 
1358  if (cell < og->dataCellCount)
1359  {
1360  uint8_t *user = (uint8_t *)og + og->dataOffset;
1361  return (void *)(user + (cell * og->config.dataSize));
1362  }
1363 
1364  return 0;
1365 }
1366 
1380 static inline void PTK_GridRoi_setDefault(PTK_GridRoi * roi)
1381 {
1382  roi->xOffset = 0.f;
1383  roi->yOffset = 0.f;
1384  roi->xWidth = 1.f;
1385  roi->yWidth = 1.f;
1386  roi->xDir = 1.f;
1387  roi->yDir = 0.f;
1388 }
1389 
1390 #ifdef __cplusplus
1391 }
1392 #endif
1393 
1394 #endif
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
uint32_t minUpdatedCellX
Definition: grid.h:215
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
Definition: grid.h:132
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
uint32_t maxUpdatedCellY
Definition: grid.h:224
float zInvCellSize
Definition: grid.h:245
float yOffset
Definition: grid.h:274
Definition: grid.h:123
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
Definition: grid.h:129
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
uint32_t minUpdatedCellY
Definition: grid.h:218
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
Definition: grid.h:135
Definition: grid.h:126
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 maxUpdatedCellX
Definition: grid.h:221
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
Grid Meta Data.
Definition: grid.h:212
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