[vtkusers] scalar input to vtkLookupTable

YaoHaofeng hfyao1983 at hotmail.com
Mon Mar 12 19:15:23 EDT 2007


Hi, I have now a structuredPoints image data, and an array of scalars corresponding to the color at each point of the image, I want to use vtkLookupTable to take the color array as input and color the points, what i did was set the color array as the scalar values of the PointData in structuredpoints, however I am not able to do that, the image is blue at all points, here is my code, could anybody have a look at the problem?thanks    vtkStructuredPoints *sp = vtkStructuredPoints::New();    int dim[3] = {dx, dy, dz};    sp->SetDimensions(dim);    sp->SetScalarType(VTK_FLOAT);    //sp->SetNumberOfScalarComponents(1);    sp->SetSpacing(1.75, 1.75, 2);    sp->SetOrigin(0, 0, 0);        sp->GetPointData()->SetScalars(scalar);    sp->GetPointData()->SetVectors(arr);    arr->Delete();    vtkThreshold *thres = vtkThreshold::New();    thres->SetInput(sp);    thres->ThresholdByUpper(10);    thres->AllScalarsOff();    thres->SetComponentModeToUseSelected();    thres->SetSelectedComponent(0);    vtkMaskPoints *mask = vtkMaskPoints::New();    mask->SetInputConnection(thres->GetOutputPort());    mask->SetOnRatio(30);    //mask->RandomModeOn();    vtkHedgeHog* hh  = vtkHedgeHog::New();    hh->SetInputConnection(mask->GetOutputPort());    hh->SetVectorModeToUseVector();    hh->SetScaleFactor(5);       vtkLookupTable *bwLut = vtkLookupTable::New();    bwLut->SetTableRange (0, 255);    bwLut->SetNumberOfColors(256);    bwLut->Build(); //effective built    vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();    mapper->SetLookupTable(bwLut);    mapper->SetInput(hh->GetOutput());    vtkProperty *prop = vtkProperty::New();    prop->SetOpacity(0.2);    vtkActor *actor = vtkActor::New();    actor->SetProperty(prop);    actor->SetMapper(mapper);        vtkRenderer *renderer = vtkRenderer::New();    vtkRenderWindow *renWin = vtkRenderWindow::New();    renWin->AddRenderer(renderer);    vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();    iren->SetRenderWindow(renWin);    renderer->AddActor(actor);    renderer->SetBackground(1,1,1);    //renderer->SetActiveCamera(aCamera);    renderer->ResetCamera();    renderer->GetActiveCamera()->Elevation(60.0);    renderer->GetActiveCamera()->Azimuth(30.0);    renderer->GetActiveCamera()->Zoom(2);    renWin->SetSize(600,600);    renWin->Render();    iren->Initialize();    iren->Start();
_________________________________________________________________
中国十大热门旅游景点
http://search.msn.com/results.aspx?q=%E4%B8%AD%E5%9B%BD%E5%8D%81%E5%A4%A7%E9%A3%8E%E6%99%AF&mkt=zh-CN&form=QBRE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070312/01596686/attachment.htm>


More information about the vtkusers mailing list