------------------------------------------------------------------------------
| 62 | |
| 63 | //------------------------------------------------------------------------------ |
| 64 | int vtkBiomTableReader::ReadMeshSimple(const std::string& fname, vtkDataObject* doOutput) |
| 65 | { |
| 66 | vtkDebugMacro(<< "Reading biom table..."); |
| 67 | |
| 68 | if (fname.empty()) |
| 69 | { |
| 70 | vtkErrorMacro(<< "Input filename not set"); |
| 71 | return 1; |
| 72 | } |
| 73 | |
| 74 | vtksys::ifstream ifs(fname.c_str(), vtksys::ifstream::in); |
| 75 | if (!ifs.good()) |
| 76 | { |
| 77 | vtkErrorMacro(<< "Unable to open " << fname << " for reading"); |
| 78 | return 1; |
| 79 | } |
| 80 | |
| 81 | ifs.seekg(0, std::ios::end); |
| 82 | this->FileContents.reserve(ifs.tellg()); |
| 83 | ifs.seekg(0, std::ios::beg); |
| 84 | |
| 85 | this->FileContents.assign( |
| 86 | (std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>()); |
| 87 | |
| 88 | this->ParseShape(); |
| 89 | this->ParseDataType(); |
| 90 | |
| 91 | vtkNew<vtkStringArray> rowNames; |
| 92 | rowNames->SetName("name"); |
| 93 | vtkTable* output = vtkTable::SafeDownCast(doOutput); |
| 94 | output->AddColumn(rowNames); |
| 95 | for (int i = 1; i < this->NumberOfColumns + 1; ++i) |
| 96 | { |
| 97 | switch (this->DataType) |
| 98 | { |
| 99 | case VTK_INT: |
| 100 | { |
| 101 | vtkNew<vtkIntArray> intCol; |
| 102 | output->AddColumn(intCol); |
| 103 | break; |
| 104 | } |
| 105 | case VTK_FLOAT: |
| 106 | { |
| 107 | vtkNew<vtkFloatArray> floatCol; |
| 108 | output->AddColumn(floatCol); |
| 109 | break; |
| 110 | } |
| 111 | case VTK_STRING: |
| 112 | { |
| 113 | vtkNew<vtkStringArray> stringCol; |
| 114 | output->AddColumn(stringCol); |
| 115 | break; |
| 116 | } |
| 117 | default: |
| 118 | break; |
| 119 | } |
| 120 | } |
| 121 | output->SetNumberOfRows(this->NumberOfRows); |
nothing calls this directly
no test coverage detected