Replacement for Interface_Tracefile in OCC 6.3

I just switched my code from 6.2 to 6.3. In my old code, I was using Interface_Tracefile to set a log file for importing/exporting IGES & STEP files. The code was similar to this:

Interface_TraceFile::SetDefault(2, cLogFile, Standard_False);

Unfortuntely, Interface_TraceFile was removed in OCC 6.3 (actually 6.2.1). The nearest replacement I could find is:

Handle(Message_PrinterOStream) filePrinter;
filePrinter = new Message_PrinterOStream(cLogFile, Standard_False, Message_Info);
Handle(Message_Messenger) msgr = Message::DefaultMessenger();

This causes the file to be created, but none of the messages are written (the file remains empty).

Any help would be greatly appreciated.


Rob Bachrach's picture

Well, it turns out that my code was correct. However, OCC 6.3 has a bug that was preventing it from working as expected...

In the file Message_PrinterOStream, line 93 (the Send function):
if ( theGravity >= myTraceLevel || ! myStream ) return;

In theory, each setting of myTraceLevel should allow additional information:
Message_Fail -> only failures
Message_Alarm -> failures and errors
Message_Warning -> failures, errors, and warnings
Message_Info -> failures, errors, warnings, and information
Message_Trace -> all information plus internal debugging

Unfortunately, the way the code is written produces the opposite effect. The only way to get all messages is to set the value to the highest enumerated value, Message_Fail. In addition, because the code exits on >=, failure messages can never be printed.

This line of code should probable read:
if ( theGravity < myTraceLevel || ! myStream ) return;


Roman Lygin's picture

Hi Rob,
Yep, I also did notice the bug (though did not dig into the sourcecode). In Draw Test Harness:
Draw > pload ALL
Draw > xtrace 2 (this sets trace level to 2, enough for failures and warnigs)
Draw > igesbrep filename.igs shape

silently translates the file though there are warnings and failures happening there, which can later be retrieved with

Draw > tps c

So, hope the OCC team will fix that.

P Dolbey's picture