[vtkusers] does returning "vtkPolyData" work?

Aashish Chaudhary aashish.chaudhary at kitware.com
Sun Jan 3 17:11:08 EST 2010


Zein,

Use the smart pointers all the way (for return value and for the lvalue) if
you want to use smart pointers like this.

For some more information on smart pointers .. look here.

http://www.vtk.org/Wiki/Smart_Pointers

Hope I helped.

~Regards


On Sun, Jan 3, 2010 at 11:40 AM, Zein Salah <zeinsalah at gmail.com> wrote:

> 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
> _______________________________________________
> 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
>



-- 
| Aashish Chaudhary
| R&D Engineer
| Kitware Inc.
| www.kitware.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100103/9069c2f3/attachment.htm>


More information about the vtkusers mailing list