`IO` `Mesh` modules reading methods missing reading ability check
Description
The IO modules itk::FreeSurferAsciiMeshIO, itk::FreeSurferBinaryMeshIO, itk::OBJMeshIO, and itk::OFFMeshIO classes' ReadMeshInformation methods do not take into account the information provided by the CanReadFile method, i.e. whether the file can be correctly interpreted by the class.
Impact analysis
Despite CanReadFile signaling a given file format as not readable for a given class in the above list (e.g an ASCII FreeSurfer *.fsa file, or an ASCII VTK file *.vtk for the itk::FreeSurferBinaryMeshIO class), when the same filename is set to the class instance (i.e. fsMeshIO->SetFileName(inputFileName)), the ReadMeshInformation method tries to read the data, and the IO instance data might get populated with unexpected values.
Calling CanReadFile at the beginning of the Read* methods would prevent this inconsistency. A boolean should probably be returned to tell the user whether reading has been successful.
Expected behavior
ReadMeshInformation methods do not attempt to read a file format that does not match the expected format.
In order to make sure that the Read* methods do first check whether the file format is readable, it would suffice to add, e.g. for the itk::FreeSurferMeshIO* test:
fsMeshIO->SetFileName(notAFsInputFileName);
ITK_TRY_EXPECT_EXCEPTION(fsMeshIO->ReadMeshInformation());
Actual behavior
ReadMeshInformation methods attempt to read a file format that CanReadFile tells they cannot read.
Versions
ITK master.
Additional Information
Related to PR #3403.