Skip to content

Commit

Permalink
Merge pull request #1822 from ANTsX/ants_transform_check_cast
Browse files Browse the repository at this point in the history
ENH: Enhanced error checking
  • Loading branch information
cookpa authored Dec 17, 2024
2 parents 03135c4 + f3de125 commit 9c98082
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions Examples/antsTransformInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,15 @@ antsTransformInfo(std::vector<std::string> args, std::ostream * /*out_stream = n
{
using TransformType3D = itk::MatrixOffsetTransformBase<double, 3, 3>;
TransformType3D * itktx3d = dynamic_cast<TransformType3D *>((*it).GetPointer());
itktx3d->Print(std::cout);
std::cout << "Determinant: " << vnl_determinant(itktx3d->GetMatrix().GetVnlMatrix()) << std::endl;
if (itktx3d)
{
itktx3d->Print(std::cout);
std::cout << "Determinant: " << vnl_determinant(itktx3d->GetMatrix().GetVnlMatrix()) << std::endl;
}
else
{
(*it)->Print(std::cout);
}
}
}
else if (Dimension == 2)
Expand Down Expand Up @@ -175,8 +182,15 @@ antsTransformInfo(std::vector<std::string> args, std::ostream * /*out_stream = n
{
using TransformType2D = itk::MatrixOffsetTransformBase<double, 2, 2>;
TransformType2D * itktx2d = dynamic_cast<TransformType2D *>((*it).GetPointer());
itktx2d->Print(std::cout);
std::cout << "Determinant: " << vnl_determinant(itktx2d->GetMatrix().GetVnlMatrix()) << std::endl;
if (itktx2d)
{
itktx2d->Print(std::cout);
std::cout << "Determinant: " << vnl_determinant(itktx2d->GetMatrix().GetVnlMatrix()) << std::endl;
}
else
{
(*it)->Print(std::cout);
}
}
}
}
Expand Down

0 comments on commit 9c98082

Please sign in to comment.