-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpoint_io.hpp
92 lines (70 loc) · 2.2 KB
/
point_io.hpp
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef POINTIO_H
#define POINTIO_H
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <limits>
#include <pdal/Options.hpp>
#include <pdal/PointTable.hpp>
#include <pdal/StageFactory.hpp>
#include <pdal/io/BufferReader.hpp>
struct XYZ {
float x;
float y;
float z;
};
struct Extent{
double minx;
double maxx;
double miny;
double maxy;
Extent(){
minx = miny = (std::numeric_limits<double>::max)();
maxx = maxy = (std::numeric_limits<double>::min)();
}
void inline update(double x, double y){
minx = (std::min)(minx, x);
maxx = (std::max)(maxx, x);
miny = (std::min)(miny, y);
maxy = (std::max)(maxy, y);
}
double width() const {
return maxx - minx;
}
double height() const {
return maxy - miny;
}
friend std::ostream& operator<<(std::ostream &out, const Extent &e){
return out << std::setprecision(12) << "[minx: " << e.minx <<
", maxx: " << e.maxx <<
", miny: " << e.miny <<
", maxy: " << e.maxy << "]";
}
};
struct PointSet {
std::vector<double> x;
std::vector<double> y;
std::vector<double> z;
pdal::PointViewPtr pointView = nullptr;
inline size_t count() const { return x.size(); }
inline size_t size() const { return x.size(); }
inline void resize(size_t count){
x.resize(count);
y.resize(count);
z.resize(count);
}
~PointSet() {
}
Extent extent;
pdal::SpatialReference srs;
};
std::string getVertexLine(std::ifstream &reader);
size_t getVertexCount(const std::string &line);
inline void checkHeader(std::ifstream &reader, const std::string &prop);
inline bool hasHeader(const std::string &line, const std::string &prop);
PointSet *fastPlyReadPointSet(const std::string &filename, size_t decimation = 1);
PointSet *pdalReadPointSet(const std::string &filename, uint8_t onlyClass = 255, size_t decimation = 1);
PointSet *readPointSet(const std::string &filename, int classification = -1, int decimation = 1);
bool fileExists(const std::string &path);
#endif