Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1.  
  2. #include <assimp\Importer.hpp>
  3. #include <assimp\Exporter.hpp>
  4. #include <assimp\postprocess.h>
  5. #include <iostream>
  6. #include <windows.h>
  7.  
  8. #include "file_handler.h"
  9.  
  10. enum output {
  11. dae = 0,
  12. x = 1,
  13. stp = 2,
  14. obj = 3,
  15. stl = 4,
  16. stl_bin = 5,
  17. ply = 6,
  18. ply_bin = 7,
  19. _3ds = 8,
  20. json = 9
  21. };
  22.  
  23. int main(){
  24.  
  25. std::string ending; //Contains the file-format ending
  26. int output = 0; //Output-Mode (0-9)
  27.  
  28. std::string fileformat_output[10] = {".dae", ".x", ".stp",".obj",".stl",".stl",".ply",".ply",".3ds", ".json"};
  29.  
  30.  
  31. std::string filename = getDigitizrFile();
  32.  
  33. Assimp::Importer Importer;
  34. const aiScene* aiscene = Importer.ReadFile(filename.c_str(), aiProcess_JoinIdenticalVertices |
  35. aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_SortByPType | aiProcess_Triangulate);
  36.  
  37. std::string str = Importer.GetErrorString();
  38.  
  39. if (!aiscene) {
  40. printf("Error parsing '%s': '%s'\n", filename.c_str(), Importer.GetErrorString());
  41. return false;
  42. }
  43.  
  44. std::cout << "Select your output format: ";
  45. std::cin >> output;
  46.  
  47. ending = fileformat_output[output];
  48.  
  49. Assimp::Exporter exporter;
  50. const aiExportFormatDesc* format = exporter.GetExportFormatDescription(output); //.obj
  51.  
  52. std::string path = getSaveDirectory(ending);
  53.  
  54. std::cout << "Choosen output-path: " << path << std::endl;
  55.  
  56. std::string output_name;
  57.  
  58. std::cout << "output file name [without fileformat!]: ";
  59. std::cin >> output_name;
  60.  
  61. path = path + "\\" + output_name + ending;
  62. std::cout << "Output-Filelocation: " << path << std::endl;
  63. aiReturn ret = exporter.Export(aiscene, format->id, path, 0);
  64. std::cout << exporter.GetErrorString() << std::endl;
  65.  
  66.  
  67. system("pause");
  68. return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement