[vtkusers] vtkTubeFilter with independently varying radius and color

Marcus Thamson markie_thomson at yahoo.de
Tue Dec 8 16:29:54 EST 2009


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 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091208/6ade955e/attachment.htm>


More information about the vtkusers mailing list