[vtkusers] Need help with vtkTubeFilter
Alex Lear
alear at cns.montana.edu
Wed Jul 31 16:02:57 EDT 2002
I have successfully used the vtkTubeFilter in the past but I am trying a new
way of doing things and have encountered a problem. In the most simple case
I am creating a line from two points and applying scalar values to the
points. I then run it into the vtkTubeFilter. I would like to scale the
tube radius by scalar value so I set that up too. However, the radius does
not seem to be varying by scalar value. I am not quite sure if the scalar
values are being set right or if the problem is somewhere else.
I am including a small c++ test program code to show the problem, maybe
someone can see why it isn't varying the radius. The development is in
Windows.
Thanks,
Alex Lear
// tube_test.cpp
//
#include "stdafx.h"
#include "vtk.h"
#define RADIAL_RESOLUTION 10
int main(int argc, char* argv[])
{
vtkPolyData *polydata = vtkPolyData::New();
vtkPoints *points = vtkPoints::New();
vtkCellArray *line = vtkCellArray::New();
vtkScalars *linescalars = vtkScalars::New();
vtkTubeFilter *Tube = vtkTubeFilter::New();
vtkPolyDataMapper *Tubemapper = vtkPolyDataMapper::New();
vtkActor *TubeActor = vtkActor::New();
vtkRenderWindowInteractor *interactor = vtkRenderWindowInteractor::New();
vtkRenderer *renderer = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
points->SetNumberOfPoints(2);
points->InsertPoint (0,0,0,0);
points->InsertPoint (1,100,100,100);
line->InsertNextCell(2);
line->InsertCellPoint(0);
line->InsertCellPoint(1);
linescalars->SetDataTypeToFloat();
linescalars->SetNumberOfScalars(2);
linescalars->InsertScalar(0,1); // I set the two scalars very different
to ...
linescalars->InsertScalar(1,100); // ... be an obvious difference in
radius.
polydata->SetPoints(points);
polydata->SetLines(line);
polydata->GetPointData()->SetScalars(linescalars);
Tube->SetInput(polydata);
Tube->SetVaryRadiusToVaryRadiusByScalar();
Tube->SetNumberOfSides(RADIAL_RESOLUTION);
Tubemapper->SetInput(Tube->GetOutput());
TubeActor->SetMapper(Tubemapper);
renWin->AddRenderer(renderer);
renderer->AddActor(TubeActor);
interactor->SetRenderWindow(renWin);
renWin->Render();
interactor->Start();
return 0;
}
More information about the vtkusers
mailing list