Skip to content

Commit 7fe74ab

Browse files
committed
Add functions to retrieve dim type interpretation byte count
1 parent c6f81ec commit 7fe74ab

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

source/pdal/pdalc_dimtype.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ namespace pdal
3131
return size;
3232
}
3333

34+
uint64_t PDALGetDimTypeListByteCount(PDALDimTypeListPtr types)
35+
{
36+
uint64_t byteCount = 0;
37+
size_t pointCount = PDALGetDimTypeListSize(types);
38+
39+
for (size_t i = 0; i < pointCount; ++i)
40+
{
41+
byteCount += PDALGetDimTypeInterpretationByteCount(PDALGetDimType(types, i));
42+
}
43+
44+
return byteCount;
45+
}
46+
3447
PDALDimType PDALGetInvalidDimType()
3548
{
3649
PDALDimType dim ={
@@ -71,15 +84,16 @@ namespace pdal
7184
return result;
7285
}
7386

87+
size_t PDALGetDimTypeInterpretationByteCount(PDALDimType dim)
88+
{
89+
return pdal::Dimension::size(static_cast<pdal::Dimension::Type>(dim.type));
90+
}
91+
7492
PDALDimType PDALGetDimType(PDALDimTypeListPtr types, size_t index)
7593
{
7694
pdal::capi::DimTypeList *wrapper = reinterpret_cast<pdal::capi::DimTypeList *>(types);
7795

7896
PDALDimType dim = PDALGetInvalidDimType();
79-
// PDALDimType dim = {
80-
// static_cast<uint32_t>(pdal::Dimension::id("")), static_cast<uint32_t>(pdal::Dimension::type("")),
81-
// 1.0, 0.0
82-
// };
8397

8498
if (wrapper && wrapper->get())
8599
{

source/pdal/pdalc_dimtype.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ namespace pdal
2929
*/
3030
PDALC_API size_t PDALGetDimTypeListSize(PDALDimTypeListPtr types);
3131

32+
/**
33+
* Returns the number of bytes required to store data referenced
34+
* by a dimension type list.
35+
*
36+
* @param types A pointer to the dimension type list
37+
* @return The number of bytes required to store the referenced data
38+
*/
39+
PDALC_API uint64_t PDALGetDimTypeListByteCount(PDALDimTypeListPtr types);
40+
3241
/**
3342
* Returns the invalid dimension type. This dimension type has:
3443
* - An ID value of 0 that corresponds to pdal::Dimension::Id::Unknown
@@ -72,6 +81,14 @@ namespace pdal
7281
*/
7382
PDALC_API size_t PDALGetDimTypeInterpretationName(PDALDimType dim, char *name, size_t size);
7483

84+
/**
85+
* Retrieves the byte count of a dimension type's interpretation, i.e., its data size.
86+
*
87+
* @param dim The dimension type
88+
* @return The byte count of the retrieved interpretation
89+
*/
90+
PDALC_API size_t PDALGetDimTypeInterpretationByteCount(PDALDimType dim);
91+
7592
/**
7693
* Disposes the provided dimension type list.
7794
*

tests/pdal/test_pdalc_pointview.c.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ TEST testPDALGetAllPackedPoints(void)
388388
size_t pointSize = PDALGetPointSize(layout);
389389
ASSERT(numPoints > 0);
390390
ASSERT(pointSize > 0);
391+
ASSERT_EQ(pointSize, PDALGetDimTypeListByteCount(dims));
392+
391393

392394
char *actualPoints = calloc(numPoints, pointSize);
393395
ASSERT(actualPoints);

0 commit comments

Comments
 (0)