How do you get the TopoDS_Shape back from MyAisObject in the OCC example?

eue

CAD practitioner
According to the OCC example here, MyAisObject is a inherent class of AIS_InteractiveObject.

What I am trying to do is get the TopoDS_Shape from a MyAisObject class object, which should be the same as the one made in Compute() member function of MyAisObject class.

Now, I cannot directly downcast MyAisObject to AIS_Shape, and then get the TopoDS_Shape from AIS_Shape. The reason is because MyAisObject is in no relation to AIS_Shape.

I try to cast the MyAisObject to AIS_InteractiveObject first and then cast AIS_InteractiveObject to AIS_Shape. The result is a NULL Handle(AIS_Shape).
 

Attachments

  • 212603.png
    212603.png
    102.5 KB · Views: 4

Jonathan

CAD community veteran
if you use isKind method you will be able to see what kind of ais object

if(anObj->isKind(STANDARD_TYPE(MyAisObject)) {
// nice' its myaisobject. let do stuff with it!
}

I am not sure you may need to hold a ref to the TopoDS_Shape in your MyAisObject to be able to retrieve it easily.

I am curious how people handle this kind of situation..
 

eue

CAD practitioner
if you use isKind method you will be able to see what kind of ais object

if(anObj->isKind(STANDARD_TYPE(MyAisObject)) {
// nice' its myaisobject. let do stuff with it!
}

I am not sure you may need to hold a ref to the TopoDS_Shape in your MyAisObject to be able to retrieve it easily.

I am curious how people handle this kind of situation..
I have solved the problem. In my case is just to simply inherent from AIS_Shape instead of InteractiveObject. AIS_Shape have myshape which is the TopoDS_Shape of the AIS_Object.
 
Top