example.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "readOBJ.h"
  2. #include <cstdio>
  3. #include <vector>
  4. using namespace igl;
  5. using namespace std;
  6. // Template:
  7. // T type that can be safely cast to float
  8. // Inputs:
  9. // vv vector of vectors of type T
  10. template <typename T>
  11. void print_vector_of_vectors_as_floats(const std::vector<std::vector<T > > & vv)
  12. {
  13. for(int i = 0;i<vv.size();i++)
  14. {
  15. for(int j = 0;j<vv[i].size();j++)
  16. {
  17. printf("%g ",(float)(vv[i][j]));
  18. }
  19. printf("\n");
  20. }
  21. }
  22. int main(int argc, char * argv[])
  23. {
  24. if(argc <= 1)
  25. {
  26. printf("USAGE:\n ./example [path_1] [path_2] ... [path_n]\n");
  27. return 1;
  28. }
  29. std::vector<std::vector<double> > V,TC,N;
  30. std::vector<std::vector<int> > F,FTC,FN;
  31. // loop over arguments
  32. for(int i = 1; i < argc; i++)
  33. {
  34. if(i != 1)
  35. {
  36. printf("-----------------------------------------------------------\n");
  37. }
  38. readOBJ(argv[i],V,TC,N,F,FTC,FN);
  39. cout<<"V=["; print_vector_of_vectors_as_floats(V); cout<<"];"<<endl;
  40. cout<<"TC=["; print_vector_of_vectors_as_floats(TC); cout<<"];"<<endl;
  41. cout<<"N=["; print_vector_of_vectors_as_floats(N); cout<<"];"<<endl;
  42. cout<<"F=["; print_vector_of_vectors_as_floats(F); cout<<"];"<<endl;
  43. cout<<"FTC=[";print_vector_of_vectors_as_floats(FTC);cout<<"];"<<endl;
  44. cout<<"FN=["; print_vector_of_vectors_as_floats(FN); cout<<"];"<<endl;
  45. }
  46. return 0;
  47. }