[Insight-users] question about casting

Christoph Palm christoph.palm at web.de
Thu Aug 10 03:40:25 EDT 2006


Dear all,

I have a question about the casting in the itkCannyLevelsetFunction.txx.
There, we can find the following code:


  // Only cast if we need to
  if ( typeid(TImageType) == typeid(TFeatureImageType))
    {
    m_Canny->SetInput(tempFeature);
    }
  else
    {
    m_Caster->SetInput(tempFeature);
    m_Canny->SetInput(m_Caster->GetOutput());
    }

My problem: if I try to use and compile this with
TImageType != TFeatureImageType, the compiler
stops with an error message like
"casting not possible" in m_Canny->SetInput(tempFeature);
Obviously, at run-time there is no problem because of the
if-statement, but at compile-time, the compiler does not
know, that this casting problem never will occure.

Did I get someting wrong here?

Possible solution:
Omit the if-statement and use the caster in every case.
If a cast is not need, the casting is just bad for the
run-time but not wrong at all.

Any suggestions?

Best regards

Christoph 





More information about the Insight-users mailing list