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

Arvind Rao arvind.sbia at gmail.com
Wed Apr 4 20:57:44 EDT 2012


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120404/f24b4926/attachment.htm>


More information about the Insight-users mailing list