[vtkusers] AddArray() to polydata

ChiaWeng Boon chiaweng at gmail.com
Tue Sep 28 20:39:28 EDT 2010


Hi,

My AddArray() to this polydata does not work.  I tried also
GetCellData()->SetScalars(speed).  The array/variable speed is not
present!  Can someone tell me why?

                 /* vtksamplefunction before this */
                 vtkContourFilter *contours = vtkContourFilter::New();
		 contours->SetInput(sample->GetOutput());
		 contours->GenerateValues(1,-0.01, 0.01);
                vtkSmartPointer<vtkPolyData> polydata =
vtkSmartPointer<vtkPolyData>::New();
		polydata = contours->GetOutput();
		vtkSmartPointer<vtkUnsignedCharArray> speed =
vtkSmartPointer<vtkUnsignedCharArray>::New();
		speed->SetName("pbColors");
		vtkIdType nbCells=polydata->GetNumberOfPoints();
		for (int i=0;i<nbCells;i++){
			speed->InsertNextValue(2);
		}	
		polydata->GetPointData()->AddArray(speed);    // HELP HELP
		polydata->Update();
		
Yours,
boon



More information about the vtkusers mailing list