| 224 | } |
| 225 | |
| 226 | bool ParseSOSFile(const char* filename) |
| 227 | { |
| 228 | this->CaseFileNames.clear(); |
| 229 | if (!this->SOSFile.SetFileNamePattern(filename, true)) |
| 230 | { |
| 231 | vtkGenericWarningMacro("SOS file " << filename << " could not be opened"); |
| 232 | return false; |
| 233 | } |
| 234 | this->FilePath = vtksys::SystemTools::GetParentDirectory(filename); |
| 235 | |
| 236 | bool foundServersSection = false; |
| 237 | int numServers = 0; |
| 238 | |
| 239 | auto result = this->SOSFile.ReadNextLine(); |
| 240 | while (result.first) |
| 241 | { |
| 242 | std::string& line = result.second; |
| 243 | if (line.find("FORMAT") != std::string::npos) |
| 244 | { |
| 245 | // nothing to do here |
| 246 | } |
| 247 | else if (line.find("type") != std::string::npos) |
| 248 | { |
| 249 | if (line.find("master_server") == std::string::npos || |
| 250 | line.find("gold") == std::string::npos) |
| 251 | { |
| 252 | vtkGenericWarningMacro("vtkEnSightSOSGoldReader only reads SOS files for Gold format"); |
| 253 | return false; |
| 254 | } |
| 255 | } |
| 256 | else if (line.find("SERVERS") != std::string::npos) |
| 257 | { |
| 258 | foundServersSection = true; |
| 259 | } |
| 260 | else if (foundServersSection && line.find("number of servers") != std::string::npos) |
| 261 | { |
| 262 | auto pos = line.find(':'); |
| 263 | auto value = line.substr(pos + 1); |
| 264 | sanitize(value); |
| 265 | VTK_FROM_CHARS_IF_ERROR_RETURN(value, numServers, false); |
| 266 | } |
| 267 | else if (foundServersSection && line.find("casefile") != std::string::npos) |
| 268 | { |
| 269 | auto lineParts = vtksys::SystemTools::SplitString(result.second, ':'); |
| 270 | if (lineParts.size() != 2) |
| 271 | { |
| 272 | vtkGenericWarningMacro("line " << result.second << " could not be read properly"); |
| 273 | return false; |
| 274 | } |
| 275 | sanitize(lineParts[1]); |
| 276 | this->CaseFileNames.push_back(lineParts[1]); |
| 277 | } |
| 278 | result = this->SOSFile.ReadNextLine(); |
| 279 | } |
| 280 | |
| 281 | if (this->CaseFileNames.size() != static_cast<size_t>(numServers)) |
| 282 | { |
| 283 | vtkGenericWarningMacro( |
nothing calls this directly
no test coverage detected