[vtkusers] How to use LookupTable correctly?
Khew Sing Yoong
sykhew at simbiosys.ca
Fri Jun 23 12:35:06 EDT 2006
Tried it.. doesn't work.. still the same behaviour.. i am guessing it
might be something to do with the mapper that isn't set correctly???
SY
Paul Tait - OPES wrote:
>My two color code looks like this
>
> lut = vtkLookupTable::New();
> lut->SetNumberOfTableValues(2);
> lut->SetTableValue(0, 0.8, 0.8, 0.8);
> lut->SetTableValue(1, 0.0, 1.0, 1.0);
> lut->Build();
>
>-----Original Message-----
>From: vtkusers-bounces+paul=opes.com.au at vtk.org
>[mailto:vtkusers-bounces+paul=opes.com.au at vtk.org] On Behalf Of Khew Sing
>Yoong
>Sent: Friday, 23 June 2006 1:28 AM
>To: vtkusers at vtk.org
>Subject: [vtkusers] How to use LookupTable correctly?
>
>
>Hi there,
>
>I am fairly new to vtk and I am having problems drawing lines with
>colours using a lookup table. I am using VTK 5.0.
>
>In a snapshot: create a vtkPolyData, assign 3 points, and connect them
>with 2 lines in the form of an L shape.
>I want to color the first point Red, second Green, third Blue, hence I
>assign 0, 1, 2 as scalar values for each point respectively. Then I created
>a lookup table for the PolyDataMapper with 0,1,2 mapping
>to RGB.
>Connect the pipe and the results weren't as expected. Green never shows up!
>
>Can somebody be kind enough to help me out here a little? Maybe I missed
>something? Thank you in advance! :)
>
>SY
>
>
> vtkPolyData * data = vtkPolyData::New();
> vtkPoints *Points = vtkPoints::New();
> vtkCellArray *Lines= vtkCellArray::New();
> vtkIntArray *color = vtkIntArray::New();
> Points->Allocate(3);
> Lines->Allocate(2);
> color->SetName("Color");
> color->SetNumberOfComponents(1);
>
> Points->InsertNextPoint(0, 1, 0);
> Points->InsertNextPoint(0, 0, 0);
> Points->InsertNextPoint(1, 0, 0);
> vtkIdType line[2];
> line[0] = 0;
> line[1] = 1;
> Lines->InsertNextCell(2, line);
> line[0] = 1;
> line[1] = 2;
> Lines->InsertNextCell(2, line);
> color->InsertNextValue(0);
> color->InsertNextValue(1);
> color->InsertNextValue(2);
> data->SetPoints(Points);
> data->SetLines(Lines);
> data->GetPointData()->SetScalars(color);
> data->Squeeze();
>
> vtkPolyDataMapper * mapper = vtkPolyDataMapper::New();
> mapper->SetInput(data);
> mapper->SetScalarVisibility(1);
>
> vtkLookupTable * lut = vtkLookupTable::New();
> lut->SetTableRange(0, 3);
> lut->SetNumberOfColors(3);
> lut->Build();
> lut->SetTableValue(0, 1, 0, 0, 1);
> lut->SetTableValue(1, 0, 1, 0, 1);
> lut->SetTableValue(2, 0, 0, 1, 1);
>
> mapper->SetLookupTable(lut);
> mapper->SetScalarModeToUsePointFieldData();
> mapper->SetColorModeToMapScalars();
> mapper->SelectColorArray("Color");
>
> vtkActor * actor = vtkActor::New();
> actor->SetMapper(mapper);
> actor->GetProperty()->SetLineWidth(2);
> ren1->AddActor(actor); _______________________________________________
>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