本文整理汇总了C++中LasReader::setReadCb方法的典型用法代码示例。如果您正苦于以下问题:C++ LasReader::setReadCb方法的具体用法?C++ LasReader::setReadCb怎么用?C++ LasReader::setReadCb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LasReader
的用法示例。
在下文中一共展示了LasReader::setReadCb方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(LasReaderTest, callback)
{
PointTable table;
point_count_t count = 0;
Options ops;
ops.add("filename", Support::datapath("las/simple.las"));
Reader::PointReadFunc cb = [&count](PointView& view, PointId id)
{
count++;
};
LasReader reader;
reader.setOptions(ops);
reader.setReadCb(cb);
reader.prepare(table);
reader.execute(table);
EXPECT_EQ(count, (point_count_t)1065);
}
示例2: addPoint
TEST(PointTable, userView)
{
class UserTable : public PointTable
{
private:
double m_x;
double m_y;
double m_z;
public:
PointId addPoint()
{ return 0; }
char *getPoint(PointId idx)
{ return NULL; }
void setField(const Dimension::Detail *d, PointId idx, const void *value)
{
if (d->id() == Dimension::Id::X)
m_x = *(const double *)value;
else if (d->id() == Dimension::Id::Y)
m_y = *(const double *)value;
else if (d->id() == Dimension::Id::Z)
m_z = *(const double *)value;
}
void getField(const Dimension::Detail *d, PointId idx, void *value)
{
if (d->id() == Dimension::Id::X)
*(double *)value = m_x;
else if (d->id() == Dimension::Id::Y)
*(double *)value = m_y;
else if (d->id() == Dimension::Id::Z)
*(double *)value = m_z;
}
};
LasReader reader;
Options opts;
opts.add("filename", Support::datapath("las/simple.las"));
opts.add("count", 100);
reader.setOptions(opts);
PointTable defTable;
reader.prepare(defTable);
PointViewSet viewSet = reader.execute(defTable);
PointViewPtr defView = *viewSet.begin();
bool called(false);
auto readCb = [defView, &called](PointView& customView, PointId id)
{
called = true;
double xDef = defView->getFieldAs<double>(Dimension::Id::X, id);
double yDef = defView->getFieldAs<double>(Dimension::Id::Y, id);
double zDef = defView->getFieldAs<double>(Dimension::Id::Z, id);
double x = customView.getFieldAs<double>(Dimension::Id::X, id);
double y = customView.getFieldAs<double>(Dimension::Id::Y, id);
double z = customView.getFieldAs<double>(Dimension::Id::Z, id);
EXPECT_FLOAT_EQ(xDef, x);
EXPECT_FLOAT_EQ(yDef, y);
EXPECT_FLOAT_EQ(zDef, z);
};
reader.setReadCb(readCb);
UserTable table;
reader.prepare(table);
reader.execute(table);
EXPECT_TRUE(called);
}