[vtkusers] color/points dont appear

Amy Henderson amy.henderson at kitware.com
Tue Feb 3 08:58:47 EST 2004


Hi Lisa,

One reason I see for why this code won't work is that the call to SetCells 
on the vtkUnstructuredGrid happens before the cell array has been filled 
in.  In the SetCells call, vtkUnstructuredGrid assumes that the cell array 
already contains useful information.  Alternatively, you could use the 
InsertNextCell method of vtkUnstructuredGrid to add cells to your data set.

- Amy

At 12:00 AM 2/3/2004 +0000, lisa hughes wrote:
>hi
>for some reason, i just get a black screen when i run the code below..
>I have some random points which i want to display, and color code them 
>somehow - for now i've left them to be color mapped to some constant
>so i used unstructured grid and vertex cells to represent the data
>whats wrong with the below code??
>
>
>
>
>vtkLookupTable *lut = vtkLookupTable::New();
>vtkPoints *SampleVolPoints =  vtkPoints::New();
>vtkUnstructuredGrid *SampleVolGrid = vtkUnstructuredGrid::New();
>vtkCellArray *SampleVolCellarray = vtkCellArray::New();
>vtkActor *SampleVolUgridactor =  vtkActor::New();
>vtkDataSetMapper *SampleVolDatasetmapper = vtkDataSetMapper::New();
>vtkVertex *SampleVolVertex = vtkVertex::New();
>vtkFloatArray *fltarray = vtkFloatArray::New();
>vtkFloatArray *cellfltarray = vtkFloatArray::New();
>Ren1= vtkRenderer::New();
>RenWin = vtkRenderWindow::New();
>Iren = vtkRenderWindowInteractor::New();
>  int point, pnt[1] ;
>  float xyz[3];
>
>  lut->SetAlphaRange(0,1);
>  lut->SetHueRange(0, 1);
>  lut->SetNumberOfColors(256);
>  lut->SetSaturationRange(0, 1);
>  lut->SetValueRange(0, 1);
>  lut->SetTableRange(0,1);
>  lut->Build();
>
>
>int *vertexTypes = new int[NumSearchPoints];
>  for ( int k =0; k<NumSearchPoints; k++)
>  {
>       vertexTypes[k] = VTK_VERTEX;
>  }
>
>
>fltarray->SetNumberOfValues(NumSearchPoints);
>SampleVolGrid->Allocate(NumSearchPoints);
>SampleVolPoints->SetNumberOfPoints(NumSearchPoints);
>SampleVolGrid->SetCells(vertexTypes, SampleVolCellarray);
>
>SampleVolDatasetmapper->SetInput( SampleVolGrid );
>SampleVolDatasetmapper->SetLookupTable( lut );
>SampleVolDatasetmapper->SetScalarRange(0,2);
>SampleVolUgridactor->SetMapper(SampleVolDatasetmapper);
>Ren1->AddActor( SampleVolUgridactor );
>RenWin->AddRenderer( Ren1 );
>RenWin->SetSize( 600, 600 );
>RenWin->SetInteractor(Iren);
>
>while(1)
>{
>    for ( int point = 0; point<NumSearchPoints; point++)
>    {
>       xyz[0] = point/2; //x
>       xyz[1] = point/3; //y
>       xyz[2] = point/4; //z
>
>        pnt[0] = point;
>        SampleVolPoints->SetPoint(point, xyz);
>        fltarray->SetValue(point, 1.5);
>        SampleVolCellarray->InsertNextCell( 1, pnt);
>     }
>
>SampleVolGrid->GetPointData()->SetScalars(fltarray);
>
>SampleVolDatasetmapper->Update();
>Iren->Initialize();
>Iren->Render();
>Iren->Start();
>}
>
>
>----------
><http://g.msn.com/8HMBENUS/2755??PS=>Get a FREE online virus check for 
>your PC here, from McAfee. _______________________________________________ 
>This is the private VTK discussion list. Please keep messages on-topic. 
>Check the FAQ at: Follow this link to subscribe/unsubscribe: 
>http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040203/bceb4df8/attachment.htm>


More information about the vtkusers mailing list