Rearranging .ply file via C++ String Parsing

x99

Joined
Dec 14, 2019
Messages
1
Reaction score
0
I have two .ply files (original and myfile). After skipping lines till end_header in both the files, I need to read lines.

Each line has 3 coordinates and I have to store them. The lines in myfile are not arranged properly and I want them to be in the same order as that of the original file. I could use cartesian product to do so but I am not sure how to formulate the whole program sine I am working with two files together.



#include<iostream>
#include <fstream>
#include <string>

using namespace std;


int main()
{
ifstream myfile ("A.ply");
ifstream originalFile ("org.ply");

string myString;
string line;

float coordinate;

std::vector<Vec3f> original;
Vec3f coordOriginal;
std::vector<Vec3f> decompressed;
Vec3f coordDecompressed;

if (! myfile.is_open())
{
cout << "Error opening file" << endl;
exit (1);
}

if (! originalFile.is_open())
{
cout << "Error opening file" << endl;
exit (1);
}

while (! originalFile.eof() )
{
//skipping first 31 lines till end_header

do{
getline(myfile, myString);
} while(myString !="end_header")

//storing x, y, z coordinates of each line in the Original File
std::istringstream str(&line[0]);
str >> coordOriginal[0] >> coordOriginal[1] >> coordOriginal[2];
original.push_back(coordOriginal);



}


return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top