Page MenuHomePhabricator

ITKv4 compatibility: Number of Inputs and Outputs in the filter pipeline
Closed, WontfixPublic

Description

The methods SetNumberOfInputs and SetNumberOfOutputs are deprecated, and using them does not ensure that the output objects are generated correctly before the filter processing is executed (causing lots of errors).

The reasons why these methods are now deprecated can be found in the ITKv4 migration guide (http://itk.org/migrationv4/index.php?action=artikel&cat=3&id=121&artlang=en&highlight=setnumberofoutputs).

These methods should be replaced by SetNumberOfIndexedInputs and SetNumberOfIndexedOutputs.

Event Timeline

Some other API change examples:

Broken API Sample Code:
const_cast<mitk::BaseProcess*>(this)->RemoveOutput(outputs[idx]);

New API Sample Code:
const_cast<mitk::BaseProcess*>(this)->RemoveOutput(idx);

Broken API Sample Code:
warper->SetDeformationField( field );

New API Sample Code:
warper->SetDisplacementField( field );

Broken API Sample Code:
this->SetNumberOfOutputs( num );

New API Sample Code:
this->SetNumberOfIndexedOutputs( num );

Old API Sample Code:
Set_vnl_vector(...

New API Sample Code:
SetVnlVector(...

Broken API Sample Code:
Get_vnl_vector(...

New API Sample Code:
GetVnlVector(...

Broken API Sample Code:
itk::Math::RoundHalfIntegerUp( ... );

New API Sample Code:
itk::Math::RoundHalfIntegerUp<int, mitk::ScalarType>( ... );

Broken API Sample Code:
this->SetNumberOfInputs( num );

New API Sample Code:
this->SetNumberOfIndexedInputs( num );

not so sure about this one:

"do not use mitkCloneMacro and own Clone() implementations"

examples:

mitkCloneMacro(PointSet);
AffineGeometryFrame3D::Pointer Clone() const;
/*
AffineGeometryFrame3D::Pointer
PlaneGeometry::Clone() const
{

Self::Pointer newGeometry = new PlaneGeometry(*this);
newGeometry->UnRegister();
return newGeometry.GetPointer();

}
*/

same throughout the toolkit ...

Broken API Sample Code:

void mitk::SurfaceToSurfaceFilter::RemoveInputs(mitk::Surface* input)
{

this->RemoveInput(input);

}

New API Sample Code:

void mitk::SurfaceToSurfaceFilter::RemoveInput(unsigned int idx)
{

this->RemoveInput(idx);

}

Broken API Sample Code:
vec3d_units = GetIndexToWorldTransform()->BackTransform(vec3d_mm);

New API Sample Code:
vec3d_units = GetIndexToWorldTransform()->GetInverseTransform()->TransformVector(vec3d_mm);

SetParameters() and SetFixedParameters() are now pure virtual in itk::Transform

Therefore, a workaround in class VtkAbstractTransform : public itk::Transform<TScalarType, 3, 3>

could be:

virtual void SetParameters(const ParametersType &) {};
virtual void SetFixedParameters(const ParametersType &) {};

a tough one:

2>mitkLog.obj : warning LNK4217: locally defined symbol ?Unlock@SimpleFastMutexLock@itk@@QBEXXZ (public: void thiscall itk::SimpleFastMutexLock::Unlock(void)const ) imported in function "public: virtual void thiscall mitk::LoggingBackend::ProcessMessage(class mbilog::LogMessage const &)" (?ProcessMessage@LoggingBackend@mitk@@UAEXABVLogMessage@mbilog@@@Z)
2>mitkLog.obj : warning LNK4217: locally defined symbol ?GetInstance@OutputWindow@itk@@SA?AV?$SmartPointer@VOutputWindow@itk@@@2@XZ (public: static class itk::SmartPointer<class itk::OutputWindow> cdecl itk::OutputWindow::GetInstance(void)) imported in function "public: virtual void thiscall mitk::LoggingBackend::ProcessMessage(class mbilog::LogMessage const &)" (?ProcessMessage@LoggingBackend@mitk@@UAEXABVLogMessage@mbilog@@@Z)
2>mitkLog.obj : warning LNK4217: locally defined symbol ?Lock@SimpleFastMutexLock@itk@@QBEXXZ (public: void thiscall itk::SimpleFastMutexLock::Lock(void)const ) imported in function "public: virtual void thiscall mitk::LoggingBackend::ProcessMessage(class mbilog::LogMessage const &)" (?ProcessMessage@LoggingBackend@mitk@@UAEXABVLogMessage@mbilog@@@Z)
2>mitkLog.obj : warning LNK4217: locally defined symbol ??0SimpleFastMutexLock@itk@@QAE@XZ (public: thiscall itk::SimpleFastMutexLock::SimpleFastMutexLock(void)) imported in function "void cdecl `dynamic initializer for 'logMutex''(void)" (??ElogMutex@@YAXXZ)
2>mitkLog.obj : warning LNK4217: locally defined symbol ??1SimpleFastMutexLock@itk@@QAE@XZ (public:
thiscall itk::SimpleFastMutexLock::~SimpleFastMutexLock(void)) imported in function "void cdecl `dynamic atexit destructor for 'logMutex''(void)" (??FlogMutex@@YAXXZ)

(In reply to comment #2)

Broken API Sample Code:
warper->SetDeformationField( field );

New API Sample Code:
warper->SetDisplacementField( field );

http://itk.org/migrationv4/index.php?sid=4049&lang=en&action=artikel&cat=3&id=90&artlang=en

(In reply to comment #10)

Broken API Sample Code:
vec3d_units = GetIndexToWorldTransform()->BackTransform(vec3d_mm);

New API Sample Code:
vec3d_units =
GetIndexToWorldTransform()->GetInverseTransform()->TransformVector(vec3d_mm);

another case:

Broken API Sample Code:

Vector3D vec3d_units;
vec3d_units = GetIndexToWorldTransform()->BackTransform(vec3d_mm);
vec3d_units[2] = 0;
projectedVec3d_mm = GetIndexToWorldTransform()->TransformVector(vec3d_units);

Point3D pt3d_units;
pt3d_units = GetIndexToWorldTransform()->BackTransformPoint(atPt3d_mm);
return const_cast<BoundingBox*>(m_BoundingBox.GetPointer())->IsInside(pt3d_units);

New API Sample Code:

Vector3D vec3d_units;
vec3d_units = GetIndexToWorldTransform()->GetInverseTransform()->TransformVector(vec3d_mm);
vec3d_units[2] = 0;
projectedVec3d_mm = GetIndexToWorldTransform()->TransformVector(vec3d_units);

Point3D pt3d_units;
pt3d_units = GetIndexToWorldTransform()->GetInverseTransform()->TransformPoint(atPt3d_mm);
return const_cast<BoundingBox*>(m_BoundingBox.GetPointer())->IsInside(pt3d_units);

Broken API Sample Code:

template <class TScalarType>
itk::VtkAbstractTransform<TScalarType>::VtkAbstractTransform() :

Superclass(3, 0)

New API Sample Code:

template <class TScalarType>
itk::VtkAbstractTransform<TScalarType>::VtkAbstractTransform() :

Superclass(3)

Broken API Sample Code:
template <class TScalarType>
itk::VtkAbstractTransform<TScalarType>::VtkAbstractTransform() :

Superclass(3, 0)

New API Sample Code:
template <class TScalarType>
itk::VtkAbstractTransform<TScalarType>::VtkAbstractTransform() :

Superclass(3)

Broken API Sample Code:

itk::ImageRegionConstIterator<ImageType>

iter(image, image->GetLargestPossibleRegion());

iter = itimage.Begin();

New API Sample Code:

itk::ImageRegionConstIterator<ImageType>

iter(image, image->GetLargestPossibleRegion());

itimage.GoToBegin();

itimage.GoToBegin();

iter.GoToBegin();

I also experienced the same "Multiple symbol definition" link error as in here:

http://cmake.3232098.n2.nabble.com/Multiple-symbol-definition-at-linker-stage-with-ITK4-tt7580229.html#none

workaround is to add /FORCE:MULTIPLE in CMAKE_SHARED_LINKER_FLAGS

kislinsk claimed this task.
kislinsk added a subscriber: kislinsk.
This task was automatically closed because it wasn't updated at least since July 2016 (over 2 years). Please re-open this task if you think that it is still relevant. This most probably means that you will resolve it.