Hi Dean,<br><br>Thanks for the reply!<br><br>I had looked at it but had got a bit confused with the following lines:<br><pre>x = (1.0 - u[0])*x0 + u[0]*x1;<br>y = (1.0 - u[0])*y0 + u[0]*y1;<br>z = (1.0 - u[0])*z0 + u[0]*z1;
<br><br>But it is great to know that they can be used with any values. Perfect! <br><br>Thanks again.<br><br>Anja<br></pre><div><span class="gmail_quote">On 10/11/06, <b class="gmail_sendername">Dean Inglis</b> <<a href="mailto:dean.inglis@sympatico.ca">
dean.inglis@sympatico.ca</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Anja,<br><br>have a look at the code snippet taken from vtkSplineWidget below.
<br>Pass your screen coordinates as is (or any other type of points) to the<br>vtkParametricSpline: these are your "handles" or control points: no need<br>to normalize. You control how many points to generate along the spline with
<br>the<br>Resolution term. For a single line between control point pairs,<br>set resolution to be numberOfControlPoints - 1.<br><br>Dean<br><br>Hi everyone,<br><br>I have a question about the usage of vtkParametricSpline and
<br>vtkParametricSource. What I want to do is use Qt to draw a spline through<br>some selected points on my image. I think the combination of<br>vtkParametricSpline and vtkParametricFunctionSource can do what I want to<br>
achieve.<br><br>Now, I acquire the control points coordinates through the mouse events and<br>these are integers. What I would like to do is calculate the spline using<br>these values. I noticed that the documentation for the vtkParametricSpline
<br>mentions:<br>"This family of 1D splines is quaranteed to be parameterized in the interval<br>[0,1]. Attempting to evaluate outside this interval will cause the parameter<br>u to be clamped in the range [0,1]."
<br><br>I was wondering if I could pass the screen coordinates as input points to<br>the spline or does everything has to be normalized between 0 and 1. I think<br>working with integers would be faster and I would like to avoid the
<br>unnecessary conversions back and forth...<br><br>Thanks and cheers,<br><br>Anja<br><br>vtkPoints* points = vtkPoints::New(VTK_DOUBLE);<br> points->SetNumberOfPoints(this->NumberOfHandles);<br><br> for ( i = 0; i < this->NumberOfHandles; ++i )
<br> {<br> this->HandleGeometry[i] = vtkSphereSource::New();<br> this->HandleGeometry[i]->SetThetaResolution(16);<br> this->HandleGeometry[i]->SetPhiResolution(8);<br> vtkPolyDataMapper* handleMapper = vtkPolyDataMapper::New();
<br> handleMapper->SetInput(this->HandleGeometry[i]->GetOutput());<br> this->Handle[i] = vtkActor::New();<br> this->Handle[i]->SetMapper(handleMapper);<br> handleMapper->Delete();<br> u[0] = (double)i / (double)(this->NumberOfHandles -
1.0);<br> x = (1.0 - u[0])*x0 + u[0]*x1;<br> y = (1.0 - u[0])*y0 + u[0]*y1;<br> z = (1.0 - u[0])*z0 + u[0]*z1;<br> points->SetPoint(i, x, y, z);<br> this->HandleGeometry[i]->SetCenter(x,y,z);<br> }
<br><br> // vtkParametric spline acts as the interpolating engine<br> this->ParametricSpline = vtkParametricSpline::New();<br> this->ParametricSpline->Register(this);<br> this->ParametricSpline->SetPoints(points);
<br> this->ParametricSpline->ParameterizeByLengthOff();<br> points->Delete();<br> this->ParametricSpline->Delete();<br><br> // Define the points and line segments representing the spline<br> this->Resolution = 499;
<br><br> this->ParametricFunctionSource = vtkParametricFunctionSource::New();<br> this->ParametricFunctionSource->SetParametricFunction(this->ParametricSpli<br>ne);<br> this->ParametricFunctionSource->SetScalarModeToNone();
<br> this->ParametricFunctionSource->GenerateTextureCoordinatesOff();<br> this->ParametricFunctionSource->SetUResolution( this->Resolution );<br> this->ParametricFunctionSource->Update();<br><br> vtkPolyDataMapper* lineMapper = vtkPolyDataMapper::New();
<br> lineMapper->SetInput( this->ParametricFunctionSource->GetOutput() ) ;<br> lineMapper->ImmediateModeRenderingOn();<br> lineMapper->SetResolveCoincidentTopologyToPolygonOffset();<br><br> this->LineActor = vtkActor::New();
<br> this->LineActor->SetMapper( lineMapper );<br> lineMapper->Delete();<br><br></blockquote></div><br><br clear="all"><br>-- <br>Cheers,<br><br>Anja