PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
ReplayRecordedDataTest.cxx
Go to the documentation of this file.
1 /*=Plus=header=begin======================================================
2 Program: Plus
3 Copyright (c) Laboratory for Percutaneous Surgery. All rights reserved.
4 See License.txt for details.
5 =========================================================Plus=header=end*/
6 
12 #include "PlusConfigure.h"
13 
14 #include "vtkSmartPointer.h"
15 #include "vtksys/CommandLineArguments.hxx"
16 #include "vtkXMLUtilities.h"
17 
18 #include "vtkPlusDataCollector.h"
19 #include "vtkPlusSavedDataSource.h"
20 
21 
22 int main( int argc, char** argv )
23 {
24 
25  // Check command line arguments.
26 
27  std::string inputConfigFileName;
28  std::string inputVideoBufferMetafile;
29  std::string inputTrackerBufferMetafile;
30  int verboseLevel = vtkPlusLogger::LOG_LEVEL_UNDEFINED;
31 
32  vtksys::CommandLineArguments args;
33  args.Initialize( argc, argv );
34 
35  args.AddArgument( "--config-file", vtksys::CommandLineArguments::EQUAL_ARGUMENT,
36  &inputConfigFileName, "Name of the input configuration file." );
37  args.AddArgument( "--verbose", vtksys::CommandLineArguments::EQUAL_ARGUMENT,
38  &verboseLevel, "Verbose level (1=error only, 2=warning, 3=info, 4=debug 5=trace)" );
39 
40  if ( ! args.Parse() )
41  {
42  std::cerr << "Problem parsing arguments." << std::endl;
43  std::cout << "Help: " << args.GetHelp() << std::endl;
44  return EXIT_FAILURE;
45  }
46 
47  vtkPlusLogger::Instance()->SetLogLevel( verboseLevel );
48 
49  // Prepare data collector object.
50  vtkSmartPointer<vtkXMLDataElement> configRootElement = vtkSmartPointer<vtkXMLDataElement>::New();
51  if (PlusXmlUtils::ReadDeviceSetConfigurationFromFile(configRootElement, inputConfigFileName.c_str())==PLUS_FAIL)
52  {
53  LOG_ERROR("Unable to read configuration from file " << inputConfigFileName.c_str());
54  return EXIT_FAILURE;
55  }
56 
58 
59  vtkSmartPointer<vtkPlusDataCollector> dataCollector = vtkSmartPointer<vtkPlusDataCollector>::New();
60 
61  dataCollector->ReadConfiguration( configRootElement );
62 
63  LOG_DEBUG( "Initializing data collector... " );
64  dataCollector->Connect();
65 
66  // TODO: Check if the read transforms are really the same as in the ones recorded in the data file.
67 
68  dataCollector->Disconnect();
69 
70  return EXIT_SUCCESS;
71 }
#define PLUS_FAIL
Definition: PlusCommon.h:43
static vtkPlusConfig * GetInstance()
int main(int argc, char **argv)
static vtkIGSIOLogger * Instance()
void SetDeviceSetConfigurationData(vtkXMLDataElement *deviceSetConfigurationData)
static PlusStatus ReadDeviceSetConfigurationFromFile(vtkXMLDataElement *config, const char *filename)
Definition: PlusXmlUtils.h:23