[vtkusers] Re: bizarre spline problem

Anja Ende anja.ende at googlemail.com
Mon Nov 13 09:58:49 EST 2006


Hi,

Just a follow up: Another weird problem is that the spline does not show up
till the 4th point has been inserted and even after that is passed through
the first, second and the fourth points...skipping the second. Of course,
when I move the points, the spline looks fine...

Anja

On 13/11/06, Anja Ende <anja.ende at googlemail.com> wrote:
>
> Hi everyone,
>
> 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!
>
> I create the spline as follows:
>
> m_parametricSpline = vtkParametricSpline::New();
> m_parametricSpline->ClosedOff();
>
> vtkKochanekSpline* xspline = vtkKochanekSpline::New();
> vtkKochanekSpline* yspline = vtkKochanekSpline::New();
> vtkKochanekSpline* zspline = vtkKochanekSpline::New();
>
> m_parametricSpline->SetXSpline(xspline);
> m_parametricSpline->SetYSpline(yspline);
> m_parametricSpline->SetZSpline(zspline);
>
> xspline->Delete();
> yspline->Delete();
> zspline->Delete();
>
> m_splineSource = vtkParametricFunctionSource::New();
> m_splineSource->SetUResolution(200);
> m_splineSource->SetVResolution(200);
> m_controlPoints = vtkPoints::New();
>
> The code to add the points is as follows:
> As I add points here, the display is updated and the spline never passes
> through the second last point.
>
> void KochanekSpline::PushPoint(float x, float y)
> {
>             int pos = m_controlPoints->InsertNextPoint(x, y, 0.0);
>             if (m_controlPoints->GetNumberOfPoints() > 1)
>             {
>                 m_parametricSpline->SetPoints(0);
>                 m_parametricSpline->SetPoints(m_controlPoints);
>                 m_splineSource->SetParametricFunction(m_parametricSpline);
>                 m_splineSource->Update();
>             }
> }
>
> 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:
>
> void KochanekSpline::SetPointAtIndex(unsigned index, float x, float y)
> {
>             if (m_controlPoints->GetNumberOfPoints() > index)
>             {
>                 m_controlPoints->SetPoint(index, x, y, 0.0);
>                 if (m_controlPoints->GetNumberOfPoints() > 1)
>                 {
>                     m_parametricSpline->SetPoints(0);
>                     m_parametricSpline->SetPoints(m_controlPoints);
>
> m_splineSource->SetParametricFunction(m_parametricSpline);
>                     m_splineSource->Update();
>                 }
>             }
> }
>
> This works as intended! As soon as I click on a point, the spline now
> passes through all the control points!!
>
> However, as you can see it is pretty similar to the function above! I have
> no idea why this is happening.
>
> Any suggestions and help will be greatly appreciated!
>
> Thanks,
> Anja
>
>
>


-- 
Cheers,

Anja
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061113/faf5eea3/attachment.htm>


More information about the vtkusers mailing list