-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathIldaReader.cpp
More file actions
52 lines (40 loc) · 1.14 KB
/
Copy pathIldaReader.cpp
File metadata and controls
52 lines (40 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "IldaReader.h"
#include "Frame.h"
#include "Points.h"
#include <fstream>
#include <string>
using namespace std;
IldaReader::IldaReader() {}
bool IldaReader::readFile(string fileName) {
// Open file.
this->file = std::ifstream(fileName, std::ifstream::binary);
if (!this->file) {
return false;
}
// Read first 32 header bytes from the file and check if the first 4 bytes in ASCII are "ILDA".
return checkHeader();
}
// Read first 32 header bytes from the file and check if the first 4 bytes in ASCII are "ILDA".
bool IldaReader::checkHeader() {
char buf[Frame::NUMBER_OF_HEADER_BYTES];
this->file.read(buf, Frame::NUMBER_OF_HEADER_BYTES);
string header = "";
for (int i = 0; i < 4; i++) {
header += buf[i];
}
if (header != "ILDA") {
// Invalid file.
return false;
}
// Return back to start of the file.
this->file.seekg(0);
return true;
}
bool IldaReader::getNextFrame(Points* points) {
// Read all points from next frame.
Frame frame;
return frame.getNext(this->file, points);
}
void IldaReader::closeFile() {
this->file.close();
}