------------------------------------------------------------------------------
| 138 | |
| 139 | //------------------------------------------------------------------------------ |
| 140 | int vtkNewickTreeReader::ReadMeshSimple(const std::string& fname, vtkDataObject* doOutput) |
| 141 | { |
| 142 | vtkDebugMacro(<< "Reading Newick tree ..."); |
| 143 | |
| 144 | if (!this->ReadFromInputString) |
| 145 | { |
| 146 | if (fname.empty()) |
| 147 | { |
| 148 | vtkErrorMacro("FileName not set."); |
| 149 | return 1; |
| 150 | } |
| 151 | |
| 152 | vtksys::ifstream ifs(fname.c_str(), vtksys::ifstream::in); |
| 153 | if (!ifs.good()) |
| 154 | { |
| 155 | vtkErrorMacro(<< "Unable to open " << fname << " for reading"); |
| 156 | return 1; |
| 157 | } |
| 158 | |
| 159 | // Read the input file into a char * |
| 160 | ifs.seekg(0, std::ios::end); |
| 161 | this->InputStringLength = ifs.tellg(); |
| 162 | ifs.seekg(0, std::ios::beg); |
| 163 | this->InputString = new char[this->InputStringLength]; |
| 164 | ifs.read(this->InputString, this->InputStringLength); |
| 165 | ifs.close(); |
| 166 | } |
| 167 | else |
| 168 | { |
| 169 | if ((!this->InputString) || (this->InputStringLength == 0)) |
| 170 | { |
| 171 | vtkErrorMacro(<< "Input string is empty!"); |
| 172 | return 1; |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | vtkTree* const output = vtkTree::SafeDownCast(doOutput); |
| 177 | |
| 178 | if (!ReadNewickTree(this->InputString, *output)) |
| 179 | { |
| 180 | vtkErrorMacro(<< "Error reading a vtkTree from the input."); |
| 181 | return 1; |
| 182 | } |
| 183 | |
| 184 | vtkDebugMacro(<< "Read " << output->GetNumberOfVertices() << " vertices and " |
| 185 | << output->GetNumberOfEdges() << " edges.\n"); |
| 186 | |
| 187 | return 1; |
| 188 | } |
| 189 | |
| 190 | //------------------------------------------------------------------------------ |
| 191 | void vtkNewickTreeReader::CountNodes(const char* buffer, vtkIdType* numNodes) |
nothing calls this directly
no test coverage detected