[vtkusers] RE: vtkSplineWidget

Dean Inglis dean.inglis at camris.ca
Tue Sep 27 10:46:43 EDT 2005


Isabelle,


see edits below.  You have to turn on ProjectToPlane and set
the projection position.

Dean


 points = vtkPoints::New();
 points->SetNumberOfPoints( 100);

splineWidget = vtkSplineWidget::New();
splineWidget->SetCurrentRenderer(m_Renderer);
splineWidget->SetDefaultRenderer(m_Renderer);
splineWidget->SetInput(m_Actor->GetInput());//vtkImageActor
splineWidget->SetInteractor(m_RenderWindow->GetInteractor());

double bounds[6];
m_Actor->GetBounds(bounds);

splineWidget->ProjectToPlaneOn();  // you need to do this to make the spline
reside planar
double pos = 0.0;

if ( bounds[0] == bounds[1] ) // a y-z plane
  {
  splineWidget->SetProjectionNormalToXAxes();
  pos = bounds[0];
  }
else if ( bounds[2] == bounds[3] ) // a x-z plane
  {
  splineWidget->SetProjectionNormalToYAxes();
  pos = bounds[2];
  }
else if ( bounds[4] == bounds[5] ) // a x-y plane
  {
  splineWidget->SetProjectionNormalToZAxes();
  }
else
  {
  splineWidget->SetProjectionNormalToOblique();  // you need to do other
things to make this work, see docs
  }

splineWidget->SetProjectionPosition(pos);


splineWidget->PlaceWidget(bounds);
splineWidget->ClosedOn();


//leftbuttonpressed handle
static int numberOfNodes = 0;
void vtkSliceViewer::SelectPoint( double x, double y, double z )
{

  if(numberOfNodes <100)
  {
   // Store the point with no range checking or memory allocation.
   points->SetPoint( nodeId, x,y,z );
   numberOfNodes ++;

   if(numberOfNodes >=2)
   {
    splineWidget->InitializeHandles(points);
 //   splineWidget->SetProjectionNormalToZAxes(); // don't need to do this
here
 //   splineWidget->SetProjectionPosition(z);  // don't need to do this here
    splineWidget->On();
   this->Render();
   }
}






More information about the vtkusers mailing list