<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt;color:#000000;"><div>Hello everyone,<br><br>I have a cell array and I'm assigning a color to each cell.<br>So far I have a working solution, it's doing the job when there are a few cells, but it takes awfully long when there are a thousands of them.<br>There probably is another way to do that faster.<br><br>My (relevant) code is:<br><br>//creating a color attribute for the cells<br>vtkFloatArray* Colors = vtkFloatArray::New();<br> Colors->SetName("Colors");<br><br>//creating a transfer function<br>vtkColorTransferFunction* MyColorFunction = vtkColorTransferFunction::New();<br><br>//building colors and MyColorFunction:<br>for (var indice=0;indice<imax;++indice) {<br> MyColorFunction->AddRGBPoint(indice,r,g,b);<br>
Colors->InsertNextValue(indice);<br>}<br><br>//assigning points, vertices and colors<br> polydata->SetPoints(Points);<br> polydata->SetPolys(Vertices);<br> polydata->GetCellData()->AddArray(Colors);<br><br>// and with the mapper, I have:<br>contMapper->SetInput(polydata);<br>contMapper->SetScalarModeToUseCellFieldData();<br>contMapper->SetLookupTable(MyColorFunction);<br> contMapper->SelectColorArray("Colors");<br><br>So as I said, this is perfectly working, but the for loop is taking forever, if someone knows how to achieve the same result faster, that would be great!<br><br>Thank you,<br><br>Guillaume<br></div></div><br>
</body></html>