I had a colleague have a quick look over the code and they found the issue.
I was deleting test (which was a pointer to the current data object) when I
shouldn't have been, which is why the iterator gave a segmentation fault.
Sorry for wasting your time on this.

Adriano


===================================

Adriano Gagliardi MEng PhD
Business Sector Leader
Computational Aerodynamics
Aircraft Research Association Ltd.
Manton Lane
Bedford

Tel: 01234 32 4644
E-mail: [email protected]
Url: www.ara.co.uk 
-----Original Message-----
From: Utkarsh Ayachit [mailto:[email protected]] 
Sent: 31 March 2010 18:47
To: Paul Edwards
Cc: [email protected]; ParaView
Subject: Re: [Paraview] vtkCompositeDataIterator and GoToFirstItem()

GoToFirstItem() and InitTraversal() are almost equivalent, so that should
not matter. What's happening in "//do something here". Are you sure test
remains valid at the end of it?

Utkarsh

On Wed, Mar 31, 2010 at 1:41 PM, Paul Edwards <[email protected]>
wrote:
> Do you need to call InitTraversal first?
>
> Regards,
> Paul
>
> On 31 March 2010 17:30, Adriano Gagliardi <[email protected]> wrote:
>>
>> Sorry, I forgot to mention that. The seg fault occurs when the new 
>> vtkCompositeDataIterator is created at i=1. I just realised the first 
>> block of code I posted was wrong anyway. This is the correct (but not 
>> working)
>> routine:
>>
>>       for ( vtkIdType i = 0; i != max; ++i ) {
>>         vtkCompositeDataIterator* iter = test->NewIterator();
>>         iter->GoToFirstItem();
>>         for ( int j = 0; j != test->GetNumberOfBlocks(); ++j ) {
>>           //do something here
>>
>>            iter->GoToNextItem();
>>         }
>>         iter->Delete();
>>       }
>>
>> I'm assuming that what I'm trying just isn't possible, but it would 
>> be nice to know if there is a way of achieving this.
>>
>> Adriano
>>
>> ===================================
>>
>> Adriano Gagliardi MEng PhD
>> Business Sector Leader
>> Computational Aerodynamics
>> Aircraft Research Association Ltd.
>> Manton Lane
>> Bedford
>>
>> Tel: 01234 32 4644
>> E-mail: [email protected]
>> Url: www.ara.co.uk
>> -----Original Message-----
>> From: Utkarsh Ayachit [mailto:[email protected]]
>> Sent: 31 March 2010 17:23
>> To: [email protected]
>> Cc: ParaView
>> Subject: Re: [Paraview] vtkCompositeDataIterator and GoToFirstItem()
>>
>> You might want to attach a debugger and produce a stack trace to see 
>> where you are getting a segfault.
>>
>>
>>
>> On Wed, Mar 31, 2010 at 12:12 PM, Adriano Gagliardi 
>> <[email protected]>
>> wrote:
>>>
>>> I'm using the vtkCompositeDataIterator to iterate over a multiblock 
>>> data-set multiple times. I'd like to reuse the iterator I create in 
>>> the first instance by using GoToFirstItem after it has finished the 
>>> traversal, but I'm getting a segmentation fault. Is this possible or 
>>> am I
>> doing this wrong?
>>> Example code below:
>>>
>>
>>>
>>>
>>> It works when the for loops are switched around. I'm just interested 
>>> to see what the performance difference is between them:
>>>
>>>        vtkCompositeDataIterator* iter = test->NewIterator();
>>>      iter->GoToFirstItem();
>>>        for ( int j = 0; j != test->GetNumberOfBlocks(); ++j ) {
>>>        for ( vtkIdType i = 0; i != max; ++i ) {
>>>          //do something here
>>>        }
>>>        iter->GoToNextItem();
>>>      }
>>>      iter->Delete();
>>>
>>> Cheers,
>>>
>>> Adriano
>>>
>>> ===================================
>>>
>>> Adriano Gagliardi MEng PhD
>>> Business Sector Leader
>>> Computational Aerodynamics
>>> Aircraft Research Association Ltd.
>>> Manton Lane
>>> Bedford
>>>
>>> Tel: 01234 32 4644
>>> E-mail: [email protected]
>>> Url: www.ara.co.uk
>>>
>>>
>>> ---------------------------
>>> This email contains information that is private and confidential and 
>>> is
>> intended only for the addressee.  If you are not the intended 
>> recipient please delete it and notify us immediately by e-mailing the
sender.
>>> Note: All email sent to or from this address may be accessed by 
>>> someone
>> other than the recipient, for system management and security reasons.
>>> Aircraft Research Association Ltd.  Registered in England, 
>>> Registration No 503668 Registered Office: Manton Lane, Bedford MK41 
>>> 7PF England VAT No GB 196351245
>>>
>>>
>>> _______________________________________________
>>> 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 ParaView Wiki at:
>>> http://paraview.org/Wiki/ParaView
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.paraview.org/mailman/listinfo/paraview
>>>
>>
>>
>> ---------------------------
>> This email contains information that is private and confidential and is
intended only for the addressee.  If you are not the intended recipient
please delete it and notify us immediately by e-mailing the sender.
>> Note: All email sent to or from this address may be accessed by someone
other than the recipient, for system management and security reasons.
>> Aircraft Research Association Ltd.  Registered in England, 
>> Registration No 503668 Registered Office: Manton Lane, Bedford MK41 
>> 7PF England VAT No GB 196351245
>>
>>
>> _______________________________________________
>> 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 ParaView Wiki at: 
>> http://paraview.org/Wiki/ParaView
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.paraview.org/mailman/listinfo/paraview
>>
>


---------------------------
This email contains information that is private and confidential and is 
intended only for the addressee.  If you are not the intended recipient please 
delete it and notify us immediately by e-mailing the sender.
Note: All email sent to or from this address may be accessed by someone other 
than the recipient, for system management and security reasons.
Aircraft Research Association Ltd.  Registered in England, Registration No 
503668 Registered Office: Manton Lane, Bedford MK41 7PF England VAT No GB 
196351245


_______________________________________________
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 ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview

Reply via email to