Zein, <br><br>Use the smart pointers all the way (for return value and for the lvalue) if you want to use smart pointers like this. <br><br>For some more information on smart pointers .. look here. <br><br><a href="http://www.vtk.org/Wiki/Smart_Pointers">http://www.vtk.org/Wiki/Smart_Pointers</a> <br>
<br>Hope I helped. <br><br>~Regards<br><br><br><div class="gmail_quote">On Sun, Jan 3, 2010 at 11:40 AM, Zein Salah <span dir="ltr"><<a href="mailto:zeinsalah@gmail.com">zeinsalah@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hallo ,<br>
In my class, I have a function that SHOULD return a vtkPolyData, which is<br>
the result of a vtkCutter, as shown below:<br>
<br>
<br>
vtkPolyData* MyClass::GenerateCont(double cntr[], double nrml[])<br>
{<br>
<br>
vtkSmartPointer<vtkPlane> plane = vtkSmartPointer<vtkPlane>::New();<br>
plane->SetOrigin(cntr[0], cntr[1], cntr[2]);<br>
plane->SetNormal(nrml[0], nrml[1], nrml[2]);<br>
<br>
vtkSmartPointer<vtkCutter> cutter = vtkSmartPointer<vtkCutter>::New();<br>
cutter->SetInput(....); // some input vtkpolydata<br>
cutter->SetCutFunction(plane);<br>
cutter->Update();<br>
<br>
<br>
vtkSmartPointer<vtkPolyData> polyData = cutter->GetOutput();<br>
return polyData;<br>
}<br>
<br>
<br>
Now I have an array of struct, cArray, where one field of the struct is of<br>
type vtkPolyData*. When I call the GenerateCont function on the elements<br>
of the array, as follows<br>
<br>
<br>
for (int i= 0; i<num; i++) {<br>
double cntr[3]; cntr[0] = ...; cntr[1] = ...;<br>
cntr[2] = ...;<br>
double zdir[3]; zdir[0] = ...; zdir[1] =<br>
...; zdir[2] = ...;<br>
<br>
cArray[i].polyData = GenerateCont(cntr, zdir);<br>
}<br>
<br>
I noticed that the cArray is not updated. I.e. calling function GenerateCont<br>
does not return the supposed vtkPolyData. By testing whether the function<br>
GenerateCont works itself, I found that is the vtkCutter generates the<br>
output as required, only the output value is not returned.<br>
<br>
What is wrong I am doing? Is returning a vtkPolyData semantically wrong?<br>
<br>
<br>
Much thanks,<br>
Zein<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>| Aashish Chaudhary <br>| R&D Engineer <br>| Kitware Inc. <br>| <a href="http://www.kitware.com">www.kitware.com</a> <br>