<div dir="ltr">Thanks for that link Shawn and setting me straight (I did day I could be wrong ;-))<div><br></div><div>My logic was that if you had to do:</div><div><br></div><div>vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();</div>
<div><br></div><div>then initializing a smart pointer not created with the form on the RHS above wouldn't work...</div><div><br></div><div>Goodwin</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 7, 2014 at 6:17 PM, Shawn Waldon <span dir="ltr"><<a href="mailto:swaldon@cs.unc.edu" target="_blank">swaldon@cs.unc.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Goodwin,<div><br></div><div>It shouldn't be causing the segfault. That line will create a new smart pointer and set its internal pointer to the reader's output, incrementing the reference count.</div>
<div>See <a href="http://www.vtk.org/Wiki/VTK/Tutorials/SmartPointers#Getting_an_Object_with_a_Smart_Pointer" target="_blank">http://www.vtk.org/Wiki/VTK/Tutorials/SmartPointers#Getting_an_Object_with_a_Smart_Pointer</a> for details. If the reference increment is unnecessary, then it is still only a small performance gain and not a segfault causing bug.</div>
<div><br></div><div>My guess for the segfault is what Bill said: the normals are in a vtkDoubleArray not a vtkFloatArray so SafeDownCast is returning NULL.</div><div><br></div><div>HTH,</div><div><br></div><div>Shawn</div>
</div><div class="gmail_extra"><div><div class="h5"><br><br><div class="gmail_quote">On Mon, Apr 7, 2014 at 1:11 PM, Goodwin Lawlor <span dir="ltr"><<a href="mailto:goodwin.lawlor.lists@gmail.com" target="_blank">goodwin.lawlor.lists@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Elena,<div><br></div><div>I coud be wrong but I dont think this is correct:</div><div><div>
<br>
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
vtkSmartPointer<vtkPolyData> polydata = reader->GetOutput();</blockquote><div><br></div></div><div>reader->GetOutput() returns a regular pointer to a vtkPolydata not a smart pointer.</div><div><br></div><div>
Try:</div>
<div><br></div><div>vtkPolyData *polydata = reader->GetOutput();</div><div><br></div><div>instead.</div><div><br></div><div>hth</div><span><font color="#888888"><div><br></div><div>Goodwin</div><div><br>
</div><div><br></div></font></span></div><div class="gmail_extra">
<br><br><div class="gmail_quote"><div><div>On Mon, Apr 7, 2014 at 4:00 PM, elena bresciani <span dir="ltr"><<a href="mailto:elena.bresciani87@gmail.com" target="_blank">elena.bresciani87@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
<div dir="ltr">Hello everybody!<br><br>I need your help with a segmentation fault error.<br>Using gdb I understood where it is generated but I don't know how to modify the code to make it run.<br><br>Here's the portion of the code that I'm talking about:<br>
<br><br><i>vtkSmartPointer<vtkPolyData> polydata = reader->GetOutput();</i><br>(the reader is a vtkXMLPolyDataReader)<br><br><i>vtkFloatArray *PointNormalArray = vtkFloatArray::SafeDownCast( polydata->GetPointData()->GetNormals() ) ; <br>
<br>for(vtkIdType i = 0; i < PointNormalArray->GetNumberOfTuples(); i++) {....}</i><br> <br>everytime I call GetNumberOfTuples I have this error so I think the problem is on PointNormalArray.<br><br>Can somebody help me?<br>
<br>Thanks in advance<span><font color="#888888"><br><br>Elena<br></font></span></div>
<br></div></div><div>_______________________________________________<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>
<br></div></blockquote></div><br></div>
<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>
<br></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div dir="ltr">Shawn Waldon<div>Graduate Research Assistant</div><div>Department of Computer Science</div>
<div>University of North Carolina at Chapel Hill</div>
<div><a href="mailto:swaldon@cs.unc.edu" target="_blank">swaldon@cs.unc.edu</a></div></div>
</font></span></div>
</blockquote></div><br></div>