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> &lt;<a href="mailto:dean.inglis@sympatico.ca">
dean.inglis@sympatico.ca</a>&gt; 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 &quot;handles&quot; or control points: no need<br>to normalize. You control how many points to generate along the spline with
<br>the<br>Resolution term.&nbsp;&nbsp;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>&quot;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].&quot;
<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>&nbsp;&nbsp;points-&gt;SetNumberOfPoints(this-&gt;NumberOfHandles);<br><br>&nbsp;&nbsp;for ( i = 0; i &lt; this-&gt;NumberOfHandles; ++i )
<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;this-&gt;HandleGeometry[i] = vtkSphereSource::New();<br>&nbsp;&nbsp;&nbsp;&nbsp;this-&gt;HandleGeometry[i]-&gt;SetThetaResolution(16);<br>&nbsp;&nbsp;&nbsp;&nbsp;this-&gt;HandleGeometry[i]-&gt;SetPhiResolution(8);<br>&nbsp;&nbsp;&nbsp;&nbsp;vtkPolyDataMapper* handleMapper = vtkPolyDataMapper::New();
<br>&nbsp;&nbsp;&nbsp;&nbsp;handleMapper-&gt;SetInput(this-&gt;HandleGeometry[i]-&gt;GetOutput());<br>&nbsp;&nbsp;&nbsp;&nbsp;this-&gt;Handle[i] = vtkActor::New();<br>&nbsp;&nbsp;&nbsp;&nbsp;this-&gt;Handle[i]-&gt;SetMapper(handleMapper);<br>&nbsp;&nbsp;&nbsp;&nbsp;handleMapper-&gt;Delete();<br>&nbsp;&nbsp;&nbsp;&nbsp;u[0] = (double)i / (double)(this-&gt;NumberOfHandles - 
1.0);<br>&nbsp;&nbsp;&nbsp;&nbsp;x = (1.0 - u[0])*x0 + u[0]*x1;<br>&nbsp;&nbsp;&nbsp;&nbsp;y = (1.0 - u[0])*y0 + u[0]*y1;<br>&nbsp;&nbsp;&nbsp;&nbsp;z = (1.0 - u[0])*z0 + u[0]*z1;<br>&nbsp;&nbsp;&nbsp;&nbsp;points-&gt;SetPoint(i, x, y, z);<br>&nbsp;&nbsp;&nbsp;&nbsp;this-&gt;HandleGeometry[i]-&gt;SetCenter(x,y,z);<br>&nbsp;&nbsp;&nbsp;&nbsp;}
<br><br>&nbsp;&nbsp;// vtkParametric spline acts as the interpolating engine<br>&nbsp;&nbsp;this-&gt;ParametricSpline = vtkParametricSpline::New();<br>&nbsp;&nbsp;this-&gt;ParametricSpline-&gt;Register(this);<br>&nbsp;&nbsp;this-&gt;ParametricSpline-&gt;SetPoints(points);
<br>&nbsp;&nbsp;this-&gt;ParametricSpline-&gt;ParameterizeByLengthOff();<br>&nbsp;&nbsp;points-&gt;Delete();<br>&nbsp;&nbsp;this-&gt;ParametricSpline-&gt;Delete();<br><br>&nbsp;&nbsp;// Define the points and line segments representing the spline<br>&nbsp;&nbsp;this-&gt;Resolution = 499;
<br><br>&nbsp;&nbsp;this-&gt;ParametricFunctionSource = vtkParametricFunctionSource::New();<br>&nbsp;&nbsp;this-&gt;ParametricFunctionSource-&gt;SetParametricFunction(this-&gt;ParametricSpli<br>ne);<br>&nbsp;&nbsp;this-&gt;ParametricFunctionSource-&gt;SetScalarModeToNone();
<br>&nbsp;&nbsp;this-&gt;ParametricFunctionSource-&gt;GenerateTextureCoordinatesOff();<br>&nbsp;&nbsp;this-&gt;ParametricFunctionSource-&gt;SetUResolution( this-&gt;Resolution );<br>&nbsp;&nbsp;this-&gt;ParametricFunctionSource-&gt;Update();<br><br>&nbsp;&nbsp;vtkPolyDataMapper* lineMapper = vtkPolyDataMapper::New();
<br>&nbsp;&nbsp;lineMapper-&gt;SetInput( this-&gt;ParametricFunctionSource-&gt;GetOutput() ) ;<br>&nbsp;&nbsp;lineMapper-&gt;ImmediateModeRenderingOn();<br>&nbsp;&nbsp;lineMapper-&gt;SetResolveCoincidentTopologyToPolygonOffset();<br><br>&nbsp;&nbsp;this-&gt;LineActor = vtkActor::New();
<br>&nbsp;&nbsp;this-&gt;LineActor-&gt;SetMapper( lineMapper );<br>&nbsp;&nbsp;lineMapper-&gt;Delete();<br><br></blockquote></div><br><br clear="all"><br>-- <br>Cheers,<br><br>Anja