PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
vtkFcsvReaderTest1.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 
7 // Local includes
8 #include "PlusConfigure.h"
9 #include "vtkFcsvReader.h"
10 
11 // STL includes
12 #include <stdio.h>
13 #include <string>
14 #include <stdlib.h>
15 
16 // ITK includes
17 #include <itkLandmarkSpatialObject.h>
18 
19 int main(int argc, char* argv[])
20 {
21  vtkPlusLogger::Instance()->SetLogLevel(vtkPlusLogger::LOG_LEVEL_UNDEFINED);
22 
23  vtkSmartPointer<vtkFcsvReader> reader = vtkSmartPointer<vtkFcsvReader>::New();
24 
25  reader->SetFileName(argv[1]);
26  reader->Update();
27 
28  LOG_DEBUG("Color information:" << reader->GetFcsvDataObject().color[0]
29  << " " << reader->GetFcsvDataObject().color[1]
30  << " " << reader->GetFcsvDataObject().color[2]);
31 
32  //Second way of iteration ( good way : access to many data)
33  int fidIndex = 0;
34  std::vector<FcsvPoint>::const_iterator it = reader->GetFcsvDataObject().points.begin();
35  while (it != reader->GetFcsvDataObject().points.end())
36  {
37  LOG_DEBUG("Point position: " << (*it).position);
38 
39  if (fidIndex == 1)
40  {
41  if ((*it).position[0] != -319.5)
42  {
43  LOG_ERROR("Point position mismatch");
44  return EXIT_FAILURE;
45  }
46  if ((*it).position[1] != -224.608)
47  {
48  LOG_ERROR("Point position mismatch");
49  return EXIT_FAILURE;
50  }
51  if ((*it).position[2] != 77)
52  {
53  LOG_ERROR("Point position mismatch");
54  return EXIT_FAILURE;
55  }
56  if ((*it).selected != 0)
57  {
58  LOG_ERROR("Selected mismatch");
59  return EXIT_FAILURE;
60  }
61  if ((*it).visibility != 1)
62  {
63  LOG_ERROR("Visibility mismatch");
64  return EXIT_FAILURE;
65  }
66  }
67  if (fidIndex == 2)
68  {
69  if ((*it).selected != 1)
70  {
71  LOG_ERROR("Selected mismatch");
72  return EXIT_FAILURE;
73  }
74  if ((*it).visibility != 0)
75  {
76  LOG_ERROR("Visibility mismatch");
77  return EXIT_FAILURE;
78  }
79  }
80 
81  ++it;
82  fidIndex++;
83  }
84 
85  return EXIT_SUCCESS;
86 }
int main(int argc, char *argv[])
static vtkIGSIOLogger * Instance()