How to set several scalars to vtkPoint ?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to set several scalars to vtkPoint ?

houssen
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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to set several scalars to vtkPoint ?

Bill Lorensen
Try
uGrid->GetPointdata()->AddArray(data2);


On Sun, Apr 2, 2017 at 12:01 PM, houssen <[hidden email]> 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
>



--
Unpaid intern in BillsBasement at noware dot com
_______________________________________________
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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to set several scalars to vtkPoint ?

houssen
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 <[hidden email]> 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/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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to set several scalars to vtkPoint ?

houssen
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 <[hidden email]> 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/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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to set several scalars to vtkPoint ?

Joachim Pouderoux
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 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

2017-04-02 13:12 GMT-04:00 houssen <[hidden email]>:
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 <[hidden email]> 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/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/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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to set several scalars to vtkPoint ?

Joachim Pouderoux
Sorry last sentence is was incomplete:

Save your grid and you will have both arrays saved in the vtk file output for sure - and you will see that data1 is tagged as the SCALAR array.

Joachim Pouderoux, PhD
Technical Expert - Scientific Computing Team
Kitware SAS

2017-04-04 16:05 GMT-04:00 Joachim Pouderoux <[hidden email]>:
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 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

2017-04-02 13:12 GMT-04:00 houssen <[hidden email]>:
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 <[hidden email]> 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/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/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

Loading...