[Insight-users] [vtkusers] Return itkObjects

Jothybasu Selvaraj jothybasu at gmail.com
Thu Jun 7 09:05:59 EDT 2012


Thanks!

Do I need to add the below typdef declaration in .h and .cxx

typedef itk::DefaultStaticMeshTraits<
vtkFloatingPointType, PointDimension, MaxCellDimension,
vtkFloatingPointType,vtkFloatingPointType >MeshTraits;

typedef itk::Mesh< vtkFloatingPointType,PointDimension,MeshTraits >MeshType;

Is there any example on how to declare  and return itk objects in classes?

Thanks again

Jothy

On Thu, Jun 7, 2012 at 1:56 PM, David Doria <daviddoria at gmail.com> wrote:

> > Which one do you mean MeshType::pointer or MeshType?
> >
> > Jothy
>
> MeshType is not an object, it is just a type (defined with 'typedef').
> MeshType::Pointer is then a smartpointer to an object of type
> 'MeshType'.
>
> David
>
> >> Hi,
> >> It is better to return smartpointers over regular pointers?
> >>
> >> Regards
>
> If you create the object as a:
>
> MeshType::Pointer myMesh = MeshType::New();
>
> in the function, you'll have to return a MeshType::Pointer, or the
> smart pointer will go out of scope and be destroyed. Actually, I think
> in ITK that is the only way to do it (I don't have any experience with
> itk::Mesh, but with itk::Image I don't think anything works correctly
> if you try to create a itk::Image<float, 2>* image = itk::Image<float,
> 2>::New() ?)
>
> David
>



-- 
Jothy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120607/059ec9c8/attachment.htm>


More information about the Insight-users mailing list