#include <ExchangePlugin_ImportFeature.h>
#include <GeomAlgoAPI_BREPImport.h>
#include <GeomAlgoAPI_STEPImport.h>
+#include <GeomAlgoAPI_IGESImport.h>
#include <GeomAPI_Shape.h>
#include <Config_Common.h>
aShape = BREPImport::Import(aFileName, aFormatName, anError, anUnknownLabel);
} else if (aFormatName == "STEP" || aFormatName == "STP") {
aShape = STEPImport::Import(aFileName, aFormatName, anError, anUnknownLabel);
+ } else if (aFormatName == "IGES") {
+ aShape = IGESImport::Import(aFileName, aFormatName, anError, anUnknownLabel);
}
// Check if shape is valid
if ( aShape.IsNull() ) {
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#include <GeomAlgoAPI_IGESImport.h>
+
+// OOCT includes
+#include <IGESControl_Reader.hxx>
+#include <IGESData_IGESModel.hxx>
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+//extern "C" {
+namespace IGESImport {
+TopoDS_Shape Import(const TCollection_AsciiString& theFileName,
+ const TCollection_AsciiString&,
+ TCollection_AsciiString& theError, const TDF_Label&)
+{
+ #ifdef _DEBUG
+ std::cout << "Import IGES from file " << theFileName << std::endl;
+ #endif
+ TopoDS_Shape aResShape;
+
+// bool anIsIgnoreUnits = false;
+
+ IGESControl_Reader aReader;
+ try {
+ IFSelect_ReturnStatus status = aReader.ReadFile( theFileName.ToCString() );
+
+ if (status == IFSelect_RetDone) {
+// if( anIsIgnoreUnits ) {
+// // need re-scale a model, set UnitFlag to 'meter'
+// Handle(IGESData_IGESModel) aModel =
+// Handle(IGESData_IGESModel)::DownCast( aReader.Model() );
+// if( !aModel.IsNull() ) {
+// IGESData_GlobalSection aGS = aModel->GlobalSection();
+// aGS.SetUnitFlag(6);
+// aModel->SetGlobalSection(aGS);
+// }
+// }
+
+ #ifdef _DEBUG
+ std::cout << "ImportIGES : all Geometry Transfer" << std::endl;
+ #endif
+ aReader.ClearShapes();
+ aReader.TransferRoots();
+
+ #ifdef _DEBUG
+ std::cout << "ImportIGES : count of shapes produced = " << aReader.NbShapes() << std::endl;
+ #endif
+ aResShape = aReader.OneShape();
+ }
+ else {
+ switch (status) {
+ case IFSelect_RetVoid:
+ theError = "Nothing created or No data to process";
+ break;
+ case IFSelect_RetError:
+ theError = "Error in command or input data";
+ break;
+ case IFSelect_RetFail:
+ theError = "Execution was run, but has failed";
+ break;
+ case IFSelect_RetStop:
+ theError = "Execution has been stopped. Quite possible, an exception was raised";
+ break;
+ default:
+ theError = "Wrong format of the imported file. Can't import file.";
+ break;
+ }
+ aResShape.Nullify();
+ }
+ }
+ catch( Standard_Failure ) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ theError = aFail->GetMessageString();
+ aResShape.Nullify();
+ }
+
+ return aResShape;
+}
+
+}
+//}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+/*
+ * GEOMALGOAPI_IGESImport.h
+ *
+ * Created on: Dec 24, 2014
+ * Author: sbh
+ */
+
+#ifndef GEOMALGOAPI_IGESIMPORT_H_
+#define GEOMALGOAPI_IGESIMPORT_H_
+
+#include <GeomAlgoAPI.h>
+
+#include <TCollection_AsciiString.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TDF_Label.hxx>
+
+namespace IGESImport {
+
+/// Implementation of the import IGES files algorithms
+GEOMALGOAPI_EXPORT
+TopoDS_Shape Import(const TCollection_AsciiString& theFileName,
+ const TCollection_AsciiString& theFormatName,
+ TCollection_AsciiString& theError, const TDF_Label&);
+
+}
+
+#endif /* GEOMALGOAPI_IGESIMPORT_H_ */