[vtkusers] RE: vtkSplineWidget

Renaud Isabelle renauisa at yahoo.fr
Tue Sep 27 14:59:12 EDT 2005


Hi Dean, 
 
Thanks for help. I made the changes, but it changes nothing. 
 
however, I just found my  mistake, so I let it know. 
 
To avoid dealing with memory and to enable a faster access, I set at the beginning:
 
vtkpoints* points = vtkPoints::New();
points->SetNumberOfPoints(100);
 
Then, after each click, the world position is stored in vtkPoint* points and a  vtkSphereSource is positionned at the point.
 
Now I realise that, if I pick only 3 points, then the rest of vtkPoint* points (97 points) store (0,0,0). That's why I have lines passing through my spheres, instead of having a spline interpolating them. 
 
Isabelle
 

Dean Inglis <dean.inglis at camris.ca> a écrit :
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();
}
}




		
---------------------------------
 Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
 Téléchargez le ici !  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050927/3999796d/attachment.htm>


More information about the vtkusers mailing list