Skip to content

Commit dfb23a3

Browse files
committed
Add PointView support to C API
1 parent edfbe8a commit dfb23a3

File tree

4 files changed

+215
-1
lines changed

4 files changed

+215
-1
lines changed

source/pdal/capi/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ message(STATUS "Found PDAL ${PDAL_VERSION}")
55

66
set(SOURCES
77
Pipeline.cpp
8+
PointView.cpp
89
PointViewCollection.cpp
910
)
1011

1112
set(HEADERS
1213
Defines.h
1314
Forward.h
1415
Pipeline.h
16+
PointView.h
1517
PointViewCollection.h
1618
)
1719

source/pdal/capi/Forward.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,26 @@ namespace pdal
2323
{
2424
class PipelineExecutor;
2525
class PointView;
26-
26+
27+
using PointViewPtr = std::shared_ptr<PointView>;
28+
2729
namespace capi
2830
{
2931
class PointViewCollection;
3032
using Pipeline = std::unique_ptr<pdal::PipelineExecutor>;
33+
using PointView = pdal::PointViewPtr;
3134
}
3235
}
3336

3437
#endif /* __cplusplus */
3538

39+
/// A pointer to a C++ pdal::capi::Pipeline object
3640
typedef void* PDALPipelinePtr;
41+
42+
/// A pointer to a C++ pdal::capi::PointView object
3743
typedef void* PDALPointViewPtr;
44+
45+
/// A pointer to a C++ pdal::capi::PointViewCollection object
3846
typedef void* PDALPointViewCollectionPtr;
3947

4048
#endif /* PDAL_CAPI_FORWARD_H */

source/pdal/capi/PointView.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright (c) Simverge Software LLC - All Rights Reserved
3+
*/
4+
#include "PointView.h"
5+
#include <pdal/PointView.hpp>
6+
7+
namespace pdal
8+
{
9+
namespace capi
10+
{
11+
extern "C"
12+
{
13+
void PDALDisposePointView(PDALPointViewPtr view)
14+
{
15+
pdal::capi::PointView *wrapper = reinterpret_cast<pdal::capi::PointView *>(view);
16+
17+
if (wrapper)
18+
{
19+
delete wrapper;
20+
}
21+
}
22+
23+
int PDALGetPointViewId(PDALPointViewPtr view)
24+
{
25+
pdal::capi::PointView *wrapper = reinterpret_cast<pdal::capi::PointView *>(view);
26+
27+
return wrapper && *wrapper ? (*wrapper)->id() : 0;
28+
}
29+
30+
uint64_t PDALGetPointViewSize(PDALPointViewPtr view)
31+
{
32+
pdal::capi::PointView *wrapper = reinterpret_cast<pdal::capi::PointView *>(view);
33+
return wrapper && *wrapper ? (*wrapper)->size() : 0;
34+
}
35+
36+
bool PDALIsPointViewEmpty(PDALPointViewPtr view)
37+
{
38+
pdal::capi::PointView *wrapper = reinterpret_cast<pdal::capi::PointView *>(view);
39+
return !wrapper || !*wrapper || (*wrapper)->empty();
40+
}
41+
42+
PDALPointViewPtr PDALClonePointView(PDALPointViewPtr view)
43+
{
44+
pdal::capi::PointView *wrapper = reinterpret_cast<pdal::capi::PointView *>(view);
45+
46+
PDALPointViewPtr ptr = nullptr;
47+
48+
if (wrapper && *wrapper)
49+
{
50+
ptr = new pdal::capi::PointView(std::move((*wrapper)->makeNew()));
51+
}
52+
53+
return ptr;
54+
}
55+
}
56+
}
57+
}

source/pdal/capi/PointView.h

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/*
2+
* Copyright (c) Simverge Software LLC - All Rights Reserved
3+
*/
4+
#ifndef PDAL_CAPI_POINTVIEW_H
5+
#define PDAL_CAPI_POINTVIEW_H
6+
7+
#include "Forward.h"
8+
9+
#ifdef __cplusplus /* __cplusplus */
10+
11+
namespace pdal
12+
{
13+
namespace capi
14+
{
15+
extern "C"
16+
{
17+
#else
18+
#include <stdbool.h> // for bool
19+
#include <stdint.h> // for uint64_t
20+
#endif
21+
22+
PDAL_C_API void PDALDisposePointView(PDALPointViewPtr view);
23+
24+
//PointViewIter begin();
25+
//PointViewIter end();
26+
27+
PDAL_C_API int PDALGetPointViewId(PDALPointViewPtr view);
28+
29+
PDAL_C_API uint64_t PDALGetPointViewSize(PDALPointViewPtr view);
30+
31+
PDAL_C_API bool PDALIsPointViewEmpty(PDALPointViewPtr view);
32+
33+
//PDAL_C_API void PDALAppendPointToView(PDALPointViewPtr view);
34+
35+
//PDAL_C_API void PDALAppendAllPointsToView(PDALPointViewPtr to, PDALPointViewPtr from);
36+
37+
/**
38+
* @see pdal::PointView::makeNew
39+
*/
40+
PDAL_C_API PDALPointViewPtr PDALClonePointView(PDALPointViewPtr view);
41+
42+
// PointRef point(PointId)
43+
44+
// template<class T>
45+
// T getFieldAs(Dimension::Id dim, PointId pointIndex) const;
46+
47+
// inline void getField(char *pos, Dimension::Id d,
48+
// Dimension::Type type, PointId id) const;
49+
50+
// template<typename T>
51+
// void setField(Dimension::Id dim, PointId idx, T val);
52+
53+
// inline void setField(Dimension::Id dim, Dimension::Type type,
54+
// PointId idx, const void *val);
55+
56+
// template <typename T>
57+
// bool compare(Dimension::Id dim, PointId id1, PointId id2);
58+
59+
// bool compare(Dimension::Id dim, PointId id1, PointId id2)
60+
61+
// void getRawField(Dimension::Id dim, PointId idx, void *buf) const
62+
63+
// void calculateBounds(BOX2D& box) const;
64+
// static void calculateBounds(const PointViewSet&, BOX2D& box);
65+
// void calculateBounds(BOX3D& box) const;
66+
// static void calculateBounds(const PointViewSet&, BOX3D& box);
67+
68+
// void dump(std::ostream& ostr) const;
69+
70+
// bool hasDim(Dimension::Id id) const;
71+
72+
// std::string dimName(Dimension::Id id) const;
73+
74+
// Dimension::IdList dims() const;
75+
76+
// std::size_t pointSize() const;
77+
78+
// std::size_t dimSize(Dimension::Id id) const;
79+
80+
// Dimension::Type dimType(Dimension::Id id) const;
81+
82+
// DimTypeList dimTypes() const;
83+
84+
// inline PointLayoutPtr layout() const;
85+
86+
// SpatialReference spatialReference() const;
87+
88+
/**
89+
* Fill a buffer with point data specified by the dimension list.
90+
*
91+
* @param dims List of dimensions/types to retrieve.
92+
* @param idx Index of point to get.
93+
* @param[out] buf Pointer to buffer to fill.
94+
*/
95+
//void getPackedPoint(const DimTypeList& dims, PointId idx, char *buf) const
96+
97+
/// Load the point buffer from memory whose arrangement is specified
98+
/// by the dimension list.
99+
/// \param[in] dims Dimension/types of data in packed order
100+
/// \param[in] idx Index of point to write.
101+
/// \param[in] buf Packed data buffer.
102+
//void setPackedPoint(const DimTypeList& dims, PointId idx, const char *buf)
103+
104+
/// Provides access to the memory storing the point data. Though this
105+
/// function is public, other access methods are safer and preferred.
106+
//char *getPoint(PointId id)
107+
108+
/// Provides access to the memory storing the point data. Though this
109+
/// function is public, other access methods are safer and preferred.
110+
//char *getOrAddPoint(PointId id)
111+
112+
// The standard idiom is swapping with a stack-created empty queue, but
113+
// that invokes the ctor and probably allocates. We've probably only got
114+
// one or two things in our queue, so just pop until we're empty.
115+
//void clearTemps()
116+
117+
//MetadataNode toMetadata() const;
118+
119+
//void invalidateProducts();
120+
121+
/**
122+
Creates a mesh with the specified name.
123+
124+
\param name Name of the mesh.
125+
\return Pointer to the new mesh. Null is returned if the mesh
126+
already exists.
127+
*/
128+
// TriangularMesh *createMesh(const std::string& name);
129+
130+
/**
131+
Get a pointer to a mesh.
132+
133+
\param name Name of the mesh.
134+
\return New mesh. Null is returned if the mesh already exists.
135+
*/
136+
// TriangularMesh *mesh(const std::string& name = "");
137+
138+
// KD3Index& build3dIndex();
139+
// KD2Index& build2dIndex();
140+
141+
#ifdef __cplusplus
142+
}
143+
}
144+
}
145+
#endif /* __cplusplus */
146+
147+
#endif

0 commit comments

Comments
 (0)