[Insight-users] itkVectorContainer and itkimageMaskSpatialObject

David Doria daviddoria at gmail.com
Thu May 16 12:56:42 EDT 2013


On Thu, May 16, 2013 at 12:18 PM, Luke Bloy <luke.bloy at gmail.com> wrote:
> Hi everyone,
>
> I'm interested in storing a number of itkImageMaskSpatial objects into a
> vector like structure, so that I can iterator through them. I thought that
> itkVectorContainer was the correct way to do this. however I can't seem to
> get it to compile. for instance the following example won't compile
>
> #include <itkVectorContainer.h>
> #include <itkImageMaskSpatialObject.h>
>
> int main(int, char*[])
> {
>   typedef itk::ImageMaskSpatialObject<3>                      ImageMaskType;
>   typedef itk::VectorContainer<int, ImageMaskType>
> MaskContainerType;
>
>   MaskContainerType::Pointer masks = MaskContainerType::New();
>   return EXIT_SUCCESS;
> }
>
> The error seems to boil down to this...
>
> /opt/ITK/InsightToolkit-4.2.0/Modules/Core/SpatialObjects/include/itkImageMaskSpatialObject.hxx:37:
> error: ‘itk::ImageMaskSpatialObject<TDimension>::~ImageMaskSpatialObject()
> [with unsigned int TDimension = 3u]’ is protected
>
> My question is should i just use another vector like object to hold my
> ImageMasks?
>
> -Thanks.
> Luke


You just need to change

typedef itk::VectorContainer<int, ImageMaskType>            MaskContainerType;

to

typedef itk::VectorContainer<int, ImageMaskType::Pointer>
MaskContainerType;

and it will compile.

Alternatively, you can also just use an std::vector<ImageMaskType::Pointer>.

David


More information about the Insight-users mailing list