[vtk-developers] Patch: Allowing a graph to be colored directly by an array

David Doria daviddoria+vtk at gmail.com
Tue Aug 31 07:55:08 EDT 2010


Currently when you use a vtkGraphLayoutView you must use a look up table to
color the points. I modified vtkApplyColors and
vtkRenderedGraphRepresentation to allow a user to color graph vertices
directly with a vtkUnsignedCharArray. Here is an example usage:

  vtkSmartPointer<vtkUnsignedCharArray> vertexColors =
    vtkSmartPointer<vtkUnsignedCharArray>::New();
  vertexColors->SetNumberOfComponents(3);
  vertexColors->SetName("PassVertexColors");

// ... add colors ... ///

  vtkSmartPointer<vtkRenderedGraphRepresentation> representation =
    vtkSmartPointer<vtkRenderedGraphRepresentation>::New();
  std::cout << representation->GetClassName() << std::endl;
  representation->SetInputConnection(tree->GetProducerPort());
  representation->ColorVerticesByArrayOn();
*  representation->SetPassThroughPointColors(vertexColors);*

  vtkSmartPointer<vtkGraphLayoutView> graphLayoutView =
     vtkSmartPointer<vtkGraphLayoutView>::New();
  graphLayoutView->AddRepresentation(representation);

The branch is here:

repo: git at github.com:daviddoria/daviddoria-vtk.git
branch: VTK-GraphColors

Please let me know what you think.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100831/c0a20dff/attachment.html>


More information about the vtk-developers mailing list