将.las文件读入C ++

时间:2018-11-21 22:49:47

标签: c++ las

我在C ++方面还很陌生,但是我正在尝试读取.las文件。我有点关注this youtube video,但是在读取文件时仍然遇到一些问题。

我遇到几个错误:

error: prototype for 'int PointCloud::read(const string&)' does not match any in class 'PointCloud'|
candidate is: void PointCloud::read(const string&)|
expected declaration before '}' token|
error: prototype for 'int PointCloud::read(const string&)' does not match any    in class 'PointCloud'|
error: candidate is: void PointCloud::read(const string&)|
error: expected declaration before '}' token|

代码:

#ifndef POINTCLOUD_H
#define POINTCLOUD_H
#include <stdint.h>
#include <string>

class PointCloud
{

public:
    PointCloud(const std::string &path);

private:
struct Header
        {
            char magic[4];
            uint16_t fileSourceID;
            uint16_t globalEncoding;
            uint32_t guidData1;
            uint16_t guidData2;
            uint16_t guidData3;
            uint8_t guidData4;
            uint8_t versionMaj, versionMin;
            char systemIdentifier[32];
            char genSoftware[32];
            uint16_t creationDay, creationYear;
            uint16_t headerSize;
            uint32_t pointDataOffset;
            uint32_t numVarLenRecords;
            char pointDataFormat;
            uint16_t pointDataRecordLen;
            uint32_t pointRecordNum;
            uint32_t pointReturnNum[5];
            double  scaleX, scaleY, scaleZ;
            double offX, offY, offZ;
            double maxX, maxY, maxZ;
            double minX, minY, minZ;
        };
    void read(const std::string &path);

};

#endif //POINTCLOUD_H

#include "PointCloud.h"
#include <iostream>
#include <stdexcept>
#include <fstream>>

using namespace std;
PointCloud::read(const string &path)
  {
    ifstream inf(path, ios::binary);
    if(inf.is_open())
      {
        Header header;
        inf.read((char *))&header, sizeof(header));
        cout << header.versionMaj << "," << header.versionMin << endl;
      }
        else
      {
        cout << "Error: No file found" << endl;
      }
    }
}

我不确定为什么它抱怨原型,我认为我在标题中拥有所有权利。同样,标头结构中的所有变量都来自this link

任何帮助将不胜感激。 谢谢

0 个答案:

没有答案