TopoDS_Shape from AISContext

Hi! Im trying to work with ImportExport mfc example. I want to import a Step model a then for example use TopExp_Explorer to find all vectres. In the ImportExport example when im importing step file the CImportExport::ReadStep() function is called and all i have is the object in myAISContext. How can i get the TopoDS_Shape to explore? Is it posible without changeing the readStep() function?

Tilman Leune's picture

If you are sure your interactive object is a Shape, you can do the following:

Handle(AIS_InteractiveObject) aisShp = GetYourInteractiveObjectFromYourContext();
if(aisShp->IsKind("AIS_Shape"))
{
TopoDS_Shape myShape = Handle(AIS_Shape)::DownCast(aisShp)->Shape();
}

Mateusz Wnuczko's picture

Thanks a lot for your reply.

I have one additional question: what should i include for GetYourInteractiveObjectFromYourContext();?

Im trying to do something like template with funcionality of import/export step files. Does anybody start project from MDI mfc app and then add all the funcionality that is needed? I have tried that and everything is build without errors but when i debug my app i become error like: "Running this application was unsuccesfull, becosue the mfcsample.dll was nat found. Reinstaling this aplication should sove this problem" (this is my translation becouse im using oder languege in my visual) How can i solve this?

Regards,
Mateusz

Tilman Leune's picture

1) In order to retreive the shapes in your context, you need to query the context for them, and it will give you list you'll have to iterate through:

AIS_ListOfInteractive objList;
myAISContext->DisplayedObjects(objList);
AIS_ListIteratorOfListOfInteractive iter;
for(iter.Initialize(objList); iter.More(); iter.Next())
{
Handle(AIS_InteractiveObject) aisShp = iter.Value;
if(aisShp->IsKind("AIS_Shape"))
{
TopoDS_Shape myShape = Handle(AIS_Shape)::DownCast(aisShp)->Shape();
[...]
//now you that you got your shape, do something with it
}
}

Mfcsample.dll is a librarie OCCT ships with the samples. You need to copy this to your executable directory in order for your application to find it when started.
It should be located in c:\Program Files\OpenCASCADE6.3.1\samples\standard\mfc\release\mfcsample.dll

I guess you modified one of the samples for your application?

Mateusz Wnuczko's picture

i see... so GetYourInteractiveObjectFromYourContext(); was just an instruction for me what i have to do and not an existing function. i must be funny to you when you were reading my question:)

Thanks a loot again.

Regards,
Mateusz