From: Sergey POKHODENKO Date: Fri, 8 May 2015 14:27:08 +0000 (+0300) Subject: Issue #529: 4.07. Import IGES, export to BREP, STEP, IGES - Import IGES X-Git-Tag: V_1.2.0~162 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1e6672faca975085d23724f44e9aa7284e014c57;p=modules%2Fshaper.git Issue #529: 4.07. Import IGES, export to BREP, STEP, IGES - Import IGES --- diff --git a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp index 57a4e933a..86d0fae39 100644 --- a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -89,6 +90,8 @@ bool ExchangePlugin_ImportFeature::importFile(const std::string& theFileName) 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() ) { diff --git a/src/ExchangePlugin/plugin-Exchange.xml b/src/ExchangePlugin/plugin-Exchange.xml index 36f2801d5..56a87c04b 100644 --- a/src/ExchangePlugin/plugin-Exchange.xml +++ b/src/ExchangePlugin/plugin-Exchange.xml @@ -8,7 +8,7 @@ id="import_file_selector" title="Import file" path=""> - + diff --git a/src/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index 9c01c08a6..944f43382 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -21,6 +21,7 @@ SET(PROJECT_HEADERS GeomAlgoAPI_Placement.h GeomAlgoAPI_BREPImport.h GeomAlgoAPI_STEPImport.h + GeomAlgoAPI_IGESImport.h ) SET(PROJECT_SOURCES @@ -38,6 +39,7 @@ SET(PROJECT_SOURCES GeomAlgoAPI_Placement.cpp GeomAlgoAPI_BREPImport.cpp GeomAlgoAPI_STEPImport.cpp + GeomAlgoAPI_IGESImport.cpp ) SET(PROJECT_LIBRARIES @@ -54,6 +56,7 @@ SET(PROJECT_LIBRARIES ${CAS_TKPrim} ${CAS_TKSTEP} ${CAS_TKSTEPBase} + ${CAS_TKIGES} ${CAS_TKTopAlgo} ${CAS_TKXSBase} ) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_IGESImport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_IGESImport.cpp new file mode 100644 index 000000000..cc46fda83 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_IGESImport.cpp @@ -0,0 +1,85 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +#include + +// OOCT includes +#include +#include + +//============================================================================= +/*! + * + */ +//============================================================================= +//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; +} + +} +//} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_IGESImport.h b/src/GeomAlgoAPI/GeomAlgoAPI_IGESImport.h new file mode 100644 index 000000000..312b3fc1e --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_IGESImport.h @@ -0,0 +1,29 @@ +// 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 + +#include +#include +#include + +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_ */