[Insight-users] SpatialObjects GetParent() problem

Luis Ibanez luis.ibanez at kitware.com
Mon May 12 11:10:54 EDT 2008


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
> 


More information about the Insight-users mailing list