[vtkusers] Problems with visualizing multiple scalars on vtkDataSetMapper

Sarah Macumber S.Macumber at QuestReliability.com
Fri Jul 11 16:56:58 EDT 2008


Hi Gerrick thanks for the helpful reply, do you know why
 
   scalars.setArray(double, length,1);
   double [] range = scalars.getRange();
 
the range of the data is not updated after you have set a new array?  Even if I call ComputeRange I the value passed by from GetRange is not updated and I have to manually (for loop) compute my scalar range for the call,
 
mapper.SetScalarRange( range);

Thanks, Sarah

________________________________

From: Gerrick Bivins [mailto:gbivins at objectreservoir.com]
Sent: Fri 7/11/2008 1:33 PM
To: Sarah Macumber; VTK-users
Subject: Re: [vtkusers] Problems with visualizing multiple scalars on vtkDataSetMapper



No Prob.
I actually use vtkPointData interface  which inherits from
vtkDatasetAttribute rather than vtkFieldData
http://www.vtk.org/doc/nightly/html/classvtkDataSetAttributes.html

and then add my scalar arrays to that. For example:

 vtkFloatArray[] scalars = new vtkFloatArray[ numberOfScalars ];
...
       for( int f = 0; f < numberOfScalars; ++f )
       {
           
                scalars [f] = new vtkFloatArray();
                scalars [f].SetName( scalarComponents.get(f).GetName() );
                dataset.GetPointData().AddArray( scalars [f] );
       }
...

Gerrick

On 7/11/08 12:51 PM, "Sarah Macumber" <S.Macumber at QuestReliability.com>
wrote:

> Hey Gerrick thanks for the quick reply, can you please say more.  How do you
> connect your field data to begin with?  Also I am using a vtkDataSetMapper
> because I have 3D data and I think it may have issues with visualizing more
> than the 0th scalar.  When I try your code I get it to render correctly on the
> first pass but if I try to switch scalars I get a solid color rendering so it
> is not switching to the other field.
> 
> If you can send some code which shows how you connect your "field data" to
> your polydata / grid that would be very useful.
> 
> Thanks Sarah
>
> ________________________________
>
> From: Gerrick Bivins [mailto:gbivins at objectreservoir.com]
> Sent: Fri 7/11/2008 12:08 PM
> To: Sarah Macumber; VTK-users
> Subject: Re: [vtkusers] Problems with visualizing multiple scalars on
> vtkDataSetMapper
>
>
>
> Hi Sarah,
> How are you setting up your mapper?
>
> I use a lookup table and setup my mapper something like this:
> ...
>  lut = new vtkLookupTable();
>  lut.SetNumberOfTableValues(256);
>  lut.SetHueRange( 2.0f / 3.0f, 0.0f );
>       
>  mapper = new vtkPolyDataMapper();
>  mapper.SetLookupTable( lut );
>  mapper.SetScalarModeToUsePointFieldData();
> ...
>
> Then anytime I change the current scalar, I update the mapper:
>
> void updateCurrentScalarForMapper( String currentScalar,
>                                    double [] currentScalarRange )
> {
>    mapper.SelectColorArray( currentScalar );
>    mapper.SetScalarRange( currentScalarRange );
> }
>
>
>
> Gerrick
>
>
> On 7/11/08 11:46 AM, "Sarah Macumber" <S.Macumber at QuestReliability.com>
> wrote:
>
>> Hi,
>>
>> I have 2D / 3D data so I am using an vtkUnstructuredGrid & a vtkDataSetMapper
>> to visualize my data.  My data has several associated scalar values which I
>> want to be able to switch between for coloring purposes.  Calling SetScalars
>> with the new scalar value does not update the visualization pipeline as
>> described in this thread :
>> Grid.GetCellData().SetScalars(currentScalars);
>>
>> http://www.vtk.org/pipermail/vtk-developers/2007-September/004700.html
>> <http://www.vtk.org/pipermail/vtk-developers/2007-September/004700.html>
>>
>> but I still don't fully understand what to do about it.
>>
>> What is the best way to switch your viewable scalar value on a
>> vtkUnstructuredGrid?
>>
>> Thanks, Sarah
>>
>> _______________________________________________
>> This is the private VTK discussion list.
>> Please keep messages on-topic. Check the 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