------------------------------------------------------------------------------
| 39 | |
| 40 | //------------------------------------------------------------------------------ |
| 41 | int vtkStructuredGridReader::ReadMetaDataSimple(const std::string& fname, vtkInformation* metadata) |
| 42 | { |
| 43 | char line[256]; |
| 44 | bool dimsRead = false; |
| 45 | |
| 46 | if (!this->OpenVTKFile(fname.c_str()) || !this->ReadHeader(fname.c_str())) |
| 47 | { |
| 48 | return 1; |
| 49 | } |
| 50 | |
| 51 | // Read structured grid specific stuff |
| 52 | // |
| 53 | if (!this->ReadString(line)) |
| 54 | { |
| 55 | vtkErrorMacro(<< "Data file ends prematurely!"); |
| 56 | this->CloseVTKFile(); |
| 57 | return 1; |
| 58 | } |
| 59 | |
| 60 | if (!strncmp(this->LowerCase(line), "dataset", 7)) |
| 61 | { |
| 62 | // Make sure we're reading right type of geometry |
| 63 | // |
| 64 | if (!this->ReadString(line)) |
| 65 | { |
| 66 | vtkErrorMacro(<< "Data file ends prematurely!"); |
| 67 | this->CloseVTKFile(); |
| 68 | return 1; |
| 69 | } |
| 70 | |
| 71 | if (strncmp(this->LowerCase(line), "structured_grid", 15) != 0) |
| 72 | { |
| 73 | vtkErrorMacro(<< "Cannot read dataset type: " << line); |
| 74 | this->CloseVTKFile(); |
| 75 | return 1; |
| 76 | } |
| 77 | |
| 78 | // Read keyword and dimensions |
| 79 | // |
| 80 | while (true) |
| 81 | { |
| 82 | if (!this->ReadString(line)) |
| 83 | { |
| 84 | break; |
| 85 | } |
| 86 | |
| 87 | // Have to read field data because it may be binary. |
| 88 | if (!strncmp(this->LowerCase(line), "field", 5)) |
| 89 | { |
| 90 | vtkFieldData* fd = this->ReadFieldData(); |
| 91 | fd->Delete(); |
| 92 | } |
| 93 | |
| 94 | if (!strncmp(this->LowerCase(line), "dimensions", 10) && !dimsRead) |
| 95 | { |
| 96 | int dim[3]; |
| 97 | if (!(this->Read(dim) && this->Read(dim + 1) && this->Read(dim + 2))) |
| 98 | { |
nothing calls this directly
no test coverage detected