Hello everyone,
I have some question regarding the memory management.
I want to separate my application in multiple modules and manage all itk::Image PixelType available.
To store an itk::Image inside a itk::DataObject with the Pixel type and the Image Dimension then I do some cast to get back my image when I call a filter.
This is an example of what I currently do for my filters:
template<typename Image>
void doFilter(const itk::DataObject::Pointer & input, itk::DataObject::Pointer & output)
{
using Filter = itk::FooFilter<Image>;
typename Filter::Pointer filter = Filter::New();
filter->SetInput(static_cast<Image*>(input.GetPointer());
filter->Update();
output = filter->GetOutput();
}
I have some memory issues (empty images, segmentation fault…), so I suspect that I don’t understand quite well the memory management of itk smart pointer. I read the documentation (https://itk.org/ItkSoftwareGuide.pdf section 3.2.3 and 3.2.4) but I don’t find anything on copy of itk smart pointer to a parent class smart pointer.
Can anyone tell me what I do wrong or not please?
Thank you.
Romain