You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears that AdvancedCombinationTransform::GetNumberOfTransforms() returns zero when the initial transform is not a combination transform. Looking at the original commit (2fc2c49, November 14, 2013):
num += initialTransformCasted->GetNumberOfTransforms() + 1;
}
}
else
{
num++;
}
}
return num;
} // end GetNumberOfTransforms()
Simplified as follows (by the first commit of pull request #925):
if (GetCurrentTransform())
{
if (const InitialTransformConstPointer initialTransform = GetInitialTransform())
{
if (const auto initialTransformCasted = dynamic_cast<const Self *>(initialTransform.GetPointer()))
{
return initialTransformCasted->GetNumberOfTransforms() + 1;
}
}
else
{
return 1;
}
}
return 0;
You see, if the dynamic_cast<const Self *> fails, the function falls back to just return 0. Is that OK? Because it seems to me that it should return 2 instead.
Example unit test:
const auto Dimension = 2U;
using TranslationTransformElastixType = elx::TranslationTransformElastix<ElastixType<Dimension>>;
using AdvancedCombinationTransformType = TranslationTransformElastixType::Superclass1;
using AdvancedTransformType = AdvancedCombinationTransformType::Superclass;
const auto TranslationTransformElastix = TranslationTransformElastixType::New();
const auto initialTranslationTransformElastix = TranslationTransformElastixType::New();
// The following expectation passes as well, no problem.
EXPECT_EQ(TranslationTransformElastix->GetNumberOfTransforms(), 1);
TranslationTransformElastix->AdvancedCombinationTransformType::SetInitialTransform(
initialTranslationTransformElastix);
// The following expectation passes, no problem.
EXPECT_EQ(TranslationTransformElastix->GetNumberOfTransforms(), 2);
const auto advancedTranslationTransform = itk::AdvancedTranslationTransform<double, Dimension>::New();
TranslationTransformElastix->AdvancedCombinationTransformType::SetInitialTransform(advancedTranslationTransform);
// The following expectation fails, because GetNumberOfTransforms() returns zero!!!
EXPECT_EQ(TranslationTransformElastix->GetNumberOfTransforms(), 2);
The text was updated successfully, but these errors were encountered:
@mstaring@stefanklein Could it be that in practice the initial transform is always also a combination transform? (Meaning that the dynamic_cast<const Self *>(initialTransform.GetPointer()) always returns a non-null pointer anyway?)
It appears that
AdvancedCombinationTransform::GetNumberOfTransforms()
returns zero when the initial transform is not a combination transform. Looking at the original commit (2fc2c49, November 14, 2013):elastix/src/Common/Transforms/itkAdvancedCombinationTransform.hxx
Lines 105 to 132 in 2fc2c49
Simplified as follows (by the first commit of pull request #925):
You see, if the
dynamic_cast<const Self *>
fails, the function falls back to justreturn 0
. Is that OK? Because it seems to me that it should return2
instead.Example unit test:
The text was updated successfully, but these errors were encountered: