/* File: ptCloudReader1.cpp Author: J.K. Johnstone Created: 11 January 2012 Last Modified: 11 January 2012 Purpose: Read a point cloud in 3-space, pure version 1. Point cloud is simply 3n floats: no delimiters, no counts. Allows an arbitrary # of comment lines, each prefaced by %, at the beginning of the point cloud. */ // 1 2 3 4 5 6 7 8 // 45678901234567890123456789012345678901234567890123456789012345678901234567890 #include #include using namespace std; #include int main (int argc, char **argv) { int i,j; ifstream infile; infile.open (argv[argc-1]); char ch; infile >> ch; while (ch == '%') // read any leading comment lines { char line[255]; infile.getline (line, 255); infile >> ch; } infile.putback(ch); int mark = infile.tellg(); int nPt=0; float foo; // count the points while (infile >> foo) { for (i=1; i<3; i++) infile >> foo; nPt++; } float** pt; // point cloud assert (nPt>0); pt = new float*[nPt]; for (i=0; i> pt[i][j]; cout << nPt << " points" << endl; // to indicate something useful was done return 0; }