| 38 | VTKImageIO::~VTKImageIO() = default; |
| 39 | |
| 40 | int |
| 41 | VTKImageIO::GetNextLine(std::ifstream & ifs, std::string & line, bool lowerCase, SizeValueType count) |
| 42 | { |
| 43 | // The terminal condition for this recursive calls |
| 44 | if (count > 5) |
| 45 | { |
| 46 | itkExceptionMacro("Error of GetNextLine due to consecutive 5 empty lines in the given .*vtk file "); |
| 47 | } |
| 48 | |
| 49 | // Get a next line from a given *.vtk file |
| 50 | std::getline(ifs, line); |
| 51 | |
| 52 | // Check the End-of-File of the file |
| 53 | if (ifs.eof()) |
| 54 | { |
| 55 | itkExceptionMacro("Premature EOF in reading a line"); |
| 56 | } |
| 57 | |
| 58 | // Convert characters of the line to lowercas |
| 59 | if (lowerCase) |
| 60 | { |
| 61 | std::transform(line.begin(), line.end(), line.begin(), ::tolower); |
| 62 | } |
| 63 | |
| 64 | // Check an empty line with the size of a read line from *.vtk file |
| 65 | if (line.empty()) |
| 66 | { |
| 67 | return GetNextLine(ifs, line, lowerCase, ++count); |
| 68 | } |
| 69 | |
| 70 | return 1; |
| 71 | } |
| 72 | |
| 73 | bool |
| 74 | VTKImageIO::CanReadFile(const char * filename) |
no test coverage detected