0

I compiled the libe57 in order to use it in my project. I did it and now I'm trying to use it. (I'm on windows 10 x64) Basing on this tutorial, I did this

int
main(int argc, char** argv)
{
    char sFile[] = "PTX/file.e57";
    _bstr_t bsFile = sFile;                 //converts Unicode to UTF-8
    e57::Reader     eReader((char*)bsFile);

    e57::E57Root rootHeader;
    eReader.GetE57Root(rootHeader);

    const char* fileGuid = rootHeader.guid.c_str();
    e57::DateTime fileGPSTime = rootHeader.creationDateTime;
    int data3DCount = eReader.GetData3DCount();
    int scanIndex = 0;
    e57::Data3D             scanHeader;
    eReader.ReadData3D(scanIndex, scanHeader);



    _bstr_t bstrName = scanHeader.name.c_str();
    _bstr_t bstrGuid = scanHeader.guid.c_str();
    _bstr_t bstrDesc = scanHeader.description.c_str();

    int64_t nColumn = 0;
    int64_t nRow = 0;

    int64_t nPointsSize = 0;        //Number of points

    int64_t nGroupsSize = 0;        //Number of groups
    int64_t nCountSize = 0;         //Number of points per group
    bool    bColumnIndex = false; //indicates that idElementName is "columnIndex"

    eReader.GetData3DSizes(scanIndex, nRow, nColumn, nPointsSize, nGroupsSize, nCountSize, bColumnIndex);

    int64_t nSize = nRow;
    if (nSize == 0) nSize = 1024;    // choose a chunk size

        int8_t * isInvalidData = NULL;
    if (scanHeader.pointFields.cartesianInvalidStateField)
        isInvalidData = new int8_t[nSize];


        double * xData = NULL;
    if (scanHeader.pointFields.cartesianXField)
        xData = new double[nSize];

    double * yData = NULL;
    if (scanHeader.pointFields.cartesianYField)
        yData = new double[nSize];

    double * zData = NULL;
    if (scanHeader.pointFields.cartesianZField)
        zData = new double[nSize];


        double *        intData = NULL;
    bool            bIntensity = false;
    double          intRange = 0;
    double          intOffset = 0;

    if (scanHeader.pointFields.intensityField)
    {
        bIntensity = true;
        intData = new double[nSize];
        intRange = scanHeader.intensityLimits.intensityMaximum - scanHeader.intensityLimits.intensityMinimum;
        intOffset = scanHeader.intensityLimits.intensityMinimum;
    }


    uint16_t *      redData = NULL;
    uint16_t *      greenData = NULL;
    uint16_t *      blueData = NULL;
    bool            bColor = false;
    int32_t         colorRedRange = 1;
    int32_t         colorRedOffset = 0;
    int32_t         colorGreenRange = 1;
    int32_t         colorGreenOffset = 0;
    int32_t         colorBlueRange = 1;
    int32_t         colorBlueOffset = 0;

    if (scanHeader.pointFields.colorRedField)
    {
        bColor = true;
        redData = new uint16_t[nSize];
        greenData = new uint16_t[nSize];
        blueData = new uint16_t[nSize];
        colorRedRange = scanHeader.colorLimits.colorRedMaximum - scanHeader.colorLimits.colorRedMinimum;
        colorRedOffset = scanHeader.colorLimits.colorRedMinimum;
        colorGreenRange = scanHeader.colorLimits.colorGreenMaximum - scanHeader.colorLimits.colorGreenMinimum;
        colorGreenOffset = scanHeader.colorLimits.colorGreenMinimum;
        colorBlueRange = scanHeader.colorLimits.colorBlueMaximum - scanHeader.colorLimits.colorBlueMinimum;
        colorBlueOffset = scanHeader.colorLimits.colorBlueMinimum;
    }


        int64_t * idElementValue = NULL;
    int64_t * startPointIndex = NULL;
    int64_t * pointCount = NULL;
    if (nGroupsSize > 0)
    {
        idElementValue = new int64_t[nGroupsSize];
        startPointIndex = new int64_t[nGroupsSize];
        pointCount = new int64_t[nGroupsSize];

        if (!eReader.ReadData3DGroupsData(scanIndex, nGroupsSize, idElementValue,
            startPointIndex, pointCount))
            nGroupsSize = 0;
    }


    int32_t * rowIndex = NULL;
    int32_t * columnIndex = NULL;
    if (scanHeader.pointFields.rowIndexField)
        rowIndex = new int32_t[nSize];
    if (scanHeader.pointFields.columnIndexField)
        columnIndex = new int32_t[nRow];
    e57::CompressedVectorReader dataReader = eReader.SetUpData3DPointsData(
        scanIndex,                      //!< data block index given by the NewData3D
        nRow,                           //!< size of each of the buffers given
        xData,                          //!< pointer to a buffer with the x data
        yData,                          //!< pointer to a buffer with the y data
        zData,                          //!< pointer to a buffer with the z data
        isInvalidData,          //!< pointer to a buffer with the valid indication
        intData,                        //!< pointer to a buffer with the lidar return intesity
        NULL,
        redData,                        //!< pointer to a buffer with the color red data
        greenData,                      //!< pointer to a buffer with the color green data
        blueData,                       //!< pointer to a buffer with the color blue data
        NULL,
        NULL,
        NULL,
        NULL,
        NULL,
        rowIndex,                       //!< pointer to a buffer with the rowIndex
        columnIndex                     //!< pointer to a buffer with the columnIndex
    );


    int64_t         count = 0;
    unsigned        size = 0;
    int                     col = 0;
    int                     row = 0;


    int cpt = 0;
    while (size = dataReader.read())
    {
        cpt++;
    }

    std::cout << cpt << std::endl;

        dataReader.close();

        if (isInvalidData) delete isInvalidData;
        if (xData) delete xData;
        if (yData) delete yData;
        if (zData) delete zData;
        if (intData) delete intData;
        if (redData) delete redData;
        if (greenData) delete greenData;
        if (blueData) delete blueData;
   }

The problem is that everytime, the reader says that there are 65536 rows and 1 cols, meaning that my pointcloud contain always 65536 points. I tried with several files that have more than 200k points each, but the result are always the same, it writes in my XYZ file 65536 points, and no more.

EDIT 2: shorter example : the problem is still the same

#include "E57Foundation.h"
#include "E57Simple.h"
#include "comutil.h"

#include <iostream>
#include <vector>
 int
main(int argc, char** argv)
{

   e57::Reader  eReader("PTX/file.e57");
    int         scanIndex = 0;  //picking the first scan

    e57::Data3D scanHeader;     //read scan's header information
    eReader.ReadData3D(scanIndex, scanHeader);


    _bstr_t scanGuid = scanHeader.guid.c_str();     //get guid
    int64_t nColumn = 0;        //Number of Columns in a structure scan (from "indexBounds" if structure data)
    int64_t nRow = 0;           //Number of Rows in a structure scan    
    int64_t nPointsSize = 0;    //Number of points 
    int64_t nGroupsSize = 0;    //Number of groups (from "groupingByLine" if present)
    int64_t nCountsSize = 0;    //Number of points per group
    bool bColumnIndex = false;
    eReader.GetData3DSizes(scanIndex, nRow, nColumn, nPointsSize, nGroupsSize, nCountsSize, bColumnIndex);

    int64_t nSize = (nRow > 0) ? nRow : 1024;   //Pick a size for buffers
    double *xData = new double[nSize];
    double *yData = new double[nSize];
    double *zData = new double[nSize];

    e57::CompressedVectorReader dataReader = eReader.SetUpData3DPointsData(
        scanIndex,  //!< scan data index 
        nSize,      //!< size of each of the buffers given
        xData,      //!< pointer to a buffer with the x data
        yData,      //!< pointer to a buffer with the y data
        zData);     //!< pointer to a buffer with the z data 
//still a size of 65536

    dataReader.close();
    delete xData;
    delete yData;
    delete zData;   
}
Raph Schim
  • 528
  • 7
  • 30
  • `_bstr_t bsFile = sFile; //converts Unicode to UTF-8` Does it? – Lightness Races in Orbit Nov 02 '18 at 12:25
  • Please form a [MCVE] with less code. – Lightness Races in Orbit Nov 02 '18 at 12:26
  • This sounds a lot like a range limitation inherent to the library, to me, but I can't make sense of the documentation. Probably best off asking their devs... – Lightness Races in Orbit Nov 02 '18 at 12:27
  • I don't know if it does, I just get their example, and the problem doesn't come from this function, so, for now, I'm not looking into this. I will form a minimal complete and verifiable example after this comment. This library is quite old actually (the last version is from 2012), maybe it is something that was bring with new versions of windows? – Raph Schim Nov 02 '18 at 12:37
  • I am trying to find a quick answer before again sending you off to the e57 lists (which I maintain would be a better place to ask) - can you confirm that it is `eReader.SetUpData3DPointsData` you're asking about? An actual [MCVE] (meaning, a `main` function and all necessary #include directives) would still help. – Lightness Races in Orbit Nov 02 '18 at 12:42
  • I asked for entering into e57 list, but actually, I have no response that's why I'm posted here. I'm not sure if the fault creating function is `GetData3DSizes` or `SetUpData3DPointsData` – Raph Schim Nov 02 '18 at 12:45
  • See Edit 2 for minimal code example. The results with this are still the same – Raph Schim Nov 02 '18 at 12:50
  • Thanks, good MCVE now. – Lightness Races in Orbit Nov 02 '18 at 12:51
  • Meh, I can't see anything in their code that adds any artificial uint16_t bound. You'll need usage guidance from the e57 devs/community on this. Good luck! – Lightness Races in Orbit Nov 02 '18 at 12:55
  • Maybe the problem come directly from the constructor of the eReader. Since in my first code, when I read the header `ReadData3D(scanIndex, scanHeader)`, in `scanHeader`, `int64_t pointsSize` (that have this comment : `//!< Total size of the compressed vector of PointRecord structures referring to the binary data that actually stores the point data`) is 65536 – Raph Schim Nov 02 '18 at 12:55
  • Thanks a lot for trying. I'll bring answer here if there is one one day :) – Raph Schim Nov 02 '18 at 12:56
  • I look forward to it! Give me a ping if you find one. – Lightness Races in Orbit Nov 02 '18 at 13:19
  • What version is this by the way? – Lightness Races in Orbit Nov 02 '18 at 13:22
  • Where did your input file come from? Are you sure it's correct? – Lightness Races in Orbit Nov 02 '18 at 13:33
  • This is the version 3.3.2. and my file ocme from Cyclone. But maybe my files are malformated. because I just tried the examples they give in the websites, and some files are stuck with 65536 points and some seems to have more. That's pretty strange actually. I'll do my research to find if there is some correlations between all the files that are stuck to that limits of points. – Raph Schim Nov 02 '18 at 13:41
  • Could you link me to two of those contrasting examples? I'm convinced it's a problem with metadata in the files themselves. Some software that writes it apparently caps the `"points"` count at `UINT16_MAX`. We should be able to prove that this is the case with those files (with help from examples that _aren't_ capped), though that still leaves the mystery of how these files were generated that way, why, and how to stop it from happening. – Lightness Races in Orbit Nov 02 '18 at 13:42
  • Woaw!!! No I found it! I'm utterly stupid! Cyclone is something we use really often, so I put a blind trust in it. But in certain condition, the export of e57 doesn't work well and it creates useless points in order to go to 2^16 points in the file. While I was working, VS didn't built again the code so it was always the sames bugged file that was used! Sorry I took your time like this :( – Raph Schim Nov 02 '18 at 13:52
  • Lol well at least it's fixed – Lightness Races in Orbit Nov 02 '18 at 14:31

0 Answers0