-
Notifications
You must be signed in to change notification settings - Fork 0
/
exportfile.cpp
41 lines (35 loc) · 1.09 KB
/
exportfile.cpp
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
#include "exportfile.h"
#include <QDebug>
Exportfile::Exportfile(std::vector<cv::Point3f> points_cloud,QString address):points_cloud{points_cloud},fileAdress{address}
{
}
void Exportfile::save_points_cloud(std::vector<cv::Point3f> points_cloud)
{
QString lenPoint = QString::number (points_cloud.size());
header = "ply\n";
header += "format ascii 1.0\n";
header += "comment Code by Ha\n";
header += "element vertex ";
header += lenPoint;
header += "\n";
header += "property float32 x\n";
header += "property float32 y\n";
header += "property float32 z\n";
header += "element face 0\n";
header += "property list uchar int vertex_indices\n";
header += "end_header\n";
for(cv::Point3f &it:points_cloud){
header += QString::number(it.x) + " " + QString::number(it.y) + " " + QString::number(it.z) + "\n";
}
}
void Exportfile::run()
{
QFile file(fileAdress);
if(!file.open (QFile::WriteOnly | QFile::Text)){
}
QTextStream out(&file);
save_points_cloud(points_cloud);
out << header;
file.flush ();
file.close ();
}