]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #529: 4.07. Import IGES, export to BREP, STEP, IGES - Import IGES
authorSergey POKHODENKO <sergey.pokhodenko@opencascade.com>
Fri, 8 May 2015 14:27:08 +0000 (17:27 +0300)
committerSergey POKHODENKO <sergey.pokhodenko@opencascade.com>
Tue, 12 May 2015 07:00:38 +0000 (10:00 +0300)
src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp
src/ExchangePlugin/plugin-Exchange.xml
src/GeomAlgoAPI/CMakeLists.txt
src/GeomAlgoAPI/GeomAlgoAPI_IGESImport.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_IGESImport.h [new file with mode: 0644]

index 57a4e933a058b31ead2c19e0a7ee0f55607b2b01..86d0fae393ae9a7d67d4365e683c51052a525bab 100644 (file)
@@ -10,6 +10,7 @@
 #include <ExchangePlugin_ImportFeature.h>
 #include <GeomAlgoAPI_BREPImport.h>
 #include <GeomAlgoAPI_STEPImport.h>
+#include <GeomAlgoAPI_IGESImport.h>
 
 #include <GeomAPI_Shape.h>
 #include <Config_Common.h>
@@ -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() ) {
index 36f2801d51ffa6f19e3daf5623bbb18327cc0be7..56a87c04b127919bd4f184fd496c175bc3e4d64a 100644 (file)
@@ -8,7 +8,7 @@
           id="import_file_selector"
           title="Import file"
           path="">
-          <validator id="ExchangePlugin_ImportFormat" parameters="BREP:BREPImport,STEP|STP:STEPImport" />
+          <validator id="ExchangePlugin_ImportFormat" parameters="BREP:BREPImport,STEP|STP:STEPImport,IGES:IGESImport" />
         </file_selector>
       </feature>
     </group>
index 9c01c08a666f3b84d1384a825b559845dec0c7b7..944f43382d8b63483844458f6abbef342ea1502a 100644 (file)
@@ -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 (file)
index 0000000..cc46fda
--- /dev/null
@@ -0,0 +1,85 @@
+// 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;
+}
+
+}
+//}
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_IGESImport.h b/src/GeomAlgoAPI/GeomAlgoAPI_IGESImport.h
new file mode 100644 (file)
index 0000000..312b3fc
--- /dev/null
@@ -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 <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_ */