<html>
Hi Lisa,<br><br>
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.<br><br>
- Amy<br><br>
At 12:00 AM 2/3/2004 +0000, lisa hughes wrote:<br>
<blockquote type=cite class=cite cite>hi<br>
for some reason, i just get a black screen when i run the code
below..<br>
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<br>
so i used unstructured grid and vertex cells to represent the data<br>
whats wrong with the below code??<br>
<br>
<br>
<br>
<br>
vtkLookupTable *lut = vtkLookupTable::New();<br>
vtkPoints *SampleVolPoints = vtkPoints::New();<br>
vtkUnstructuredGrid *SampleVolGrid = vtkUnstructuredGrid::New();<br>
vtkCellArray *SampleVolCellarray = vtkCellArray::New();<br>
vtkActor *SampleVolUgridactor = vtkActor::New();<br>
vtkDataSetMapper *SampleVolDatasetmapper = vtkDataSetMapper::New();<br>
vtkVertex *SampleVolVertex = vtkVertex::New();<br>
vtkFloatArray *fltarray = vtkFloatArray::New();<br>
vtkFloatArray *cellfltarray = vtkFloatArray::New();<br>
Ren1= vtkRenderer::New();<br>
RenWin = vtkRenderWindow::New();<br>
Iren = vtkRenderWindowInteractor::New(); <br>
int point, pnt[1] ;<br>
float xyz[3];<br>
<br>
lut->SetAlphaRange(0,1);<br>
lut->SetHueRange(0, 1);<br>
lut->SetNumberOfColors(256);<br>
lut->SetSaturationRange(0, 1);<br>
lut->SetValueRange(0, 1);<br>
lut->SetTableRange(0,1);<br>
lut->Build();<br>
<br>
<br>
int *vertexTypes = new int[NumSearchPoints];<br>
for ( int k =0; k<NumSearchPoints; k++)<br>
{<br>
vertexTypes[k] = VTK_VERTEX;<br>
}<br>
<br>
<br>
fltarray->SetNumberOfValues(NumSearchPoints);<br>
SampleVolGrid->Allocate(NumSearchPoints); <br>
SampleVolPoints->SetNumberOfPoints(NumSearchPoints);<br>
SampleVolGrid->SetCells(vertexTypes, SampleVolCellarray);<br>
<br>
SampleVolDatasetmapper->SetInput( SampleVolGrid );<br>
SampleVolDatasetmapper->SetLookupTable( lut );<br>
SampleVolDatasetmapper->SetScalarRange(0,2);<br>
SampleVolUgridactor->SetMapper(SampleVolDatasetmapper);<br>
Ren1->AddActor( SampleVolUgridactor );<br>
RenWin->AddRenderer( Ren1 );<br>
RenWin->SetSize( 600, 600 );<br>
RenWin->SetInteractor(Iren);<br>
<br>
while(1)<br>
{<br>
for ( int point = 0; point<NumSearchPoints;
point++)<br>
{<br>
xyz[0] = point/2; //x<br>
xyz[1] = point/3; //y<br>
xyz[2] = point/4; //z<br>
<br>
pnt[0] = point;<br>
SampleVolPoints->SetPoint(point,
xyz); <br>
fltarray->SetValue(point,
1.5);<br>
SampleVolCellarray->InsertNextCell( 1, pnt); <br>
}<br>
<br>
SampleVolGrid->GetPointData()->SetScalars(fltarray);<br>
<br>
SampleVolDatasetmapper->Update();<br>
Iren->Initialize();<br>
Iren->Render();<br>
Iren->Start(); <br>
} <br><br>
<hr>
<a href="http://g.msn.com/8HMBENUS/2755??PS=">Get a FREE online virus
check for your PC here, from McAfee.</a>
_______________________________________________ This is the private VTK
discussion list. Please keep messages on-topic. Check the FAQ at: Follow
this link to subscribe/unsubscribe:
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" eudora="autourl">http://www.vtk.org/mailman/listinfo/vtkusers</a>
</blockquote></html>