[Insight-users] SpatialObjects GetParent() problem

Xabier Artaechevarria Artieda xabiarta at unav.es
Tue May 13 03:55:47 EDT 2008


Hi Luis,

Thanks for your answer. I had:

SegmentSpatialObject::Pointer auxSegment2 = dynamic_cast<
            SegmentSpatialObject *> (auxSegment->GetParent());

instead of:

SegmentSpatialObject * auxSegment2 = dynamic_cast<
            SegmentSpatialObject *> (auxSegment->GetParent());

and that caused the runtime error.

Thanks for your help!
Xabier

-- 
Xabier Artaechevarria
Cancer Imaging Laboratory
Centre for Applied Medical Research
www.cima.es



Luis Ibanez <luis.ibanez at kitware.com> ha escrito:

>
> Hi Xabier,
>
> The second expression:
>
> SegmentSpatialObject * auxSegment2 = dynamic_cast<
>           SegmentSpatialObject *> (auxSegment->GetParent());
>
>
> should be the right one to use.
>
>
> Does the runtime that you get happens because
>
>           auxSegment2 == 0  ?
>
> If so, there may be something wrong in the declaration
> of derivation of your SegmentationSpatialObject.
>
> Could you please post to the list the header (.h) file
> of your class ?
>
>
>    Thanks
>
>
>       Luis
>
>
> ------------------------------------
> Xabier Artaechevarria Artieda wrote:
>> Thanks for your answer, Gaetan.
>>
>> How should I do the dynamic_cast, though?
>>
>> If I do:
>>
>> auxSegment = dynamic_cast<SegmentSpatialObject::Pointer>    
>> (auxSegment->GetParent());
>>
>> it does not compile (invalid target type for dynamic_cast)
>>
>> And if I do:
>> auxSegment2 = dynamic_cast<SegmentSpatialObject*> (auxSegment->GetParent());
>>
>> I get a runtime error.
>>
>> Regards,
>> Xabi
>>



----------------------------------------------------------------
Este mensaje ha sido enviado desde https://webmail.unav.es



More information about the Insight-users mailing list