[vtkusers] reset scalars
Eric E. Monson
emonson at cs.duke.edu
Mon Jul 9 09:30:08 EDT 2012
Hello Gonzalo,
vtkDataSetAttributes like vtkCellData and vtkPointData can have many attribute arrays, like scalars and vectors and other sorts of multi-component vtkDataArray instances attached to them, but they also have the concept of an "Active" scalar or vector, etc. Some routines work on the active attribute, so for those you want to set which attribute array is to be considered the active one, but the rest can still be attached.
The SetScalars method is a shortcut for doing AddArray(vtkDataArray *da) and then SetActiveScalars(const char *name). So, first of all, your sequence of SetScalars calls should just add both arrays and end up with array2 as the "active" scalar. Secondly, there is a compliment of AddArray called RemoveArray() which takes either a name or an index.
So, I make it a point to only use AddArray() when I'm adding any type of array to vtkPointData or vtkCellData, and then explicitly use SetActiveScalars() or SetActiveVectors(), etc, when I need to set the "active" one. This works well and is more readable. In your case you could just add all of your arrays and then on each iteration if you really need to set the active scalars you can just call SetActiveScalars() with the proper name, or else you can just use surface->GetCellData()->GetArray("name") or (index) and not worry about what is considered the active scalars at all.
The docs for vtkDataSetAttributes is here:
http://www.vtk.org/doc/nightly/html/classvtkDataSetAttributes.html
along with links to vtkFieldData which is where AddArray is defined.
Hope this helps,
-Eric
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
Eric E Monson
Duke Visualization Technology Group
On Jul 9, 2012, at 9:01 AM, Gonzalo Amadio wrote:
> Hello,
>
> Is there a good way of deleting scalars from a polydata?
>
>
> My problem is that I am iterating over the cells of a polydata, and in each iteration I want to use a different set of scalars.
> So, in each iterarion I do :
>
> surface->GetCellData()->SetScalars(myScalarArray);
>
> But I think I have to delete the scalars of the previous iteration, so I have only the last array of scalars.
>
>
>
> Another point of view of the question would be :
> doing
>
> surface->GetCellData()->SetScalars(array1);
> surface->GetCellData()->SetScalars(array2);
>
> is the same as only
>
> surface->GetCellData()->SetScalars(array2); ?
>
> or the result of the first case would lead to have the scalars in "array1" plus the scalars in "array2" and not only the scalars in "array2".
>
> Thank you.!
>
> --
> --------
> Gonzalo Amadio
>
> _______________________________________________
> 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