asmaloney/libE57Format

How to access individual points?

Opened this issue · 0 comments

Hello, first of all thank you for the library and the fantastic effort. This library seems like the more promising option on vcpkg, compared to the original library I believe this one is forked from. I'm well aware that there are no official tutorials and that the documentation is very limited. In the future, I'd honestly like to help a little bit to help others not lose so much time.

My main issue: I need to use E57 format to access a point cloud because it's the only format that seems to work for other tools I'm working with. I'm trying to work with a toy example, so I made a very simple trapezoid of 8 points and exported the ascii format to e57 via cloud compare. The points are really just the following:

0.0 0.0 0.0
4.0 0.0 0.0
4.0 4.0 0.0
0.0 4.0 0.0
1.0 1.0 2.0
3.0 1.0 2.0
3.0 3.0 2.0
1.0 3.0 2.0

So, I'm really just dipping my toes in E57 to get what I need (and actually keep working with data in PCL). However, I've spent nearly 2 days trying to access each point in what I feel is a very intuitive way: trying to iterate over some kind of array in a loop and print to screen. However, no matter what I've searched, including in this repo's unittesting files, I can't print the value of a single point to screen. Sorry for the rant, and I'm sorry to ask what seems like a novice question, but could someone please help me complete the code below. Thank you very very much in advance.

// above: #include <E57Format/E57SimpleReader.h>
// (... int main, etc ...)
    // load with e57 lib, then convert to point cloud
    e57::ReaderOptions opts;
    e57::Reader fe(fpath, opts);
    int scanIndex = 0;
    e57::Data3D scanHeader;

    fe.ReadData3D(scanIndex, scanHeader);
    int const npts = scanHeader.pointCount;
    cout << "npoints: " << npts << endl;

    // this part doesn't work correctly
    e57::Data3DPointsFloat pointsData(scanHeader);
    e57::CompressedVectorReader vectorReader = fe.SetUpData3DPointsData(scanIndex, npts, pointsData);
    pcl::PointXYZ ipt(pointsData.cartesianX[0], pointsData.cartesianY[0], pointsData.cartesianZ[0]);
    cout << "sample: " << ipt << endl; // somehow scaled / 

current output:

npoints: 8
sample: (-4.31602e+08,-4.31602e+08,-4.31602e+08)