[vtkusers] does returning "vtkPolyData" work?

Zein Salah zeinsalah at gmail.com
Sun Jan 3 11:40:45 EST 2010


Hallo ,
In my class, I have a function that SHOULD return a vtkPolyData, which is
the result of a vtkCutter, as shown below:


vtkPolyData* MyClass::GenerateCont(double cntr[], double nrml[])
{

    vtkSmartPointer<vtkPlane> plane = vtkSmartPointer<vtkPlane>::New();
    plane->SetOrigin(cntr[0], cntr[1], cntr[2]);
    plane->SetNormal(nrml[0], nrml[1], nrml[2]);
	
    vtkSmartPointer<vtkCutter> cutter = vtkSmartPointer<vtkCutter>::New();		
    cutter->SetInput(....); // some input vtkpolydata
    cutter->SetCutFunction(plane);
    cutter->Update();


    vtkSmartPointer<vtkPolyData> polyData = cutter->GetOutput();
    return polyData;
}


Now I have an array of struct, cArray, where one field of the struct is of
type vtkPolyData*. When I call the GenerateCont function on the elements
of the array, as follows


for (int i= 0; i<num; i++) {
     double       cntr[3];      cntr[0] = ...; 	   cntr[1] = ...;
      cntr[2] = ...;
     double       zdir[3];      zdir[0] = ...;            zdir[1] =
...;             zdir[2] = ...;

     cArray[i].polyData = GenerateCont(cntr, zdir);
}

I noticed that the cArray is not updated. I.e. calling function GenerateCont
does not return the supposed vtkPolyData. By testing whether the function
GenerateCont works itself, I found that is the vtkCutter generates the
output as required, only the output value is not returned.

What is wrong I am doing? Is returning a vtkPolyData semantically wrong?


Much thanks,
Zein



More information about the vtkusers mailing list