[vtkusers] vtkSpline

Ho Ngoc Ha ha_lennon at yahoo.com
Sat Sep 5 12:03:01 EDT 2009


Hi, these are the result
t: 0
t: 0.42105
t: 0.84210
t: 1.26316
t: 1.68421
t: 2.10526
t: 2.52632
t: 2.94737
t: 3.36842
t: 3.78947
t: 4.21053
t: 4.63158
t: 5.05263
t: 5.47368
t: 5.89474
t: 6.31579
t: 6.73684
t: 7.15789
t: 7.57895
t: 8

i don't know what's wrong with it. Please help me :(

--- On Sat, 9/5/09, Bill Lorensen <bill.lorensen at gmail.com> wrote:

From: Bill Lorensen <bill.lorensen at gmail.com>
Subject: Re: [vtkusers] vtkSpline
To: "Ho Ngoc Ha" <ha_lennon at yahoo.com>
Cc: vtkusers at vtk.org
Date: Saturday, September 5, 2009, 7:17 PM

Your code look OK. What is the resulting output of the std::cout <<
"t: " << t << std::endl;

Bill

On Sat, Sep 5, 2009 at 1:45 AM, Ho Ngoc Ha<ha_lennon at yahoo.com> wrote:
> Hi,
>
> I have a set of points, I just need to find a spline that pass through all
> of those points and generate a number of output points.
>
> Here is what I did
>
> int numberOfInputPoints = points->GetNumberOfPoints();
>
>     vtkCardinalSpline* aSplineX;
>     vtkCardinalSpline* aSplineY;
>     vtkCardinalSpline* aSplineZ;
>
>     aSplineX = vtkCardinalSpline::New();
>     aSplineY = vtkCardinalSpline::New();
>     aSplineZ = vtkCardinalSpline::New();
>
>     for (int i=0; i<numberOfInputPoints; i++)
>     {
>       double x = points->GetPoint(i)[0];
>       double y = points->GetPoint(i)[1];
>       double z = points->GetPoint(i)[2];
>           aSplineX->AddPoint(i, x);
>           aSplineY->AddPoint(i, y);
>           aSplineZ->AddPoint(i, z);
>
>     }
>
>     vtkPoints* polypoints = vtkPoints::New();
>
>
>     int numberOfOutputPoints = 20;
>
>        double t;
>        for (int i=0; i<numberOfOutputPoints; i++)
>     {
>       t
> =(double)(numberOfInputPoints-1)/(double)(numberOfOutputPoints-1)*(double)i;
>       std::cout << "t: " << t << std::endl;
>       polypoints->InsertNextPoint(aSplineX->Evaluate(t),
> aSplineY->Evaluate(t),
>                        aSplineZ->Evaluate(t));
>     }
>
>
> I thought the newly generated points will be stored in polypoints? But when
> I checked it, it only contains the first and the last point of my input
> points.
>
> I am new to vtk so please help me. Thank you very much
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090905/947458a4/attachment.htm>


More information about the vtkusers mailing list