-
Notifications
You must be signed in to change notification settings - Fork 1
/
ccPDALReaders.h
81 lines (64 loc) · 1.73 KB
/
ccPDALReaders.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef CLOUDCOMPAREPROJECTS_CCPDALREADERS_H
#define CLOUDCOMPAREPROJECTS_CCPDALREADERS_H
#include <pdal/Reader.hpp>
#include <pdal/Streamable.hpp>
#include <ccPointCloud.h>
static const pdal::PluginInfo s_CloudStreamReaderInfo
{
"readers.ccPointCloudStreamReader",
"Allow to use ccPointCloud as source for PDAL pipelines",
""
};
class ccPointCloudStreamReader : public pdal::Reader, pdal::Streamable
{
public:
explicit ccPointCloudStreamReader(ccPointCloud *mCloud) : m_cloud(mCloud)
{}
ccPointCloudStreamReader() = default;
std::string getName() const override
{
return s_CloudStreamReaderInfo.name;
}
private:
pdal::point_count_t read(pdal::PointViewPtr view, pdal::point_count_t count) override
{
pdal::PointId idx = view->size();
pdal::point_count_t cnt = 0;
pdal::PointRef point(*view, idx);
while (cnt < m_cloud->size())
{
point.setPointId(idx);
if (!processOne(point))
break;
cnt++;
idx++;
}
return cnt;
}
private:
void addDimensions(pdal::PointLayoutPtr ptr) override
{
ptr->registerDim(pdal::Dimension::Id::X);
ptr->registerDim(pdal::Dimension::Id::Y);
ptr->registerDim(pdal::Dimension::Id::Z);
}
private:
bool processOne(pdal::PointRef &point) override
{
if (!m_cloud)
{
return false;
}
const CCVector3 *ccPoint = m_cloud->getPoint(m_currentPoint);
point.setField(pdal::Dimension::Id::X, ccPoint->x);
point.setField(pdal::Dimension::Id::Y, ccPoint->y);
point.setField(pdal::Dimension::Id::Z, ccPoint->z);
m_currentPoint++;
return m_currentPoint < m_cloud->size();
}
private:
ccPointCloud *m_cloud;
unsigned m_currentPoint = 0;
};
CREATE_STATIC_STAGE(ccPointCloudStreamReader, s_CloudStreamReaderInfo);
#endif //CLOUDCOMPAREPROJECTS_CCPDALREADERS_H