[vtkusers] vtkSplineWidget

Renaud Isabelle renauisa at yahoo.fr
Fri Sep 23 07:36:15 EDT 2005


Hi,

 I followed your advice and had a look on
 vtkSplineWidget: It seems to do exactly all I have
 tried to do without success. Moreover, it could
 simplify my code a lot. Thanksa lot. 

 So, i tried to implement it: however, it seems
 that I missed something about projection or
 something else.:  the points (handle geometries) are
 positionned correctly on my figure exactly where I
 click. However, the splines passing through are just
 parallel lines (no curve, no spline). 

 In fact, I am using vtkImageActor to display just
 one Z slice of my 3D image. So I thought that my
 projection plane should be normal to Z axis. I tried
 each possibility: SetProjectionNormalToXAxes,
 SetProjectionNormalToYAxes,
 SetProjectionNormalToZAxes. All I have is parallel
 lines.

 Could you have a look, please?  
 Isabelle

 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());
splineWidget->PlaceWidget(m_Actor->GetBounds());
splineWidget->ClosedOn();

//leftbuttonpressed handle
 static int numberOfNodes = 0;
 void vtkSliceViewer::SelectPoint( double x, double
y, double z )
 {
 if(numberOfNodes <100)
   {
    points->SetPoint( nodeId, x,y,z );   
    numberOfNodes ++;   

   if(numberOfNodes >=2)
    {
    splineWidget->InitializeHandles(points);
    splineWidget->SetProjectionNormalToZAxes();
    splineWidget->SetProjectionPosition(z);
     splineWidget->On();
    this->Render();
  }   
}
> >  
> >  
> > 
> > 
> > Dean Inglis <dean.inglis at camris.ca> a écrit :
> > why don't you just use the
> > new vtkParametricSpline and
> vtkParametricFunctionSource
> > classes? That way you just insert a vtkPoints
> containing
> > the points to fit a spline to into a
> > vtkParametricSpline and then
> vtkParametricFunctionSource
> > generates the polydata for you.
> > Have a look at cvs vtkSplineWidget
> > to see how this is can be done.
> > 
> > Dean
> > 
> > 
> > -----Original Message-----
> > From: Renaud Isabelle [mailto:renauisa at yahoo.fr]
> > Sent: Monday, September 12, 2005 11:48 AM
> > To: Dean Inglis; vtkusers archive
> > Subject: RE: [vtkusers] splines
> > 
> > 
> > Hi,
> > 
> > - i tried this but it didn't change anything.
> > 
> > - i have a question: do you know if my parameter t
> has to be a float between
> > 0 and 1?
> > 
> > When I traced spline_points, here is what I got:
> > 
> > t=0.000000, spline points:13.035959 10.105188
> 0.000000
> > t=5.210526, spline
> > points:-434367840.000000 -434367840.000000
> -434367840.000000
> > t=10.421053, spline
> > points:-431597504.000000 -431597504.000000
> -431597504.000000
> > t=15.631579, spline
> > points:-431602080.000000 -431602080.000000
> -431602080.000000
> > t=20.842106, spline
> > points:-431602080.000000 -431602080.000000
> -431602080.000000
> > t=26.052631, spline
> > points:-431602080.000000 -431602080.000000
> -431602080.000000
> > t=31.263159, spline
> > points:-431602080.000000 -431602080.000000
> -431602080.000000
> > t=36.473682, spline
> > points:-431602080.000000 -431602080.000000
> -431602080.000000
> > t=41.684212, spline
> > points:-431602080.000000 -431602080.000000
> -431602080.000000
> > t=46.894737, spline
> > points:-431602080.000000 -431602080.000000
> -431602080.000000
> > t=52.105263, spline
> > points:-431602080.000000 -431602080.000000
> -431602080.000000
> > t=57.315788, spline
> > points:-431602080.000000 -431602080.000000
> -431602080.000000
> > t=62.526318, spline
> > points:-431602080.000000 -431602080.000000
> -431602080.000000
> > t=67.736839, spline
> > points:-431602080.000000 -431602080.000000
> -431602080.000000
> > t=72.947365, spline
> > points:-431602080.000000 -431602080.000000
> -431602080.000000
> > t=78.157898, spline
> > points:-431602080.000000 -431602080.000000
> -431602080.000000
> > t=83.368423, spline
> > points:-431602080.000000 -431602080.000000
> -431602080.000000
> > t=88.578949, spline
> > points:-431602080.000000 -431602080.000000
> -431602080.000000
> > t=93.789474, spline
> > points:-431602080.000000 -431602080.000000
> -431602080.000000
> > t=99.000000, spline
> > points:-431602080.000000 -431602080.000000
> -431602080.000000
> > 
> > Maybe t could be the problem. I saw many examples:
> > - sometimes t is defined as:
> > t = ( (float)numberOfInputPoints - 1.0 ) / (
> (float)numberOfOutputPoints -
> > 1.0 ) * (float)i;
> > 
> > - sometimes length of the polyline is used, such
> as vtkSplineFilter:
> > t=len/length as cumulative distance
> > 
> > BTW, i tried to use vtkSplineFilter but i couldn't
> compile: undefined
> > identifier vtkGarbageCollector in
> vtkAlgortihm??????????
> > 
> > Please help,
> > 
> > Isabelle
> > 
> > Dean Inglis a écrit :
> > sorry, I missed that.
> > 
> > Maybe it's because you call Reset()
> > without setting the number of points.
> > 
> > 
> > if(spline_points) spline_points->Reset(); float t
> = 0.0;
> 
=== message truncated ===



	

	
		
___________________________________________________________________________ 
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger 
Téléchargez cette version sur http://fr.messenger.yahoo.com



More information about the vtkusers mailing list