Problems saving an IGES file

Hi,

I have an issue saving a TopoDS_Shape to an IGES or STEP file. For completeness, the shape was created through BRepOffsetAPI_ThruSections and then cut with a Boolean Operation. When I write the file to an IGES file, it reports success, but I cannot load the file into any other program (ProE, CadExchanger, ...). However, if I save the Shape into a .brep file, load it into Roman's CadExchanger, and export it to IGES there, everything is fine. So I must be doing something wrong here. Can anyone help? Here is the code to save "aRes" into IGES and then BRep.

IGESControl_Controller::Init();
IGESControl_Writer ICW;
ICW.AddShape(aRes);
ICW.ComputeModel();
Standard_Boolean OK = ICW.Write("wing.igs");

BRepTools::Write(aRes, "wing.brep");

Thanks for the help.
Steven

Dennis G.'s picture

Hello Stephen,

I'm not using IGES but STEP. To export a TopoDS_Shape to a .stp file do the following:

STEPControl_Writer stpWrtr;
stpWrtr.Transfer(aRes, STEPControl_AsIs);
stpWrtr.Write("wing.stp");

Good luck,

Dennis

Volker's picture

Hello Steven,

the following method worked fine for me. But I first converted my shapes in an TDocStd_Document OCAF document.

Standard_Boolean IgesDumper::write(const Handle(TDocStd_Document)& aDoc,
const Standard_CString fname)
{
Standard_Boolean ok = Standard_True;

IGESControl_Controller::Init();

// Firstly, perform the conversion to STEP entities
IGESCAFControl_Writer writer; // derived from IGESControl_Writer

// configure IGES interface
writer.SetColorMode(Standard_True);
writer.SetNameMode (Standard_True);
writer.SetLayerMode(Standard_True);

// Translating document (conversion) to IGES
if ( !writer.Transfer ( aDoc ) ) {
cerr << "The document cannot be translated or gives no result" << endl;
return Standard_False;
}

Handle(IGESData_IGESModel) igesModel = writer.Model();
// edit IGES header start section
Handle(TCollection_HAsciiString) fileDescription
= new TCollection_HAsciiString(this->applicationInfo().c_str());
fileDescription->AssignCat(" Model");

igesModel->AddStartLine(fileDescription->ToCString());
// edit IGES header global section
std::string baseName = fileName(fname);
Handle(TCollection_HAsciiString) headerFileName
= new TCollection_HAsciiString(baseName.c_str());
Handle(TCollection_HAsciiString) headerAuthor
= new TCollection_HAsciiString(this->authorInfo().c_str());
Handle(TCollection_HAsciiString) headerOrganization
= new TCollection_HAsciiString(this->organizationInfo().c_str());
Handle(TCollection_HAsciiString) headerOriginatingSystem
= new TCollection_HAsciiString(this->applicationInfo().c_str());
Handle(TCollection_HAsciiString) headerSystemId
= new TCollection_HAsciiString(this->productInfo().c_str());

IGESData_GlobalSection globalSection = igesModel->GlobalSection();
globalSection.SetAuthorName(headerAuthor);
globalSection.SetSendName (headerOriginatingSystem);
globalSection.SetFileName (headerFileName);
globalSection.SetSystemId (headerSystemId);
//globalSection.SetReceiveName (const Handle(TCollection_HAsciiString)&val)
globalSection.SetAuthorName (headerAuthor);
globalSection.SetCompanyName (headerOrganization);
igesModel->SetGlobalSection(globalSection);

// Writing the File
writer.ComputeModel(); // maybe this can be omitted
ok = ok && writer.Write(fname);
return ok;
}