[vtkusers] How to use vtkRibbonFilter to show a scalar field

Jean-Do Barnichon jeando.barnichon at free.fr
Mon Mar 24 05:27:54 EDT 2008


Hi Vidyadhar,
I just added
    SetValueRange(1,1)
to the code, but it does not change anything.
Actually, there is nothing wrong with the lookuptable, it 's somewhere 
else, obviously.
Thanks anyway
J-D

Vidyadhar a écrit :
> Hi,
> Apart from Hue and Saturation range, shouldn't you also be setting the 
> Value range (SetValueRange(double,double).
> HTH
> Vidyadhar
> ----- Original Message ----- From: "Jean-Do Barnichon" 
> <jeando.barnichon at free.fr>
> To: <vtkusers at vtk.org>
> Sent: Saturday, March 22, 2008 5:44 PM
> Subject: [vtkusers] How to use vtkRibbonFilter to show a scalar field
>
>
>> Hello all,
>>
>> I want to display a scalar field along a polyline, by making the 
>> color of each line segment depending on some color scale defined 
>> through a vtkLookupTable.
>> Actually, the scalars are known at the polyline nodes, and theses 
>> scalars are stored in a vtkFloatArray with 1 component.
>> Well the thing is that I do not get the ribbon in the display, so I 
>> guess I'm probably doing something wrong.
>> Note that if I set a given color for the whole actor (obviously it's 
>> not really what I want, but just for testing) by uncommenting the 
>> last line of the code snippet given below :
>>    RibonActor->GetProperty()->SetColor(1.,0.,0.);
>> it works in the sense that the ribbon is displayed in full red.
>>
>> Any idea where the problem might come from in my code ?
>> Thanks,
>> J-D
>>
>> Code Snippet
>> ...
>>
>> ///////////////////////////////////////////////////////////////////////////// 
>>
>>    // Create a lookup table that consists of the full hue circle 
>> (from HSV).
>>
>> ///////////////////////////////////////////////////////////////////////////// 
>>
>>    vtkLookupTable *hueLut = vtkLookupTable::New();
>>    hueLut->SetHueRange (160./240., 0.);
>>    hueLut->SetSaturationRange (1, 1);
>>    hueLut->SetTableRange (minEnergy, maxEnergy);
>>    hueLut->Build();
>>
>>
>> ///////////////////////////////////////////////////////////////////////////// 
>>
>>    // Add the traj in the vertical polyplane
>>
>> ///////////////////////////////////////////////////////////////////////////// 
>>
>>    vtkPoints* trajpoints  = vtkPoints::New(VTK_DOUBLE);
>>    vtkCellArray* trajpolyline  = vtkCellArray::New();
>>    // Fill trajpoints and trajpolyline
>> ...
>>
>>    // Set it to a polydata
>>    vtkPolyData *trajPD = vtkPolyData::New();
>>    trajPD->SetPoints(trajpoints);
>>    trajPD->SetLines(trajpolyline);
>>    trajPD->Update();
>>
>>    // Define filter
>>    vtkRibbonFilter *rf = vtkRibbonFilter::New();
>>    rf->SetInput(trajPD);
>>    rf->SetWidth(0.5);
>>    rf->SetWidthFactor(5);
>>
>>    // Link mapper
>>    vtkPolyDataMapper *RibonMapper = vtkPolyDataMapper::New();
>>    RibonMapper->SetInputConnection(rf->GetOutputPort());
>>    RibonMapper->SetScalarRange(minEnergy, maxEnergy);
>>    RibonMapper->SetLookupTable(hueLut);
>>    RibonMapper->ScalarVisibilityOn();
>>    RibonMapper->SelectColorArray("EnergyArray");
>>    RibonMapper->SetScalarModeToUsePointFieldData();
>>    RibonMapper->SetColorModeToMapScalars();
>>
>>    // Add actor
>>    vtkActor *RibonActor = vtkActor::New();
>>    RibonActor->SetMapper(RibonMapper);
>>    (RibonActor->GetProperty())->SetInterpolationToFlat();
>> //    RibonActor->GetProperty()->SetColor(1.,0.,0.);
>>
>>    // Do usual stuff
>> ...
>>
>> _______________________________________________
>> 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