Skip to content

Commit

Permalink
fix(SupportInputTypes): Avoid using null IO when not available
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Feb 15, 2023
1 parent 3eb2320 commit 4aa7620
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/itkSupportInputImageTypes.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ bool lexical_cast(const std::string &input, InterfaceImageType & imageType)
{
#ifndef ITK_WASM_NO_FILESYSTEM_IO
ImageIOBase::Pointer imageIO = ImageIOFactory::CreateImageIO(input.c_str(), CommonEnums::IOFileMode::ReadMode);
if (imageIO.IsNull())
{
std::cerr << "IO not available for: " << input << std::endl;
return false;
}
imageIO->SetFileName(input);
imageIO->ReadImageInformation();

Expand Down
5 changes: 5 additions & 0 deletions src/itkSupportInputMeshTypes.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ bool lexical_cast(const std::string &input, InterfaceMeshType & meshType)
{
#ifndef ITK_WASM_NO_FILESYSTEM_IO
MeshIOBase::Pointer meshIO = MeshIOFactory::CreateMeshIO(input.c_str(), CommonEnums::IOFileMode::ReadMode);
if (meshIO.IsNull())
{
std::cerr << "IO not available for: " << input << std::endl;
return false;
}
meshIO->SetFileName(input);
meshIO->ReadMeshInformation();

Expand Down
5 changes: 5 additions & 0 deletions src/itkSupportInputPolyDataTypes.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ bool lexical_cast(const std::string &input, InterfacePolyDataType & polyDataType
{
#ifndef ITK_WASM_NO_FILESYSTEM_IO
MeshIOBase::Pointer meshIO = MeshIOFactory::CreateMeshIO(input.c_str(), CommonEnums::IOFileMode::ReadMode);
if (meshIO.IsNull())
{
std::cerr << "IO not available for: " << input << std::endl;
return false;
}
meshIO->SetFileName(input);
meshIO->ReadMeshInformation();

Expand Down

0 comments on commit 4aa7620

Please sign in to comment.