Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. void TriangleMesh::loadOff(const string& fileName) {
  2.     ifstream trimesh("/meshes" + fileName);
  3.     if (!trimesh) { cout << "While opening a file an error is encountered" << endl; }
  4.     else { cout << "File is successfully opened" << endl; }
  5.     while (!trimesh.eof()) {
  6.         std::istream_iterator<std::string> it(trimesh);
  7.         std::istream_iterator<std::string> end;
  8.         std::vector<std::string> tokens(it, end);
  9.         if (tokens.front == "OFF") {
  10.             const int cvertices = std::stoi(tokens.at(1));
  11.             int ctripol = std::stoi(tokens.at(2));
  12.             //int edges = std::stoi(tokens.at(3));
  13.             std::vector<vec3> vertices;
  14.            
  15.             int counter = 4;
  16.             int i = 0;
  17.             while (counter < cvertices * 4 + 3) {// Faces start at Vertices*4+3
  18.                 vec3 a(std::stoi(tokens.at(counter + 1)), std::stoi(tokens.at(counter + 2)), std::stoi(tokens.at(counter + 3)));
  19.                 vertices.insert();
  20.                 counter += 4;
  21.  
  22.             }
  23.             i = 0; //reset i;
  24.             while (counter < cvertices * 4 + ctripol * 4 + 7) {// last vertice of last face
  25.  
  26.             }
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement