[Insight-users] Extending a Transform?

motes motes mort.motes at gmail.com
Sat Feb 20 14:51:11 EST 2010


I am trying to write a transform that extends
iktBsplineDeformableTransform. I have just copied the code from the
code/common folder and renamed to BSplineDeformableTransform in the .h
and .txx file to MyTransform and changed the class declaration to:

template <
    class TScalarType = double,          // Data type for scalars
    unsigned int NDimensions = 3,        // Number of dimensions
    unsigned int VSplineOrder = 3 >      // Spline order
class ITK_EXPORT  MyTransform : public BSplineDeformableTransform<
TScalarType, NDimensions, NDimensions >
{
public:

I then create the transform like:

#include "MyTransform.h"
int main(){
  typedef itk::MyTransform<double,3,3> Transform;
  Transform transform;
  return 0;
}




But when I compile I get:


mort at mort-desktop:~/test/src/benchmark/build/release$ make
[100%] Building CXX object CMakeFiles/benchmark.dir/main.cpp.o
/home/mort/test/src/benchmark/MyTransform.txx: In function ‘int main()’:
/home/mort/test/src/benchmark/MyTransform.txx:16: error:
‘itk::MyTransform<TScalarType, NDimensions,
VSplineOrder>::MyTransform() [with TScalarType = double, unsigned int
NDimensions = 3u, unsigned int VSplineOrder = 3u]’ is protected
/home/mort/test/src/benchmark/main.cpp:5: error: within this context
/home/mort/test/src/benchmark/MyTransform.txx:116: error:
‘itk::MyTransform<TScalarType, NDimensions,
VSplineOrder>::~MyTransform() [with TScalarType = double, unsigned int
NDimensions = 3u, unsigned int VSplineOrder = 3u]’ is protected
/home/mort/test/src/benchmark/main.cpp:5: error: within this context
In file included from /home/mort/test/src/benchmark/MyTransform.h:383,
                 from /home/mort/test/src/benchmark/main.cpp:1:
/home/mort/test/src/benchmark/MyTransform.txx: In constructor
‘itk::MyTransform<TScalarType, NDimensions,
VSplineOrder>::MyTransform() [with TScalarType = double, unsigned int
NDimensions = 3u, unsigned int VSplineOrder = 3u]’:
/home/mort/test/src/benchmark/main.cpp:5:   instantiated from here
/home/mort/test/src/benchmark/MyTransform.txx:17: error: type
‘itk::Transform<double, 3u, 3u>’ is not a direct base of
‘itk::MyTransform<double, 3u, 3u>’
make[2]: *** [CMakeFiles/benchmark.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/benchmark.dir/all] Error 2
make: *** [all] Error 2
mort at mort-desktop:~//test/src/benchmark/build/release$

These errors are related to the 'protected' visibility. But why this
error when I extend the BSplineDeformableTransform class?

This error:

‘itk::Transform<double, 3u, 3u>’ is not a direct base of
‘itk::MyTransform<double, 3u, 3u>’

also indicates that its no legal to extend from BSplineDeformableTransform.

Any ideas?


More information about the Insight-users mailing list