28 "MITK NavigationData Reader (CSV)")
48 std::vector<std::string> fileContent = GetFileContentLineByLine(GetInputLocation());
49 int NumOfTools = getNumberOfToolsInLine(fileContent[0]);
52 std::vector<mitk::BaseData::Pointer> result;
53 result.push_back(returnValue.GetPointer());
56 for (
unsigned int i = 1; i<fileContent.size(); i++)
58 returnValue->AddNavigationDatas(parseLine(fileContent[i], NumOfTools));
67 std::vector<std::string> tokens=splitLine(line);
68 int size = tokens.size();
69 int NumOfTools = (size)/9;
73 MITK_ERROR(
"mitkNavigationDataReader") <<
"Illegal csv-file! Unexpected number of columns found! Assuming " << NumOfTools <<
" tools!";
81 std::vector<std::string> elems;
82 std::stringstream ss(line);
84 while (std::getline(ss, item,
';')) {
85 elems.push_back(item);
99 time = StringToDouble(timestamp);
101 if (valid ==
"1") isValid =
true;
102 else isValid =
false;
104 position[0] = StringToDouble(X);
105 position[1] = StringToDouble(Y);
106 position[2] = StringToDouble(Z);
108 orientation[0] = StringToDouble(QX);
109 orientation[1] = StringToDouble(QY);
110 orientation[2] = StringToDouble(QZ);
111 orientation[3] = StringToDouble(QR);
113 result->SetIGTTimeStamp(time);
114 result->SetDataValid(isValid);
115 result->SetPosition(position);
116 result->SetOrientation(orientation);
122 std::istringstream i(s);
131 std::vector<std::string> parts = splitLine(line);
132 std::vector<mitk::NavigationData::Pointer> result;
136 for (
int n = 0; n < NumOfTools; n++)
140 nd = CreateNd(parts[offset], parts[offset + 1], parts[offset + 2], parts[offset + 3], parts[offset + 4], parts[offset + 5], parts[offset + 6], parts[offset + 7], parts[offset + 8]);
141 result.push_back(nd);
149 std::vector<std::string> readData = std::vector<std::string>();
160 file.seekg(0L, std::ios::beg);
164 std::getline(file,buffer);
165 if (buffer.size() > 0) readData.push_back(buffer);
itk::SmartPointer< Self > Pointer
virtual mitk::NavigationDataReaderCSV * Clone() const override
std::vector< mitk::NavigationData::Pointer > parseLine(std::string line, int NumOfTools)
NavigationDataReaderCSV()
DataCollection - Class to facilitate loading/accessing structured data.
double StringToDouble(const std::string &s)
std::vector< std::string > splitLine(std::string line)
mitk::NavigationData::Pointer CreateNd(std::string timestamp, std::string valid, std::string X, std::string Y, std::string Z, std::string QX, std::string QY, std::string QZ, std::string QR)
us::ServiceRegistration< IFileReader > RegisterService(us::ModuleContext *context=us::GetModuleContext())
Convenience class to temporarily change the current locale.
static const std::string filename
vnl_quaternion< ScalarType > Quaternion
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
Base class for creating mitk::BaseData objects from files or streams.
int getNumberOfToolsInLine(std::string line)
virtual ~NavigationDataReaderCSV()
virtual std::vector< itk::SmartPointer< BaseData > > Read() override
Reads a path or stream and creates a list of BaseData objects.
std::vector< std::string > GetFileContentLineByLine(std::string filename)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.