MeshKit  1.0
ReadPolyLine.hpp
Go to the documentation of this file.
00001 #ifndef READPOLYLINE_H
00002 #define READPOLYLINE_H
00003 
00004 // this should not be compiled separately, included only after some stuff
00005 /*
00006 #include <vector>
00007 #include <fstream>
00008 #include <iostream>
00009 */
00010 // this is just a utility function used too many times in tests for
00011 // mesh-based geometry, so I put it separately
00012 
00013 int ReadPolyLineFromFile(const char * filename, double direction[3],
00014     std::vector<double> & points)
00015 {
00016   // get the direction, and the polygon/ polyline points
00017   std::ifstream datafile(filename, std::ifstream::in);
00018   if (!datafile) {
00019     std::cout << "can't read polyline file\n";
00020     return 1;
00021   }
00022   //
00023   char temp[100];
00024   //double direction[3];// normalized
00025   double gridSize;
00026   datafile.getline(temp, 100);// first line
00027 
00028   // get direction and mesh size along polygon segments, from file
00029   sscanf(temp, " %lf %lf %lf %lf ", direction, direction + 1, direction + 2,
00030       &gridSize);
00031 
00032   //std::vector<double> xyz;
00033   while (!datafile.eof()) {
00034     datafile.getline(temp, 100);
00035     //int id = 0;
00036     double x, y, z;
00037     int nr = sscanf(temp, "%lf %lf %lf", &x, &y, &z);
00038     if (nr == 3) {
00039       points.push_back(x);
00040       points.push_back(y);
00041       points.push_back(z);
00042     }
00043   }
00044   return 0;
00045 }
00046 #endif // READPOLYLINE_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines