[vtkusers] vtkPoints ...how to work with them.
David Doria
daviddoria+vtk at gmail.com
Tue Feb 16 14:33:58 EST 2010
On Tue, Feb 16, 2010 at 2:09 PM, Giancarlo Amati
<ilferraresebono at hotmail.it> wrote:
> Hello everybody, this is my code:
>
> vtkSmartPointer<vtkTransformPolyDataFilter> pdF =
> vtkTransformPolyDataFilter::New();
> pdF->SetInputConnection(pdNorm->GetOutputPort());
> pdF->SetTransform(perspT);
> pdF->Update();
>
>
> vtkSmartPointer<vtkPolyData> T_persp_pd = pdF->GetOutput();
> T_persp_pd->Update();
>
> vtkSmartPointer<vtkPoints> T_pdPoints = T_persp_pd->GetPoints();
> cout << "N points: " << T_persp_pd->GetNumberOfPoints();
>
>
> //Normalize the points
> for( int i = 0; i<T_persp_pd->GetNumberOfPoints(); i++) {
> double p[3];
> T_persp_pd->GetPoints()->GetPoint(i,p);
> cout<< "POints i: " << i << " " << p[0] << endl;
> p[0] = p[0]/p[2];
> p[1] = p[1]/p[2];
> p[2] = p[2]/p[2];
> }
>
> when I print out the 3D vector p, I always get: -1.INF0000000000 which is
> clearly a mistake. What's the problem in my code?
>
> thanks a lot!
> Giancarlo
>
Try making a controlled point set (i.e. manually add the point (1,2,3)
to a point set) and transform it. This way you will know what to
expect the result to be. If there is still a problem, then maybe you
can send a small piece of fully compilable code that demonstrates the
problem.
Thanks,
David
More information about the vtkusers
mailing list