[vtkusers] Can not point to part of vtkDoubleArray using GetTuple(Id) correctly.
Paul Edwards
paul.m.edwards at gmail.com
Sun Mar 9 18:46:35 EDT 2014
The pointer is only valid until another method is called (see
http://www.vtk.org/doc/nightly/html/classvtkDataArray.html#aca11c70280dad75aabbe5747c55c6919).
The class stores the double data internally and it is copied there and the
pointer returned. So, you will not be getting around copying data and
would probably be best using GetTuple(i,double*). If you really need to
stop any memory copying you could use vtkAbstractArray::GetVoidPointer.
Regards,
Paul
On 8 March 2014 17:00, Sunrise <helios.corona at gmail.com> wrote:
> I have a vtkDoubleArray, and I want to create a double array of pointers
> that point to some subset of tuples of the vtkDoubleArray. I do not want
> to use GetComponent(i,j) or GetTuple(i,double) and allocate new memory
> for the subset of the original array, rather, I would like to just point to
> the original array with an array of pointers, and getting the pointers with
> GetTuple(Id).
>
> For example, let vtkDoubleArray *vtkArray has 4 tuples and 3 components,
> and Initialized as
>
> Assume vtkArray has the following 4 tuples:
> Tuple0: {0,1,2}
> Tuple1: {3,4,5}
> Tuple2: {6,7,8}
> Tuple3: {9,10,11}
>
> Now I create double *SubArray[2]. Then I want to point to tuples 1 and 3
> of the vtkArray:
>
> double *SubArray[2];
> SubArray[0] = vtkArray->GetTuple(0);
>
> Now SubArray[0] should be {0,1,2}.
>
> Adding pointer of tuple 3
> SubArray[1] = vtkArray->GetTuple(3);
>
> Here is the problem that I have: After setting pointer of Tuple3 to the
> SubArray[1], the SubArray[0] is changed to point to Tuple3 too. It means
>
> SubArray[0] = {9,10,11} // points to Tuple 3 not Tuple 1
> SubArray[1] = {9,10,11}
>
> How can I fix this?
>
> Thanks,
> Sia
>
> _______________________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140309/f7e46ea4/attachment.html>
More information about the vtkusers
mailing list