ctkDICOMIndexer.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) 2010 Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. // Qt includes
  15. #include <QApplication>
  16. #include <QPushButton>
  17. #include <QTextStream>
  18. // CTK includes
  19. #include <ctkDICOMIndexer.h>
  20. #include <ctkDICOM.h>
  21. // STD includes
  22. #include <cstdlib>
  23. #include <iostream>
  24. #include <fstream>
  25. int main(int argc, char** argv)
  26. {
  27. if (argc < 2)
  28. {
  29. std::cerr << "Usage: ctkDICOMIndexer <database.db> <sourceDir> [destDir]\n";
  30. return EXIT_FAILURE;
  31. }
  32. QApplication app(argc, argv);
  33. QTextStream out(stdout);
  34. ctkDICOMIndexer idx;
  35. ctkDICOM myCTK;
  36. if ( myCTK.openDatabase( argv[1]) )
  37. {
  38. out << "open db success\n";
  39. /// make sure it is empty and properly initialized
  40. myCTK.initializeDatabase();
  41. out << "init db done\n";
  42. if (argc > 3)
  43. {
  44. idx.addDirectory(myCTK.database(),argv[2],argv[3]);
  45. }
  46. else
  47. {
  48. idx.addDirectory(myCTK.database(),argv[2]);
  49. }
  50. out << "add db done\n";
  51. idx.refreshDatabase(myCTK.database(),argv[2]);
  52. out << "refresh db done\n";
  53. myCTK.closeDatabase();
  54. }
  55. else
  56. {
  57. out << "ERROR: " ;
  58. out << myCTK.GetLastError();
  59. out << "\n" ;
  60. }
  61. return EXIT_SUCCESS;
  62. }