9 #include <qprogressdialog.h> 10 #include <qapplication.h> 44 inline std::vector<Vertex> readTxt(
const std::string& fpath) {
45 std::ifstream infile(fpath);
46 assert(!infile.fail());
47 std::vector<Vertex> res;
48 std::string line, str;
51 QProgressDialog progress;
52 progress.setWindowTitle(QStringLiteral(
"加载中"));
53 progress.setMaximum(0);
54 progress.setMinimum(0);
59 std::getline(infile, line);
60 std::istringstream iss0(line);
65 while (std::getline(infile, line))
68 std::istringstream iss(line);
69 if (!(iss >> x >> y >> z >> w)) {
73 float t = (float)i / 100000.0f;
74 res.push_back(
Vertex({ x, y, z }, { t, 1.0f, 0.0f }));
77 QApplication::processEvents();
82 while (std::getline(infile, line))
86 std::istringstream iss(line);
88 if (!(iss >> x >> y >> z >> r >> g >> b >> w)) {
92 float t = (float)i / 100000.0f;
93 res.push_back(
Vertex({ x, y, z }, { r / 255.0f, g / 255.0f, b / 255.0f }));
96 QApplication::processEvents();
100 qDebug() <<
"read vertices: " << i;
109 inline std::vector<Vertex> readPly(
const std::string& fpath) {
110 std::ifstream infile(fpath);
111 assert(!infile.fail());
112 std::vector<Vertex> res;
113 std::string line, str;
116 while (std::getline(infile, line))
118 if (std::string::npos != line.find(
"element vertex")) {
119 std::istringstream iss(line);
121 if (!(iss >> str >> str >> numVertices)) {
122 qDebug() <<
"error reading element vertex";
125 qDebug() << numVertices <<
" | " << line.c_str();
130 while (std::getline(infile, line))
132 if (std::string::npos != line.find(
"end_header")) {
137 QProgressDialog progress;
138 progress.setWindowTitle(QStringLiteral(
"加载中"));
139 progress.setMaximum(100);
140 progress.setMinimum(0);
141 progress.setValue(0);
144 for (
int i = 0; i < numVertices; i++) {
145 float t = (float)i / numVertices;
146 std::getline(infile, line);
147 std::istringstream iss(line);
148 if (!(iss >> x >> y >> z)) {
149 qDebug() <<
"error reading vertex: " << line.c_str();
152 res.push_back(
Vertex(QVector3D(x, y, z), { t, 1.0f, 0.0f }));
155 progress.setValue((100 * i) / numVertices);
156 QApplication::processEvents();