[Insight-users] Problem with itk templates....

Luis Ibanez luis . ibanez at kitware . com
Fri, 05 Sep 2003 16:16:01 -0400


Hi Sergio,

Your declaration looks good, except for the fact of missing
a "typename" keyword. You need this keyword because you are
declaring a type based on another type taken from a template
parameter of your class "myClass".

The code should look like

  template <unsigned int Dimension>
  class myClass
  {
    ...
    typedef itk::Mesh<float, Dimension> MeshType;
    typename MeshType::Pointer ptMesh;
  }

Note that compilers like VC++ 6.0 will not require
the use of the "typename" keyword.  Gcc on the other
hand will not let you get away without having this
keyword.

Then, in the .txx you create the mesh just like you did
in your initial message.  For the destructor, you don't
need to do anything.  That's the beauty of SmartPointers.

The SmartPointer will delete your mesh when the
reference counting of the object gets to zero.

You will find details about SmartPointers and the ITK
architecture in the SoftwareGuide
http://www . itk . org/ItkSoftwareGuide . pdf


Please let us know if you have further questions.


   Thanks

   Luis

----------------------
Sergio Andrés wrote:

>Hi all,
>
>My problem is about itk templates...
>
>How could I create a class that have a pointer to a itk::Mesh...??
>
>I have create something like this:
>
>-- myClass.h --------------------
>
>  template <unsigned int Dimension>
>  class myClass
>  {
>    ...
>    typedef itk::Mesh<float, Dimension> MeshType;
>    MeshType::Pointer ptMesh;
>  }
>---------------------------------
>
>It exists also a file named myClass.txx, where class definitions are.
>In this file, there is a line in the class contructor method:
>
>  	this->ptMesh = MeshType::New();
>
>
>(I am not sure if that is the rigth way to do it...)
>
>
>** As I create a new itk::Mesh, in the constructor, I want to delete it in the
>destructor method but I don't know how to do that, because an error occurs if 
>I use 'Delete()' with itk::Mesh.
>
>
>Could anyone give me a solution ???
>
>Thanks a lot.
>
>Sergio.
>
>
>
>
>
>___________________________________________________
>Yahoo! Messenger - Nueva versión GRATIS
>Super Webcam, voz, caritas animadas, y más...
>http://messenger . yahoo . es
>_______________________________________________
>Insight-users mailing list
>Insight-users at itk . org
>http://www . itk . org/mailman/listinfo/insight-users
>
>  
>