Created
February 27, 2018 07:39
-
-
Save menyf/9dd843b22d9969908260c09d015d06e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
#include <vector> | |
#include <fstream> | |
#include <cstdio> | |
using namespace std; | |
struct Point | |
{ | |
double x, y, z; | |
}; | |
struct Face | |
{ | |
int a, b, c; | |
int front, back; | |
}; | |
int main(int argc, char *argv[]) | |
{ | |
char buf[1000]; | |
string tmp; | |
vector<Point> v; | |
vector<Face> f; | |
int prev = 0, pref = 0; | |
for (int i = 1; i < argc; i++) | |
{ | |
cout << argv[i] << endl; | |
// freopen(argv[i], "r", stdin); | |
ifstream f_in(argv[i]); | |
while (f_in >> tmp) | |
{ | |
puts(tmp.c_str()); | |
if (tmp == "v") | |
{ | |
Point now; | |
f_in >> now.x >> now.y >> now.z; | |
v.push_back(now); | |
} | |
else if (tmp == "f") | |
{ | |
Face face; | |
char ch; | |
int xx; | |
face.front = i; | |
face.back = 0; | |
f_in >> face.a; | |
cout<<"begin while"<<endl; | |
// while ((cin>>ch) != ' ') | |
while (1) | |
{ | |
f_in >> ch; | |
cout<<"ch="<<ch<<endl; | |
if (ch == ' ') | |
break; | |
} | |
cout<<"startb"<<endl; | |
f_in >> face.b; | |
while (1) | |
{ | |
f_in >> ch; | |
if (ch == ' ') | |
break; | |
} | |
cout<<"startc"<<endl; | |
f_in >> face.c; | |
//f_in.getline(); | |
// fgets(buf, 1000, stdin); | |
string str; | |
getline(f_in, str); | |
cout<<"str="<<str<<endl; | |
// gets(); | |
face.a += prev - 1; | |
face.b += prev - 1; | |
face.c += prev - 1; | |
f.push_back(face); | |
} | |
else | |
{ | |
//f_in.getline(); | |
string str; | |
getline(f_in, str); | |
// fgets(buf, 1000, stdin); | |
// gets(); | |
} | |
} | |
pref = f.size(); | |
prev = v.size(); | |
} | |
freopen("output.arec", "w", stdout); | |
cout << v.size() << endl; | |
for (auto point : v) | |
{ | |
printf("%.10f %.10f %.10f\n", point.x, point.y, point.z); | |
} | |
cout << f.size() << endl; | |
for (auto face : f) | |
{ | |
printf("%d %d %d %d %d\n", face.a, face.b, face.c, face.front, face.back); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment