[vtkusers] Color AND scale glyphs

M. Jordan mjordan at live.at
Mon Aug 28 05:37:31 EDT 2017


Hi,


i would like to color and scale some glyphs.

I am using the following code to draw and scale the glyphs:

vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkFloatArray> scales = vtkSmartPointer<vtkFloatArray>::New();
scales->SetName("radius");

for(int i = 0; i < 100; i++)
{
    points->InsertNextPoint(x-pos, y-pos, z-pos);
    scales->InsertNextValue(radius);
}

vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
polydata->SetPoints(points);
polydata->GetPointData()->SetScalars(scales);

// Glyph
vtkSmartPointer<vtkSphereSource> sphereSource = vtkSmartPointer<vtkSphereSource>::New();
vtkSmartPointer<vtkGlyph3D> glyph = vtkSmartPointer<vtkGlyph3D>::New();
glyph->SetSourceConnection(sphereSource->GetOutputPort());
glyph->SetInputData(scBalls_polydata);
glyph->Update();
// Mapper
vtkSmartPointer<vtkPolyDataMapper> mapper  = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(scBalls_glyph3D->GetOutputPort());
// Actor
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(actor);
renderer->AddActor(actor);

I don't know how to color AND scale the glyphs individually.  I would like to set
any RGB color in the for loop.

Thank you very much!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170828/bab2f529/attachment.html>


More information about the vtkusers mailing list