MCPcopy Create free account
hub / github.com/Kitware/VTK / ParseDenseData

Method ParseDenseData

IO/Infovis/vtkBiomTableReader.cxx:397–453  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

395
396//------------------------------------------------------------------------------
397void vtkBiomTableReader::ParseDenseData()
398{
399 // find "data":
400 size_t pos1 = this->FileContents.find("\"data\":");
401 if (pos1 == std::string::npos)
402 {
403 vtkErrorMacro(<< "data not found in input file");
404 return;
405 }
406
407 // find first [ (beginning of matrix)
408 size_t pos_start = this->FileContents.find('[', pos1) + 1;
409 if (pos_start == std::string::npos)
410 {
411 vtkErrorMacro(<< "data field not formatted properly");
412 return;
413 }
414
415 for (int currentRow = 0; currentRow < this->NumberOfRows; ++currentRow)
416 {
417 // find [ (beginning of row)
418 size_t pos_row_1 = this->FileContents.find('[', pos_start);
419 if (pos_row_1 == std::string::npos)
420 {
421 vtkErrorMacro(<< "data field not formatted properly");
422 return;
423 }
424 int currentCol;
425 for (currentCol = 1; currentCol < this->NumberOfColumns; ++currentCol)
426 {
427 // find next comma
428 size_t pos_row_2 = this->FileContents.find(',', pos_row_1 + 1);
429 if (pos_row_2 == std::string::npos)
430 {
431 vtkErrorMacro(<< "data field not formatted properly");
432 return;
433 }
434
435 // parse data value and insert it into the table
436 std::string value = this->FileContents.substr(pos_row_1 + 1, pos_row_2 - pos_row_1 - 1);
437 this->InsertValue(currentRow, currentCol, value);
438
439 pos_row_1 = pos_row_2;
440 }
441
442 // the last value of the row ends with a ] instead of a comma
443 size_t pos_row_2 = this->FileContents.find(']', pos_row_1 + 1);
444 if (pos_row_2 == std::string::npos)
445 {
446 vtkErrorMacro(<< "data field not formatted properly");
447 return;
448 }
449 std::string value = this->FileContents.substr(pos_row_1 + 1, pos_row_2 - pos_row_1 - 1);
450 this->InsertValue(currentRow, currentCol, value);
451 pos_start = pos_row_2;
452 }
453}
454

Callers 1

ReadMeshSimpleMethod · 0.95

Calls 2

InsertValueMethod · 0.95
findMethod · 0.45

Tested by

no test coverage detected