[vtkusers] vtkTubeFilter with independently varying radius and color
David E DeMarle
dave.demarle at kitware.com
Thu Dec 10 21:21:52 EST 2009
The mapper defaults to the color by the array that is marked as the active
scalars, but you can tell it to use any array you want. See the doxygen for
vtkMapper::SelectColorArray()
Dave DeMarle
Kitware, Inc.
R&D Engineer
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-371-3971 x109
On Tue, Dec 8, 2009 at 4:29 PM, Marcus Thamson <markie_thomson at yahoo.de>wrote:
> Dear All,
>
> Is it possible to set both a varying radius *and* independently varying
> color (scalar, RGB triples...) when using vtkTubeFilter? (i.e. with two sets
> of scalar arrays)
>
> I have a running code using SetVaryRadiusToVaryRadiusByScalar (with scalar
> values added to the input vtkPolyData with
> "...->GetPointData()->SetScalars(...)").
>
> The coloring of the resulting tube is also then based on these same
> scalars...
> I would have liked to set the RGB values for each segment of the tube using
> another vtkUnsignedCharArray of RGB triples, as I do for surfaces.
>
> An excerpt of the (fairly unoriginal) code is as follows:
>
> //------------------
> ...
>
> // v: Pointer to array of tube path coordinates
> // nV: Length of v
>
> // Tube path points
> vtkSmartPointer<vtkPoints> tpoints = vtkSmartPointer<vtkPoints>::New();
> for(i=0; i<nV; i++) tpoints->InsertPoint(i,v[i],v[nV+i],v[2*nV+i]);
>
> // and (somewhat trivial) lines
> vtkSmartPointer<vtkCellArray> tlines =
> vtkSmartPointer<vtkCellArray>::New();
> tlines->InsertNextCell(nV);
> for (i=0; i < nV; i++) tlines->InsertCellPoint(i);
>
> // Scalars for tube radius (from array 'trad')
> vtkSmartPointer<vtkDoubleArray> tscalars =
> vtkSmartPointer<vtkDoubleArray>::New();
> tscalars->SetNumberOfTuples(nV);
> for (i=0 ;i<nV ; i++) tscalars->SetTuple1(i,trad[i]);
> tscalars->GetRange(tscalar_range);
>
> vtkSmartPointer<vtkPolyData> tprofile =
> vtkSmartPointer<vtkPolyData>::New();
> tprofile->SetPoints((vtkPoints *)(tpoints));
> tprofile->SetLines(tlines);
> tprofile->GetPointData()->SetScalars(tscalars);
> tprofile->BuildLinks();
>
> vtkSmartPointer<vtkTubeFilter> tube =
> vtkSmartPointer<vtkTubeFilter>::New();
> tube->SetInput(tprofile);
> tube->SetVaryRadiusToVaryRadiusByScalar();
> tube->SetRadius(tscalar_range[0]);
> tube->SetRadiusFactor(tscalar_range[1]/tscalar_range[0]);
>
> vtkSmartPointer<vtkPolyDataMapper> tubeMapper =
> vtkSmartPointer<vtkPolyDataMapper>::New();
> tubeMapper->SetInput(tube->GetOutput());
> surfActor->SetMapper(tubeMapper);
> ...
> //------------------
>
> Many thanks, MT
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz
> gegen Massenmails.
> http://mail.yahoo.com
>
> _______________________________________________
> 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
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091210/3d053f1a/attachment.htm>
More information about the vtkusers
mailing list