No Description

mosher.cpp 918B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <fstream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5. int main(){
  6. string FILE_NAME = "egg";
  7. string HEIGHT_VALUE = "-0.050000";
  8. string line;
  9. vector<string> vert;
  10. ifstream input;
  11. ofstream output;
  12. ifstream input1;
  13. ofstream output1;
  14. string a;
  15. input.open(FILE_NAME + ".obj");
  16. output.open(FILE_NAME + "_half.obj");
  17. while(getline(input,line)){
  18. if(line.substr(0,2) == "v "){
  19. if(line.find(HEIGHT_VALUE) != std::string::npos){
  20. output << line << "\n";
  21. }
  22. else{
  23. vert.push_back(line);
  24. output << "\n";
  25. }
  26. }
  27. else{
  28. output << line << "\n";
  29. }
  30. }
  31. input.close();
  32. output.close();
  33. input1.open(FILE_NAME + "_half.obj");
  34. output1.open(FILE_NAME + "_mosh.obj");
  35. while(getline(input1,line)){
  36. if(line == ""){
  37. output1 << vert.back(); << "\n";
  38. vert.pop_back();
  39. }
  40. else{
  41. output1 << line << "\n";
  42. }
  43. }
  44. input1.close();
  45. output1.close();
  46. }