You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.5 KiB

2 years ago
  1. /*****************************************************************************
  2. *
  3. * demo program - part of CLIPP (command line interfaces for modern C++)
  4. *
  5. * released under MIT license
  6. *
  7. * (c) 2017-2018 André Müller; foss@andremueller-online.de
  8. *
  9. *****************************************************************************/
  10. #include <iostream>
  11. #include <string>
  12. #include <clipp.h>
  13. int main(int argc, char* argv[])
  14. {
  15. using namespace clipp;
  16. using std::cout;
  17. std::string infile;
  18. bool tr = false, rot = false;
  19. double x = 0, y = 0, z = 0;
  20. double phi = 0, theta = 0;
  21. auto cli = (
  22. value("geometry file", infile),
  23. option("-translate").set(tr) & value("x", x) & value("y", y) & value("z", z),
  24. option("-rotate").set(rot) & value("azimuth", phi) & value("polar", theta)
  25. );
  26. if(parse(argc, argv, cli)) {
  27. if(!tr && !rot) {
  28. cout << "nothing will be done with file '" << infile << "'\n";
  29. }
  30. else {
  31. cout << "transforming content of file '" << infile << "'\n";
  32. if(tr) {
  33. cout << "translating objects by vector ("
  34. << x << ", " << y << ", " << z << ")\n";
  35. }
  36. if(rot) {
  37. cout << "rotating objects about azimuth = " << phi
  38. << " and polar angle = " << theta << '\n';
  39. }
  40. }
  41. }
  42. else {
  43. cout << "Usage:\n" << usage_lines(cli, argv[0]) << '\n';
  44. }
  45. }