Reading .las file into C++











up vote
0
down vote

favorite












I'm fairly new at C++, but I'm trying to read in a .las file. I'm sort of following this youtube video, but I'm still having some issues reading in the file.



I'm getting several errors:



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|


Code:



#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;
}
}
}


I'm not sure why it is complaining about the prototype I think I have everything right in the header. Also all the variables in the header struct come from this link.



Any help would be greatly appreciated.
Thanks










share|improve this question
























  • You're missing the return type from the PointCloud::read definition. And you have unmatched braces; I think there is a closing brace (}) too much at the bottom.
    – ravnsgaard
    Nov 21 at 22:55












  • @ravnsgaard, do I still need to specify a return type even though it's void?
    – p0ps1c1e
    Nov 22 at 2:12










  • Yes, you do. You're running into an ancient rule in the system (inherited from C) that makes anything not explicitly declared an int. Your compiler should have more to say about this... What compiler are you using? What version?
    – ravnsgaard
    Nov 22 at 12:36










  • I'm running GCC im not sure the version as I'm on Windows and its kind of a pain to check
    – p0ps1c1e
    Nov 22 at 18:15






  • 1




    You're not returning anything. So, the return type should be void. It already is in your declaration, but there's no return type on your definition. This mismatch is what the compiler's complaining about.
    – ravnsgaard
    Nov 22 at 19:07















up vote
0
down vote

favorite












I'm fairly new at C++, but I'm trying to read in a .las file. I'm sort of following this youtube video, but I'm still having some issues reading in the file.



I'm getting several errors:



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|


Code:



#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;
}
}
}


I'm not sure why it is complaining about the prototype I think I have everything right in the header. Also all the variables in the header struct come from this link.



Any help would be greatly appreciated.
Thanks










share|improve this question
























  • You're missing the return type from the PointCloud::read definition. And you have unmatched braces; I think there is a closing brace (}) too much at the bottom.
    – ravnsgaard
    Nov 21 at 22:55












  • @ravnsgaard, do I still need to specify a return type even though it's void?
    – p0ps1c1e
    Nov 22 at 2:12










  • Yes, you do. You're running into an ancient rule in the system (inherited from C) that makes anything not explicitly declared an int. Your compiler should have more to say about this... What compiler are you using? What version?
    – ravnsgaard
    Nov 22 at 12:36










  • I'm running GCC im not sure the version as I'm on Windows and its kind of a pain to check
    – p0ps1c1e
    Nov 22 at 18:15






  • 1




    You're not returning anything. So, the return type should be void. It already is in your declaration, but there's no return type on your definition. This mismatch is what the compiler's complaining about.
    – ravnsgaard
    Nov 22 at 19:07













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm fairly new at C++, but I'm trying to read in a .las file. I'm sort of following this youtube video, but I'm still having some issues reading in the file.



I'm getting several errors:



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|


Code:



#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;
}
}
}


I'm not sure why it is complaining about the prototype I think I have everything right in the header. Also all the variables in the header struct come from this link.



Any help would be greatly appreciated.
Thanks










share|improve this question















I'm fairly new at C++, but I'm trying to read in a .las file. I'm sort of following this youtube video, but I'm still having some issues reading in the file.



I'm getting several errors:



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|


Code:



#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;
}
}
}


I'm not sure why it is complaining about the prototype I think I have everything right in the header. Also all the variables in the header struct come from this link.



Any help would be greatly appreciated.
Thanks







c++ las






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 at 4:00

























asked Nov 21 at 22:49









p0ps1c1e

276




276












  • You're missing the return type from the PointCloud::read definition. And you have unmatched braces; I think there is a closing brace (}) too much at the bottom.
    – ravnsgaard
    Nov 21 at 22:55












  • @ravnsgaard, do I still need to specify a return type even though it's void?
    – p0ps1c1e
    Nov 22 at 2:12










  • Yes, you do. You're running into an ancient rule in the system (inherited from C) that makes anything not explicitly declared an int. Your compiler should have more to say about this... What compiler are you using? What version?
    – ravnsgaard
    Nov 22 at 12:36










  • I'm running GCC im not sure the version as I'm on Windows and its kind of a pain to check
    – p0ps1c1e
    Nov 22 at 18:15






  • 1




    You're not returning anything. So, the return type should be void. It already is in your declaration, but there's no return type on your definition. This mismatch is what the compiler's complaining about.
    – ravnsgaard
    Nov 22 at 19:07


















  • You're missing the return type from the PointCloud::read definition. And you have unmatched braces; I think there is a closing brace (}) too much at the bottom.
    – ravnsgaard
    Nov 21 at 22:55












  • @ravnsgaard, do I still need to specify a return type even though it's void?
    – p0ps1c1e
    Nov 22 at 2:12










  • Yes, you do. You're running into an ancient rule in the system (inherited from C) that makes anything not explicitly declared an int. Your compiler should have more to say about this... What compiler are you using? What version?
    – ravnsgaard
    Nov 22 at 12:36










  • I'm running GCC im not sure the version as I'm on Windows and its kind of a pain to check
    – p0ps1c1e
    Nov 22 at 18:15






  • 1




    You're not returning anything. So, the return type should be void. It already is in your declaration, but there's no return type on your definition. This mismatch is what the compiler's complaining about.
    – ravnsgaard
    Nov 22 at 19:07
















You're missing the return type from the PointCloud::read definition. And you have unmatched braces; I think there is a closing brace (}) too much at the bottom.
– ravnsgaard
Nov 21 at 22:55






You're missing the return type from the PointCloud::read definition. And you have unmatched braces; I think there is a closing brace (}) too much at the bottom.
– ravnsgaard
Nov 21 at 22:55














@ravnsgaard, do I still need to specify a return type even though it's void?
– p0ps1c1e
Nov 22 at 2:12




@ravnsgaard, do I still need to specify a return type even though it's void?
– p0ps1c1e
Nov 22 at 2:12












Yes, you do. You're running into an ancient rule in the system (inherited from C) that makes anything not explicitly declared an int. Your compiler should have more to say about this... What compiler are you using? What version?
– ravnsgaard
Nov 22 at 12:36




Yes, you do. You're running into an ancient rule in the system (inherited from C) that makes anything not explicitly declared an int. Your compiler should have more to say about this... What compiler are you using? What version?
– ravnsgaard
Nov 22 at 12:36












I'm running GCC im not sure the version as I'm on Windows and its kind of a pain to check
– p0ps1c1e
Nov 22 at 18:15




I'm running GCC im not sure the version as I'm on Windows and its kind of a pain to check
– p0ps1c1e
Nov 22 at 18:15




1




1




You're not returning anything. So, the return type should be void. It already is in your declaration, but there's no return type on your definition. This mismatch is what the compiler's complaining about.
– ravnsgaard
Nov 22 at 19:07




You're not returning anything. So, the return type should be void. It already is in your declaration, but there's no return type on your definition. This mismatch is what the compiler's complaining about.
– ravnsgaard
Nov 22 at 19:07

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421517%2freading-las-file-into-c%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421517%2freading-las-file-into-c%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks