[vtkusers] RGB colours for many lines in vtkPolyData

Arkadiusz Zychewicz oczykota at gmail.com
Tue Oct 13 07:03:19 EDT 2009


Hi,
  I have to display many lines (~10000) and each one must have different
colour.  For now I use scalar colour for that, but I cannot represent
black or white colour.
I do this in that way:

   vtkPoints* m_points = vtkPoints::New();
    vtkCellArray*m_lines = vtkCellArray::New();
   vtkFloatArray* m_lineScalars = vtkFloatArray::New();

int m_curPointID = 0
for(int i = 0; i < lines.size(); i++){
    m_lineScalars->SetNumberOfComponents(1);
    m_points->InsertNextPoint(lines.getStart());
    m_lineScalars->InsertNextTuple1(scalar); //this gives colour
    m_points->InsertNextPoint(lines.getEnd());
    m_lineScalars->InsertNextTuple1(scalar);

    m_lines->InsertNextCell(2);
    m_lines->InsertCellPoint(m_curPointID);
    m_lines->InsertCellPoint(m_curPointID + 1);
    m_curPointID += 2;

}
    // Create poly data
    vtkPolyData* polyData = vtkPolyData::New();
    polyData->SetPoints(m_points);
    polyData->SetLines(m_lines);
    polyData->GetPointData()->SetScalars(m_lineScalars);

A.



More information about the vtkusers mailing list