[Insight-users] use of std::vector with ITK typedefs

Matt McCormick matt.mccormick at kitware.com
Wed Apr 4 22:53:50 EDT 2012


Hi Arvind,

It looks like the error is happening inside ReadStreamFile, so please
post how that is declared and defined.

Thanks,
Matt

On Wed, Apr 4, 2012 at 8:57 PM, Arvind Rao <arvind.sbia at gmail.com> wrote:
> Hi all,
>
> In order to read-in a variable number of points from a file I want to use a
> dynamically sized container like STD::VECTOR. The points are stored like so:
> ( points is the vector I use )
>
>       typedef itk::Image< itk::Vector<ComponentType, Dimension>, Dimension>
>                                 PeakImageType;
>       typedef PeakImageType::PixelType
>                                                        DirectionType;
>       std::vector<DirectionType>
>                                                                points
>
> However, the following try-catch statement gives, at run-time, "bad_alloc
> caught: St9bad_alloc"
>
>       try
>       {
>                 std::vector<DirectionType> points;
>                 ReadStreamFile<DirectionType>( streamArg.getValue(), points
> );
>       }
>      catch (std::bad_alloc& ba)
>       {
>                 std::cerr << "bad_alloc caught: " << ba.what() << std::endl;
>                 return 0;
>       }
>
> So, what is going on? Its seems like POINTS is not being allocated properly,
> but I'm sure how to fix this.
>
> Thanks for any help you can provide.
>
>
> --
> Arvind S. Rao, PhD
> Section of Biomedical Image Analysis
> Department of Radiology
> University of Pennsylvania
> 3600 Market Street, Suite 380
> Philadelphia, PA 19104
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>


More information about the Insight-users mailing list