Skip to content

Commit 6f67a88

Browse files
committed
Add functions to retrieve and dispose layout dimension type list
1 parent 6443be8 commit 6f67a88

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

source/pdal/capi/Forward.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,30 @@
1818
#ifdef __cplusplus
1919
#include <memory>
2020
#include <set>
21+
#include <vector>
2122

2223
namespace pdal
2324
{
25+
struct DimType;
2426
class PipelineExecutor;
2527
class PointView;
2628

2729
using PointViewPtr = std::shared_ptr<PointView>;
30+
using DimTypeList = std::vector<DimType>;
2831

2932
namespace capi
3033
{
3134
class PointViewIterator;
3235
using Pipeline = std::unique_ptr<pdal::PipelineExecutor>;
3336
using PointView = pdal::PointViewPtr;
37+
using DimTypeList = std::unique_ptr<pdal::DimTypeList>;
3438
}
3539
}
3640

3741
#endif /* __cplusplus */
3842

43+
/// A pointer to a C++ pdal::capi::PDALDimTypeList
44+
typedef void* PDALDimTypeListPtr;
3945

4046
/// A pointer to a C++ pdal::capi::Pipeline object
4147
typedef void* PDALPipelinePtr;

source/pdal/capi/PointLayout.cpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,28 @@ namespace pdal
1212
{
1313
namespace capi
1414
{
15-
15+
PDALDimTypeListPtr PDALGetPointLayoutDimTypes(PDALPointLayoutPtr layout)
16+
{
17+
PDALDimTypeListPtr types = NULL;
18+
pdal::PointLayoutPtr nativeLayout = reinterpret_cast<pdal::PointLayoutPtr>(layout);
19+
20+
if (nativeLayout)
21+
{
22+
types = new pdal::capi::DimTypeList(new pdal::DimTypeList(nativeLayout->dimTypes()));
23+
}
24+
25+
return types;
26+
}
27+
28+
void PDALDisposeDimTypeList(PDALDimTypeListPtr types)
29+
{
30+
if (types)
31+
{
32+
pdal::capi::DimTypeList *ptr = reinterpret_cast<pdal::capi::DimTypeList *>(types);
33+
delete ptr;
34+
}
35+
}
36+
1637
size_t PDALGetDimSize(PDALPointLayoutPtr layout, const char *name)
1738
{
1839
pdal::PointLayoutPtr nativeLayout = reinterpret_cast<pdal::PointLayoutPtr>(layout);
@@ -29,11 +50,11 @@ namespace pdal
2950
{
3051
pdal::DimType type = nativeLayout->findDimType(name);
3152
pdal::DimTypeList dims = nativeLayout->dimTypes();
32-
std::string name = pdal::Dimension::name(type.m_id);
53+
std::string nameString = pdal::Dimension::name(type.m_id);
3354

3455
for (auto dim : dims)
3556
{
36-
if (name == pdal::Dimension::name(dim.m_id))
57+
if (nameString == pdal::Dimension::name(dim.m_id))
3758
{
3859
break;
3960
}

source/pdal/capi/PointLayout.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ namespace pdal
1616
extern "C"
1717
{
1818
#endif
19-
//! PDAL_C_API PDALDimTypeList PDALGetPointLayoutDimTypes(PDALPointLayoutPtr layout);
19+
PDAL_C_API PDALDimTypeListPtr PDALGetPointLayoutDimTypes(PDALPointLayoutPtr layout);
20+
21+
PDAL_C_API void PDALDisposeDimTypeList(PDALDimTypeListPtr types);
2022

2123
//! PDAL_C_API PDALDimType PDALFindDimType(PDALPointLayoutPtr layout, const char *name);
2224

0 commit comments

Comments
 (0)