[vtkusers] Color AND scale glyphs

David Cole DLRdave at aol.com
Mon Aug 28 07:01:11 EDT 2017


Do these stack overflow Q&As help?

https://stackoverflow.com/questions/23915671/independently-color-and-rotate-3d-vtk-glyphs




On Mon, Aug 28, 2017 at 5:37 AM, M. Jordan <mjordan at live.at> wrote:
> 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!
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>


More information about the vtkusers mailing list