STEPControl_Writer verbosity

Dear all,
Do you think is it possible to somehow suppress the verbose output of STEPControl_Writer::Transfer()? Or perhaps redirect the output to a custom stream? I'm working on (win32) tool which is expected to produce strictly formatted data in stdout.
ML

Here's a small sample:

#include
#include
#include
#include

int main()
{
TopoDS_Shape solid = BRepPrimAPI_MakeCylinder(1.0, 0.2);
STEPControl_Writer writer;
writer.Transfer(solid, STEPControl_AsIs);
writer.Write("cylinder.step");
std::cout }

MikkoL's picture

Figured out a possible solution based on temporary stream buffer redirection:

std::stringstream buffer;
std::streambuf *originalBuffer = std::cout.rdbuf(buffer.rdbuf());

writer.Transfer(solid, STEPControl_AsIs);
writer.Write("cylinder.step");

// buffer.str() contains now the output from STEPControl
std::cout.rdbuf(originalBuffer);

Rob Bachrach's picture

I have not checked to see if this disables the standard output, but you might try redirecting the message handler to a log file.

Before writing your file, do the following:

Handle(Message_PrinterOStream) filePrinter = new Message_PrinterOStream("export.log", Standard_False, Message_Info);
Handle(Message_Messenger) msgr = Message::DefaultMessenger();
msgr->AddPrinter(filePrinter);

Then, after writing your file, do the following:
Handle(Message_Messenger) msgr = Message::DefaultMessenger();
msgr->RemovePrinter(filePrinter);

MikkoL's picture

Hello Rob,

> I have not checked to see if this disables the standard output

I guess it does not disable stdout, but that can be handled e.g. with ios::rdbuf.

> Before writing your file, do the following:

Thanks for the tip! Seems like an elegant way to log the verbose output from OCC.

I'll certainly have to have a close look at the built-in logging techniques.

Thanks,
ML