[vtkusers] bizarre spline problem
Anja Ende
anja.ende at googlemail.com
Mon Nov 13 08:51:22 EST 2006
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061113/f60e1830/attachment.htm>
More information about the vtkusers
mailing list