[vtkusers] polyline rendering pb

Dean Inglis dean.inglis at on.aibn.com
Fri Mar 14 11:27:09 EST 2003


Hi,

I'm developing a 'tracer widget' that works
by firing picks at a given prop with its internal
vtkPropPicker (vtkCellPicker won't do) and then
builds a polyline as the mouse moves over the
prop in the renderer.  The API for the widget
looks like this (here it is used to trace
on an image):

  vtkImageActor* imageActor = vtkImageActor::New();
  imageActor->SetInput(shifter->GetOutput());
  imageActor->VisibilityOn();
  imageActor->SetDisplayExtent(imageActor->GetInput()->GetUpdateExtent());


vtkPropTracerWidget* ptw = vtkPropTracerWidget::New();
  ptw->SetProp(imageActor);
  ptw->SetInput((vtkDataSet*)shifter->GetOutput());
  ptw->PlaceWidget();
  ptw->SetInteractor(iren);
  ptw->On();

The line is built by the widget during mouse movement
by repeatedly calling a 'trace' funcition:

void vtkPropTracerWidget::Trace(int X, int Y)
{
  if( !this->PropPicker->PickProp(X,Y,this->CurrentRenderer) ){ return; }
  if( this->Prop !=  this->PropPicker->GetProp() ){ return; }

  float pos[3];
  this->PropPicker->GetPickPosition(pos);
  this->HandleGeometry[this->CurrentHandleIndex]->SetCenter(pos);
  this->HandleGeometry[this->CurrentHandleIndex]->Update();
  this->CurrentPoints[0] = this->PickCount;
  this->PickCount++;
  this->CurrentPoints[1] = this->PickCount;

  this->LinePoints->InsertPoint(this->PickCount,pos);
  this->LineCells->InsertNextCell(2,this->CurrentPoints);

  this->LineData->SetPoints(this->LinePoints);
  this->LineData->SetLines(this->LineCells);
  this->LineData->Update();
  this->LineMapper->Modified();
}

where

this->LineData is a vtkPolyData,
this->LineMapper is a vtkPolyDataMapper with the following settings
initialized in the widget's constructor:

  this->LineMapper->SetInput(this->LineData);
  this->LineMapper->SetResolveCoincidentTopologyToPolygonOffset();
  this->LineMapper->SetResolveCoincidentTopologyPolygonOffsetParameters(1.0,
0.0);
  this->LineMapper->ScalarVisibilityOff();

furthermore, to display the line, the widget's internal LineActor has as
default property:
    this->LineProperty->SetInterpolationToFlat();
    this->LineProperty->SetRepresentationToWireframe();
    this->LineProperty->SetAmbient(1);
    this->LineProperty->SetColor(0,1,0);
    this->LineProperty->SetLineWidth(2);

The problem I am having is that during rendering and/or tracing, the line is
sometimes
'invisible' depending on how close up the prop being traced upon is in
the render window.  I have tried different settings for
this->LineMapper->SetResolveCoincidentTopologyPolygonOffsetParameters(factor
, units);

Any thoughts????

Dean






More information about the vtkusers mailing list