------------------------------------------------------------------------------
| 46 | |
| 47 | //------------------------------------------------------------------------------ |
| 48 | int vtkTreeReader::ReadMeshSimple(const std::string& fname, vtkDataObject* doOutput) |
| 49 | { |
| 50 | vtkDebugMacro(<< "Reading vtk tree ..."); |
| 51 | |
| 52 | if (!this->OpenVTKFile(fname.c_str()) || !this->ReadHeader()) |
| 53 | { |
| 54 | return 1; |
| 55 | } |
| 56 | |
| 57 | // Read table-specific stuff |
| 58 | char line[256]; |
| 59 | if (!this->ReadString(line)) |
| 60 | { |
| 61 | vtkErrorMacro(<< "Data file ends prematurely!"); |
| 62 | this->CloseVTKFile(); |
| 63 | return 1; |
| 64 | } |
| 65 | |
| 66 | if (strncmp(this->LowerCase(line), "dataset", 7) != 0) |
| 67 | { |
| 68 | vtkErrorMacro(<< "Unrecognized keyword: " << line); |
| 69 | this->CloseVTKFile(); |
| 70 | return 1; |
| 71 | } |
| 72 | |
| 73 | if (!this->ReadString(line)) |
| 74 | { |
| 75 | vtkErrorMacro(<< "Data file ends prematurely!"); |
| 76 | this->CloseVTKFile(); |
| 77 | return 1; |
| 78 | } |
| 79 | |
| 80 | if (strncmp(this->LowerCase(line), "tree", 4) != 0) |
| 81 | { |
| 82 | vtkErrorMacro(<< "Cannot read dataset type: " << line); |
| 83 | this->CloseVTKFile(); |
| 84 | return 1; |
| 85 | } |
| 86 | |
| 87 | vtkTree* const output = vtkTree::SafeDownCast(doOutput); |
| 88 | |
| 89 | vtkSmartPointer<vtkMutableDirectedGraph> builder = |
| 90 | vtkSmartPointer<vtkMutableDirectedGraph>::New(); |
| 91 | |
| 92 | while (true) |
| 93 | { |
| 94 | if (!this->ReadString(line)) |
| 95 | { |
| 96 | break; |
| 97 | } |
| 98 | |
| 99 | if (!strncmp(this->LowerCase(line), "field", 5)) |
| 100 | { |
| 101 | vtkFieldData* const field_data = this->ReadFieldData(); |
| 102 | builder->SetFieldData(field_data); |
| 103 | field_data->Delete(); |
| 104 | continue; |
| 105 | } |
no test coverage detected