[vtkusers] Creating an array of objects of a VTK-class

Bill Lorensen bill.lorensen at gmail.com
Sat Aug 8 13:38:37 EDT 2009


You could use and std::vector<vtkRectilinearGridReader *> Reader;
for(int nr = 0; nr < number; nr++)
  {
  Reader.push_back(vtkRectilinearGridReader::New());
  }

or you could use the older C-style with malloc


On Sat, Aug 8, 2009 at 12:57 PM, Dmitri Danewitz<d.danewitz at yahoo.de> wrote:
> Hello,
>
> I'm trying to create multiple objects of the vtkRectilinearReader class. It
> works fine, if I do it like this:
>
> const int number = 4;
>   vtkRectilinearGridReader *Reader[number];
>   for(int nr = 0; nr < number; nr++)
>   {
>    Reader[nr] = vtkRectilinearGridReader::New();
>   }
>
>
> But when "number" is not a constant, this doesn't work. Is there a away to
> do this without having "number" to be a constant?
>
> Thanks
> Dmitri
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list