[vtkusers] Segmentation fault
elena bresciani
elena.bresciani87 at gmail.com
Tue Apr 8 03:19:31 EDT 2014
Thank you guys,
I tried changing the type of PointNormalArray in vtkDoubleArray
*vtkDoubleArray *PointNormalArray = vtkDoubleArray::SafeDownCast(
polydata->GetPointData()->GetNormals() ) ; *
but I still have the segfault.
Elena
2014-04-07 19:31 GMT+02:00 Goodwin Lawlor <goodwin.lawlor.lists at gmail.com>:
> Thanks for that link Shawn and setting me straight (I did day I could be
> wrong ;-))
>
> My logic was that if you had to do:
>
> vtkSmartPointer<vtkPolyData> polydata =
> vtkSmartPointer<vtkPolyData>::New();
>
> then initializing a smart pointer not created with the form on the RHS
> above wouldn't work...
>
> Goodwin
>
>
> On Mon, Apr 7, 2014 at 6:17 PM, Shawn Waldon <swaldon at cs.unc.edu> wrote:
>
>> Hi Goodwin,
>>
>> 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.
>> See
>> http://www.vtk.org/Wiki/VTK/Tutorials/SmartPointers#Getting_an_Object_with_a_Smart_Pointerfor details. If the reference increment is unnecessary, then it is still
>> only a small performance gain and not a segfault causing bug.
>>
>> My guess for the segfault is what Bill said: the normals are in a
>> vtkDoubleArray not a vtkFloatArray so SafeDownCast is returning NULL.
>>
>> HTH,
>>
>> Shawn
>>
>>
>> On Mon, Apr 7, 2014 at 1:11 PM, Goodwin Lawlor <
>> goodwin.lawlor.lists at gmail.com> wrote:
>>
>>> Hi Elena,
>>>
>>> I coud be wrong but I dont think this is correct:
>>>
>>> vtkSmartPointer<vtkPolyData> polydata = reader->GetOutput();
>>>
>>>
>>> reader->GetOutput() returns a regular pointer to a vtkPolydata not a
>>> smart pointer.
>>>
>>> Try:
>>>
>>> vtkPolyData *polydata = reader->GetOutput();
>>>
>>> instead.
>>>
>>> hth
>>>
>>> Goodwin
>>>
>>>
>>>
>>>
>>> On Mon, Apr 7, 2014 at 4:00 PM, elena bresciani <
>>> elena.bresciani87 at gmail.com> wrote:
>>>
>>>> Hello everybody!
>>>>
>>>> I need your help with a segmentation fault error.
>>>> Using gdb I understood where it is generated but I don't know how to
>>>> modify the code to make it run.
>>>>
>>>> Here's the portion of the code that I'm talking about:
>>>>
>>>>
>>>> *vtkSmartPointer<vtkPolyData> polydata = reader->GetOutput();*
>>>> (the reader is a vtkXMLPolyDataReader)
>>>>
>>>>
>>>>
>>>> *vtkFloatArray *PointNormalArray = vtkFloatArray::SafeDownCast(
>>>> polydata->GetPointData()->GetNormals() ) ; for(vtkIdType i = 0; i <
>>>> PointNormalArray->GetNumberOfTuples(); i++) {....}*
>>>>
>>>> everytime I call GetNumberOfTuples I have this error so I think the
>>>> problem is on PointNormalArray.
>>>>
>>>> Can somebody help me?
>>>>
>>>> Thanks in advance
>>>>
>>>> Elena
>>>>
>>>> _______________________________________________
>>>> 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
>>>>
>>>>
>>>
>>> _______________________________________________
>>> 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
>>>
>>>
>>
>>
>> --
>> Shawn Waldon
>> Graduate Research Assistant
>> Department of Computer Science
>> University of North Carolina at Chapel Hill
>> swaldon at cs.unc.edu
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140408/0e8b3d82/attachment.html>
More information about the vtkusers
mailing list