[vtk-developers] How to set several scalars to vtkPoint ?

Joachim Pouderoux joachim.pouderoux at kitware.com
Tue Apr 4 16:05:06 EDT 2017


Houssen,

PointData (as CellData) is basically a set of arrays where some of them can
be flagged as "the normal array", "the texture coordinates array", or even
"the default scalar array".
Only one of the arrays of the PointData can be tagged a the scalar array
but it does not mean you cannot have more than one array that could be
considered as a scalar array.
Those flags are used by some VTK filters/algorithms to determine on which
array to operate by default there are other mechanism (ie.
SetArrayToProcess) to specify the
array(s) to be used by a filter. See vtkDataSetAttributes
<http://www.vtk.org/doc/nightly/html/classvtkDataSetAttributes.html>for
more info on this mechanism.

As Bill said, try this:

  vtkSmartPointer<vtkIntArray> data1 = vtkSmartPointer<vtkIntArray>::New();
data1->SetName("data1");
  vtkSmartPointer<vtkIntArray> data2 = vtkSmartPointer<vtkIntArray>::New();
data2->SetName("data2");
  for (...) {data1->SetValue(idx, d1[i]); data2->SetValue(idx, d2[idx]) }
  uGrid->GetPointdata()->AddArray(data1);
  uGrid->GetPointdata()->AddArray(data2);
  uGrid->GetPointdata()->SetScalars(data1); // specify that data1 is the
array flagged as the scalar array

Save your grid and you will have both arrays saved but only "data1" in the
vtk file output for sure.

Best,

*Joachim Pouderoux*, PhD

*Technical Expert - Scientific Computing Team*
*Kitware SAS <http://www.kitware.fr>*


2017-04-02 13:12 GMT-04:00 houssen <houssen at ipgp.fr>:

> May use a lookup table ? Not familiar with that but seems it's not what I
> need ?!...
>
> Somebody knows how to get back to this broken link ttp://
> article.gmane.org/gmane.comp.lib.vtk.user/6761/match=points+scalar+color
> I got from http://public.kitware.com/pipermail/vtkusers/2003-August/
> 019748.html
>
>
> Le 2017-04-02 18:39, houssen a écrit :
>
>> KO ! Does not work (realize I tried this before !) => I only get
>> data1 OR data2 (never both of them) in the written .vtu file...
>> It is possible to make this work or to create a N-sized-vector.
>>
>> BTW, data1 is "pressure", data2 is "velocity" (that is data 1 and 2
>> are not related to each other)
>>
>> Franck
>>
>> Le 2017-04-02 18:24, Bill Lorensen a écrit :
>>
>>> Try
>>> uGrid->GetPointdata()->AddArray(data2);
>>>
>>>
>>> On Sun, Apr 2, 2017 at 12:01 PM, houssen <houssen at ipgp.fr> wrote:
>>>
>>>> Hello,
>>>>
>>>> How to set several scalars to vtkPoint ?
>>>>
>>>> Seems vtkDataPoint scratchs the previous scalar array ?!
>>>>
>>>> vtkSmartPointer<vtkIntArray> data1 = vtkSmartPointer<vtkIntArray>::
>>>> New();
>>>> data1->SetName("data1");
>>>> vtkSmartPointer<vtkIntArray> data2 = vtkSmartPointer<vtkIntArray>::
>>>> New();
>>>> data2->SetName("data2");
>>>> for (...) {data1->SetValue(idx, d1[i]); data2->SetValue(idx, d2[idx]) }
>>>> uGrid->GetPointdata()->SetScalars(data1); // OK
>>>> uGrid->GetPointdata()->SetScalars(data2); // data2 scratch data1 ?!
>>>>
>>>> uGrid->GetPointdata()->SetActiveScalar("data1") does not do what I
>>>> need :
>>>> seems that it activate data1 back but "scratch" data2 back.
>>>>
>>>> uGrid is a vtkUnstructuredGrid : the final goal is to write the grid to
>>>> a
>>>> file (with vtkWriter). In this file, I'd like to have BOTH data1 and
>>>> data2
>>>> for points.
>>>> I only get either one or the other... How to get both ?
>>>>
>>>> Also tried to create a N-sized-vector (N=2 or 4) to associate to the
>>>> vtkPoint : does not work as it seems vector dimension MUST be 3. I
>>>> somebody
>>>> knows a solution to attach a N-sized-vector to a vtkPoint, it could
>>>> solve my
>>>> problem
>>>>
>>>> Franck
>>>>
>>>> PS : found nothing relevant on the web, targetting VTK-7.
>>>> _______________________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Search the list archives at: http://markmail.org/search/?q=
>>>> vtk-developers
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://public.kitware.com/mailman/listinfo/vtk-developers
>>>>
>>>>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensou
> rce/opensource.html
>
> Search the list archives at: http://markmail.org/search/?q=vtk-developers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtk-developers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20170404/b1f59f40/attachment.html>


More information about the vtk-developers mailing list