[vtkusers] vtkTubeFilter problem solved

Paul Tait paul at opes.com.au
Wed Aug 6 20:49:30 EDT 2003


Hi VTK'ers

Finally solved my vtkTubefilter problem which occured after upgrading from
4->4.2

The original code was pretty standard newbie code. What I'm doing is
geological modelling and I'm building an oil well from 2 points

vtkWell::vtkWell(int *idx, vtkPoints *wellPoints, vtkPropCollection *Props,
const char *name) : name(name), Props(Props)
{
 wellPolyData       = vtkPolyData::New();
 wellPolyDataMapper = vtkPolyDataMapper::New();
 wellActor          = vtkActor::New();
 wellPolyData->SetPoints(wellPoints);
 wellCellArray      = vtkCellArray::New();
 wellCellArray->InsertNextCell(2, &idx[0]);
 wellPolyData->SetLines(wellCellArray);
 tubes       = vtkTubeFilter::New();
 tubes->SetInput(wellPolyData);
 tubes->SetRadius(8.0);
 tubes->SetNumberOfSides(6);
 wellPolyDataMapper->SetInput(tubes->GetOutput());
 wellActor->SetMapper(wellPolyDataMapper);
 Props->AddItem(wellActor);
......

Anyway 4.2 displays nothing, no errors/warnings!!!! So the working code now
looks like this

vtkWell::vtkWell(int *idx, vtkPoints *wellPoints, vtkPropCollection *Props,
const char *name) : name(name), Props(Props)
{
 vtkLineSource *ls  = vtkLineSource::New();
 float *pt = wellPoints->GetPoint(idx[0]);
 ls->SetPoint1(*pt, *(pt+1), *(pt+2));
 pt = wellPoints->GetPoint(idx[1]);
 ls->SetPoint2(*pt, *(pt+1), *(pt+2));
 wellPolyDataMapper = vtkPolyDataMapper::New();
 wellActor          = vtkActor::New();
 tubes       = vtkTubeFilter::New();
 tubes->SetInput(ls->GetOutput());
 tubes->SetRadius(8.0);
 tubes->SetNumberOfSides(6);
 wellPolyDataMapper->SetInput(tubes->GetOutput());
 wellActor->SetMapper(wellPolyDataMapper);
 Props->AddItem(wellActor);
......

So instead of using polydata I'm using vtkLineSource all works well again. I
haven't investigated why this happens but I assume its either a boundary
problem/off by one error or some "tightening" of the code is rejecting the
line. Maybe polydata must have at least 3 points but I reckon a line with 2
is just fine.

Well hope this helps someone

Paul





More information about the vtkusers mailing list