S
Sweety Pie
Hi,
I need to read the values from this file and save only the numerical
ones in a new file. How can I skip the header which is up to
end_header word? how can read each value and save it
Please help me
This is the format of the file:
ply
format ascii 1.0
obj_info is_cyberware_data 1
obj_info is_mesh 0
obj_info is_warped 0
obj_info is_interlaced 1
obj_info num_cols 512
obj_info num_rows 400
obj_info echo_rgb_offset_x 0.013000
obj_info echo_rgb_offset_y 0.153600
obj_info echo_rgb_offset_z 0.172000
obj_info echo_rgb_frontfocus 0.930000
obj_info echo_rgb_backfocus 0.012660
obj_info echo_rgb_pixelsize 0.000010
obj_info echo_rgb_centerpixel 232
obj_info echo_frames 512
obj_info echo_lgincr 0.000500
element vertex 40256
property float x
property float y
property float z
element range_grid 204800
property list uchar int vertex_indices
end_header
-0.06325 0.0359793 0.0420873
-0.06275 0.0360343 0.0425949
-0.0645 0.0365101 0.0404362
-0.064 0.0366195 0.0414512
-0.0635 0.0367289 0.0424662
-0.063 0.0367836 0.0429737
-0.0625 0.0368247 0.0433543
-0.062 0.0368657 0.0437349
-0.0615 0.0369067 0.0441155
-0.061 0.0369614 0.044623
-0.0605 0.0370162 0.0451305
-0.06 0.0370572 0.0455111
-0.0595 0.0370845 0.0457648
-0.059 0.0371256 0.0461455
-0.0585 0.0371529 0.0463992
-0.058 0.0371666 0.0465261
-0.0575 0.0371666 0.0465261
-0.057 0.0371666 0.0465261
-0.0565 0.0371803 0.046653
-0.056 0.0371803 0.046653
-0.0555 0.0371803 0.046653
-0.055 0.037194 0.0467798
-0.0545 0.0371666 0.0465261
-0.054 0.037194 0.0467798
-0.0535 0.0371803 0.046653
-0.053 0.037194 0.0467798
-0.0525 0.0371803 0.046653 .......................
I have written this code:
#include <iostream>
#include <fstream>
using namespace std;
int main () {
char myString;
float aNumber;
ifstream myfile ("test.txt");
if (! myfile.is_open())
{
cout << "Error opening file";
exit (1);
}
while (! myfile.eof() )
{
getline(myfile, myString);
if(myString !="end_header");
myFile >> aNumber;
}
return 0;
}
I need to read the values from this file and save only the numerical
ones in a new file. How can I skip the header which is up to
end_header word? how can read each value and save it
Please help me
This is the format of the file:
ply
format ascii 1.0
obj_info is_cyberware_data 1
obj_info is_mesh 0
obj_info is_warped 0
obj_info is_interlaced 1
obj_info num_cols 512
obj_info num_rows 400
obj_info echo_rgb_offset_x 0.013000
obj_info echo_rgb_offset_y 0.153600
obj_info echo_rgb_offset_z 0.172000
obj_info echo_rgb_frontfocus 0.930000
obj_info echo_rgb_backfocus 0.012660
obj_info echo_rgb_pixelsize 0.000010
obj_info echo_rgb_centerpixel 232
obj_info echo_frames 512
obj_info echo_lgincr 0.000500
element vertex 40256
property float x
property float y
property float z
element range_grid 204800
property list uchar int vertex_indices
end_header
-0.06325 0.0359793 0.0420873
-0.06275 0.0360343 0.0425949
-0.0645 0.0365101 0.0404362
-0.064 0.0366195 0.0414512
-0.0635 0.0367289 0.0424662
-0.063 0.0367836 0.0429737
-0.0625 0.0368247 0.0433543
-0.062 0.0368657 0.0437349
-0.0615 0.0369067 0.0441155
-0.061 0.0369614 0.044623
-0.0605 0.0370162 0.0451305
-0.06 0.0370572 0.0455111
-0.0595 0.0370845 0.0457648
-0.059 0.0371256 0.0461455
-0.0585 0.0371529 0.0463992
-0.058 0.0371666 0.0465261
-0.0575 0.0371666 0.0465261
-0.057 0.0371666 0.0465261
-0.0565 0.0371803 0.046653
-0.056 0.0371803 0.046653
-0.0555 0.0371803 0.046653
-0.055 0.037194 0.0467798
-0.0545 0.0371666 0.0465261
-0.054 0.037194 0.0467798
-0.0535 0.0371803 0.046653
-0.053 0.037194 0.0467798
-0.0525 0.0371803 0.046653 .......................
I have written this code:
#include <iostream>
#include <fstream>
using namespace std;
int main () {
char myString;
float aNumber;
ifstream myfile ("test.txt");
if (! myfile.is_open())
{
cout << "Error opening file";
exit (1);
}
while (! myfile.eof() )
{
getline(myfile, myString);
if(myString !="end_header");
myFile >> aNumber;
}
return 0;
}