STEP importer & MFC-OpenGl Software

Dear,
I'm devloping a CAD tool under visual 2005, with the interactivity (3D/2D, selection,...) managed by openGl.
I have already used the Occ libraries in this software to hollow the shapes (boolean operation) and to tesselate it.
Now, we would like to import 3D models in the STEP format.

I have devloped an STEP importer like this (summary) :

STEPControl_Reader* readerStep = new STEPControl_Reader();
readerStep->ReadFile(file);
readerStep->TransferRoots ();
TopoDS_Shape shape = readerStep->OneShape();

It works fine for the 3D parameters, but the hierarchy of the model is flat, and no name or color are imported...

I try with the CAF libraries :

STEPCAFControl_Reader reader;
reader.ReadFile( (Standard_CString) fichier);

Handle(TDocStd_Document) doc;
Handle ( XCAFApp_Application ) anApp = XCAFApp_Application::GetApplication();
anApp->NewDocument("MDTV-XCAF", doc);

reader.SetColorMode(true);
reader.SetNameMode(true);
reader.SetLayerMode(true);

if ( reader.Transfer( doc ) )
{
}

But the execution crashes during the call of the "Transfer" function.
The STEP model is ok, so I think that the trouble comes from the initialization of the "anApp" or the "doc"
because I don't develop an OCC application, but a MFC-OpenGl application !

Could you help me or advise me, please !
Thank you very much

Roman Lygin's picture

Hi Thomas,

Your code looks fine at a first glance. Can it be a problem of your file ?
Try in DRAWEXE:
Draw> pload ALL
Draw> NewDocument d MDTV-XCAF (or XmlXCAF for instance)
Draw> ReadStep d yourfile.stp

And see what happens.

OCC (OCAF) application has no conflict with MFC application. These are totally different concepts.

A couple of weeks ago I wrote a post on my blog regarding use of XDE, perhaps can be helpful (part2 is here - http://opencascade.blogspot.com/2008/12/adding-colors-and-names-to-your_...)

Good luck.
Roman

---
opencascade.blogspot.com - blog on Open CASCADE

S's picture

Hi,
I am experiencing the same issue.
Here is my DRAW.EXE output:

Draw[1]> pload ALL
Cannot load Debug Browser library. DFBrowser command is not attached
1
Draw[2]> NewDocument d MDTV-XCAF
document d created
0:1
Draw[3]> ReadStep d d:/test.stp
filename=Main:as1:::-1
filename=Main:plate:::-1
filename=Main:l-bracket assy:::-1
filename=Main:nut-bolt assy:::-1
filename=Main:nut:::-1
filename=Main:bolt:::-1
filename=Main:l-bracket:::-1
filename=Main:rod assy:::-1
filename=Main:rod:::-1
File STEP to read : d:/test.stp
Document saved with name d
Draw[4]>

I tried with another file, same crash, but the DRAW output is different :

Draw[1]> pload ALL
Cannot load Debug Browser library. DFBrowser command is not attached
1
Draw[2]> NewDocument d MDTV-XCAF
document d created
0:1
Draw[3]> ReadStep d d:/linkrods.stp
File STEP to read : d:/linkrods.stp
Document saved with name d
Draw[4]>

Same output with a XmlXCAF document.
Thanks.

S's picture

I forgot: it doesn't draw anything.

Pawel's picture

maybe the resource file is not visible... just a guess

Pawel

S's picture

I reinstalled OCC and now it works fine.
There were problems finding libraries, the code compiled, linked and ran without complaining, but wasn't doing anything correctly. People before me deleted some env var and removed unused libraries.

Thanks anyway for the help.