[vtkusers] VTK 2d array?

David Doria daviddoria+vtk at gmail.com
Mon Oct 26 15:58:53 EDT 2009


On Mon, Oct 26, 2009 at 8:18 AM, Jeff Baumes <jeff.baumes at kitware.com> wrote:
>
> On Sat, Oct 24, 2009 at 4:01 PM, David Doria <daviddoria+vtk at gmail.com>
> wrote:
>>
>> Does VTK have anything like VBL's vbl_array_2d
>>
>> (http://public.kitware.com/vxl/doc/release/core/vbl/html/classvbl__array__2d.html)
>> that makes it easy to use a 2d array of data
>> ?
>
>
> Two options:
> 1. Any vtkAbstractArray subclass can work somewhat like a 2D array.
> Components are one dimension and Tuples another.
> 2. The new vtkArray and sublasses are N-dimensional array data structures
> that have a nice API that is perhaps closer to vbl_array_2d.
> Jeff
>

Great! This is perfect. In case anyone else is wondering, a 2D double
array can be created/used as follows:

vtkSmartPointer<vtkDenseArray<double> > array =
vtkSmartPointer<vtkDenseArray<double> >::New();
array->Resize(5,5);
array->SetValue(4,4, 5.0);
vtkstd::cout << array->GetValue(4,4) << vtkstd::endl;

Thanks,

David



More information about the vtkusers mailing list