Hi everyone,<br><br>I am having a strange problem when visualizing spline data. When I visualize it, my spline data does not pass through the second last point in the control point collection. As I add new points interactively, it keeps updating the spline but it never passes through the second last position!
<br><br>I create the spline as follows:<br><br>m_parametricSpline = vtkParametricSpline::New();<br>m_parametricSpline->ClosedOff();<br> <br>vtkKochanekSpline* xspline = vtkKochanekSpline::New();<br>vtkKochanekSpline* yspline = vtkKochanekSpline::New();
<br>vtkKochanekSpline* zspline = vtkKochanekSpline::New();<br> <br>m_parametricSpline->SetXSpline(xspline);<br>m_parametricSpline->SetYSpline(yspline);<br>m_parametricSpline->SetZSpline(zspline);<br><br>
xspline->Delete();<br>yspline->Delete();<br>zspline->Delete();<br><br>m_splineSource = vtkParametricFunctionSource::New();<br>m_splineSource->SetUResolution(200);<br>m_splineSource->SetVResolution(200);<br>
m_controlPoints = vtkPoints::New();<br><br>The code to add the points is as follows:<br>As I add points here, the display is updated and the spline never passes through the second last point.<br><br>void KochanekSpline::PushPoint(float x, float y)
<br>{<br> int pos = m_controlPoints->InsertNextPoint(x, y, 0.0);<br> if (m_controlPoints->GetNumberOfPoints() > 1)<br> {<br> m_parametricSpline->SetPoints(0);<br>
m_parametricSpline->SetPoints(m_controlPoints);<br> m_splineSource->SetParametricFunction(m_parametricSpline);<br> m_splineSource->Update();<br> }<br>}<br>
<br>Now here comes the strange part... I have code that the user can interact with the control points and move them around. This is pretty similar to the code above as follows:<br><br>void KochanekSpline::SetPointAtIndex(unsigned index, float x, float y)
<br>{<br> if (m_controlPoints->GetNumberOfPoints() > index)<br> {<br> m_controlPoints->SetPoint(index, x, y, 0.0);<br> if (m_controlPoints->GetNumberOfPoints() > 1)
<br> {<br> m_parametricSpline->SetPoints(0);<br> m_parametricSpline->SetPoints(m_controlPoints);<br> m_splineSource->SetParametricFunction(m_parametricSpline);
<br> m_splineSource->Update();<br> }<br> }<br>}<br><br>This works as intended! As soon as I click on a point, the spline now passes through all the control points!!<br><br>However, as you can see it is pretty similar to the function above! I have no idea why this is happening.
<br><br>Any suggestions and help will be greatly appreciated!<br><br>Thanks,<br>Anja<br clear="all"><br><br>