[Insight-users] SpatialObjects GetParent() problem

Xabier Artaechevarria Artieda xabiarta at unav.es
Fri May 9 05:43:12 EDT 2008


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

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



Gaëtan Lehmann <gaetan.lehmann at jouy.inra.fr> ha escrito:

>
> Le 9 mai 08 à 10:58, Xabier Artaechevarria Artieda a écrit :
>
>> Hi all,
>>
>> I am developing a new class inherited from BlobSpatialObject, which  
>>   I call SegmentSpatialObject.
>>
>> I have a problem when using the GetParent() method, because it    
>> returns a pointer to a SpatialObject, and not to a    
>> SegmentSpatialObject.
>> Then, with that pointer, I can not access the methods that are    
>> specific to SegmentSpatialObject.
>>
>> Is there any simple way in which GetParent() could return a    
>> SegmentSpatialObject pointer, without having to rewrite all the    
>> methods for hierarchy management?
>>
>
> Hi,
>
> Can't you simply dynamic_cast your SpatialObject pointer to a
> SegmentSpatialObject pointer?
>
> Regards,
>
> Gaëtan
>
>
> -- 
> Gaëtan Lehmann
> Biologie du Développement et de la Reproduction
> INRA de Jouy-en-Josas (France)
> tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
> http://voxel.jouy.inra.fr  http://www.mandriva.org
> http://www.itk.org  http://www.clavier-dvorak.org



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



More information about the Insight-users mailing list