Hi all,<br><br>How to use smart pointers with python-VTK?<br><br>Jothy<br><br><div class="gmail_quote">On Mon, Jan 4, 2010 at 11:08 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;">Hello everybody,<br>
<br>
I used smart pointers everywhere (return value, the lvalue) and it worked<br>
as supposed to be.<br>
<br>
Many Thanks,<br>
Zein<br>
<br>
@Rocco: Vielen Dank :).<br>
<br>
On Mon, Jan 4, 2010 at 8:55 AM, Rocco Gasteiger <<a href="mailto:post@rocco-gasteiger.de">post@rocco-gasteiger.de</a>> wrote:<br>
> Hello Zein,<br>
><br>
> I have two assumptions according to your smart pointer usage (I'm not very<br>
> familiar with them until yet):<br>
><br>
> 1. Maybe your polydata-pointer "polyData" is not valid outside of your<br>
> function " MyClass::GenerateCont(...)". Your solution could be in returning<br>
> "cutter->GetOutput()" directly instead of " vtkSmartPointer<vtkPolyData><br>
> polyData = cutter->GetOutput(); return polyData;"<br>
><br>
> 2. According to this VTK-Documentation:<br>
> <a href="http://www.vtk.org/Wiki/Smart_Pointers" target="_blank">http://www.vtk.org/Wiki/Smart_Pointers</a>, the return type of your function<br>
> could not be correct. Maybe you can try "vtkSmartPointer<vtkPolyData><br>
> MyClass::GenerateCont(...)" instead, additionally with "return<br>
> cutter->GetOutput();" (like above) in combination with<br>
> "vtkSmartPointer<vtkPolyData> MyPolydata = MyClass::GenerateCont(..)".<br>
><br>
> I hope this gives you a little help.<br>
><br>
> Best regards, Rocco<br>
><br>
><br>
> -----Original Message-----<br>
> From: <a href="mailto:vtkusers-bounces@vtk.org">vtkusers-bounces@vtk.org</a> [mailto:<a href="mailto:vtkusers-bounces@vtk.org">vtkusers-bounces@vtk.org</a>] On Behalf<br>
> Of Zein Salah<br>
> Sent: Sunday, January 03, 2010 5:41 PM<br>
> To: <a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a><br>
> Subject: [vtkusers] does returning "vtkPolyData" work?<br>
><br>
> 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>
><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<br>
> <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:<br>
> <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>
><br>
><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>