]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
PAL12003: Problem when importing IGS geometry. Export to IGES 5.3 (supporting BRep...
authorjfa <jfa@opencascade.com>
Mon, 27 Mar 2006 08:43:05 +0000 (08:43 +0000)
committerjfa <jfa@opencascade.com>
Mon, 27 Mar 2006 08:43:05 +0000 (08:43 +0000)
resources/ImportExport
src/BREPExport/BREPExport.cxx
src/BREPImport/BREPImport.cxx
src/GEOMImpl/GEOMImpl_ExportDriver.cxx
src/GEOMImpl/GEOMImpl_IImportExport.hxx
src/GEOMImpl/GEOMImpl_IInsertOperations.cxx
src/GEOMImpl/GEOMImpl_ImportDriver.cxx
src/IGESExport/IGESExport.cxx
src/IGESImport/IGESImport.cxx
src/STEPExport/STEPExport.cxx
src/STEPImport/STEPImport.cxx

index 574e0e2e3f5725870c40e72c3f734f0e735918f6..d6837858e35cfce2a543b09cc702f6113acba950 100644 (file)
@@ -1,5 +1,5 @@
 Import: BREP|IGES|STEP
-Export: BREP|IGES|STEP
+Export: BREP|IGES|IGES_5_3|STEP
 
 BREP.Import: libBREPImport.so
 BREP.Export: libBREPExport.so
@@ -8,6 +8,10 @@ BREP.Pattern: BREP Files ( *.brep )
 IGES.Import: libIGESImport.so
 IGES.Export: libIGESExport.so
 IGES.Pattern: IGES Files ( *.iges *.igs )
+IGES.ExportPattern: IGES 5.1 Files ( *.iges *.igs )
+
+IGES_5_3.Export: libIGESExport.so
+IGES_5_3.Pattern: IGES 5.3 Files ( *.iges *.igs )
 
 STEP.Import: libSTEPImport.so
 STEP.Export: libSTEPExport.so
index 2580cfac0a8438173624dd34a19ee4715630874e..2f5dd70a25159f4ef0640dd3f665daec2ab885d5 100644 (file)
@@ -44,7 +44,9 @@
 extern "C"
 {
 SALOME_WNT_EXPORT
-  int Export(const TopoDS_Shape& theShape, const TCollection_AsciiString& theFileName)
+  int Export(const TopoDS_Shape& theShape,
+             const TCollection_AsciiString& theFileName,
+             const TCollection_AsciiString& /*theFormatName*/)
   {
     MESSAGE("Export BREP into file " << theFileName.ToCString());
 
index 5412fb3e8d0f5c265bfba249ee77e45aee6dfee2..9153d14a399e54fff926f6442bf5f745f06d3fff 100644 (file)
@@ -46,6 +46,7 @@ extern "C"
 {
 SALOME_WNT_EXPORT
   TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
+                       const TCollection_AsciiString& /*theFormatName*/,
                        TCollection_AsciiString&       theError)
   {
     MESSAGE("Import BREP from file " << theFileName);
index 5898d9e1b869b314e14eb4b026ce1c2bb911964a..ecd9e7f08a94034657f5cf95805490be4a7f2735 100644 (file)
@@ -48,7 +48,9 @@
 #define UnLoadLib( handle ) dlclose( handle );
 #endif
 
-typedef int (*funcPoint)(const TopoDS_Shape&, const TCollection_AsciiString&);
+typedef int (*funcPoint)(const TopoDS_Shape&,
+                         const TCollection_AsciiString&,
+                         const TCollection_AsciiString&);
 
 //=======================================================================
 //function : GetID
@@ -90,9 +92,10 @@ Standard_Integer GEOMImpl_ExportDriver::Execute(TFunction_Logbook& log) const
   aFunction->SetValue(aShape);
 
   // retrieve the file and format names
-  TCollection_AsciiString aFileName = aCI.GetFileName();
-  TCollection_AsciiString aLibName  = aCI.GetPluginName();
-  if (aFileName.IsEmpty() || aLibName.IsEmpty())
+  TCollection_AsciiString aFileName   = aCI.GetFileName();
+  TCollection_AsciiString aFormatName = aCI.GetFormatName();
+  TCollection_AsciiString aLibName    = aCI.GetPluginName();
+  if (aFileName.IsEmpty() || aFormatName.IsEmpty() || aLibName.IsEmpty())
     return 0;
 
   // load plugin library
@@ -105,7 +108,7 @@ Standard_Integer GEOMImpl_ExportDriver::Execute(TFunction_Logbook& log) const
     return 0;
 
   // perform the export
-  int res = fp( aShape, aFileName );
+  int res = fp( aShape, aFileName, aFormatName );
 
   // unload plugin library
   UnLoadLib( anExportLib );
index efa6b2bec0a408942df0db7035d7f5db03e87627..ea9a45edfeb1ab0a254611caa9f986a7c088a933 100644 (file)
@@ -25,6 +25,7 @@
 #define EXP_ARG_REF  1
 #define EXP_ARG_FILE 2
 #define EXP_ARG_PLUG 3
+#define EXP_ARG_FORM 4
 
 class GEOMImpl_IImportExport
 {
@@ -36,15 +37,21 @@ class GEOMImpl_IImportExport
 
   Handle(GEOM_Function) GetOriginal() { return _func->GetReference(EXP_ARG_REF); }
 
-  void SetFileName(const TCollection_AsciiString& theFileName) { _func->SetString(EXP_ARG_FILE, theFileName); }
+  void SetFileName(const TCollection_AsciiString& theFileName)
+  { _func->SetString(EXP_ARG_FILE, theFileName); }
 
   TCollection_AsciiString GetFileName() { return _func->GetString(EXP_ARG_FILE); }
 
-  void SetPluginName(const TCollection_AsciiString& theFormatName)
-  { _func->SetString(EXP_ARG_PLUG, theFormatName); }
+  void SetPluginName(const TCollection_AsciiString& thePluginLibName)
+  { _func->SetString(EXP_ARG_PLUG, thePluginLibName); }
 
   TCollection_AsciiString GetPluginName() { return _func->GetString(EXP_ARG_PLUG); }
 
+  void SetFormatName(const TCollection_AsciiString& theFormatName)
+  { _func->SetString(EXP_ARG_FORM, theFormatName); }
+
+  TCollection_AsciiString GetFormatName() { return _func->GetString(EXP_ARG_FORM); }
+
  private:
 
   Handle(GEOM_Function) _func;
index 6aee3f044184b6daf4c8a6e40b0b511d3329d802..f0fc7443dfe42122a031c51e9ba9ca9424a88ebd 100644 (file)
@@ -140,16 +140,17 @@ void GEOMImpl_IInsertOperations::Export
   //Check if the function is set correctly
   if (aFunction->GetDriverGUID() != GEOMImpl_ExportDriver::GetID()) return;
 
-  //Set parameters
-  GEOMImpl_IImportExport aCI (aFunction);
-  aCI.SetOriginal(aRefFunction);
-  aCI.SetFileName(theFileName);
-
   Handle(TCollection_HAsciiString) aHLibName;
   if (!IsSupported(Standard_False, theFormatName, aHLibName)) {
     return;
   }
   TCollection_AsciiString aLibName = aHLibName->String();
+
+  //Set parameters
+  GEOMImpl_IImportExport aCI (aFunction);
+  aCI.SetOriginal(aRefFunction);
+  aCI.SetFileName(theFileName);
+  aCI.SetFormatName(theFormatName);
   aCI.SetPluginName(aLibName);
 
   //Perform the Export
@@ -195,15 +196,16 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
   //Check if the function is set correctly
   if (aFunction->GetDriverGUID() != GEOMImpl_ImportDriver::GetID()) return result;
 
-  //Set parameters
-  GEOMImpl_IImportExport aCI (aFunction);
-  aCI.SetFileName(theFileName);
-
   Handle(TCollection_HAsciiString) aHLibName;
   if (!IsSupported(Standard_True, theFormatName, aHLibName)) {
     return result;
   }
   TCollection_AsciiString aLibName = aHLibName->String();
+
+  //Set parameters
+  GEOMImpl_IImportExport aCI (aFunction);
+  aCI.SetFileName(theFileName);
+  aCI.SetFormatName(theFormatName);
   aCI.SetPluginName(aLibName);
 
   //Perform the Import
@@ -261,14 +263,18 @@ Standard_Boolean GEOMImpl_IInsertOperations::ImportTranslators
   // Read Patterns for each supported format
   int j = 1, len = theFormats->Length();
   for (; j <= len; j++) {
-    TCollection_AsciiString aPattern;
-    TCollection_AsciiString aKey (theFormats->Value(j));
-    aKey += ".Pattern";
+    TCollection_AsciiString aKey, aPattern;
+    aKey = theFormats->Value(j) + ".ImportPattern";
     if (myResMgr->Find(aKey.ToCString()))
       aPattern = myResMgr->Value(aKey.ToCString());
     else {
-      aPattern = theFormats->Value(j);
-      aPattern += " Files ( *.* )";
+      aKey = theFormats->Value(j) + ".Pattern";
+      if (myResMgr->Find(aKey.ToCString()))
+        aPattern = myResMgr->Value(aKey.ToCString());
+      else {
+        aPattern = theFormats->Value(j);
+        aPattern += " Files ( *.* )";
+      }
     }
     thePatterns->Append(aPattern);
   }
@@ -310,14 +316,18 @@ Standard_Boolean GEOMImpl_IInsertOperations::ExportTranslators
   // Read Patterns for each supported format
   int j = 1, len = theFormats->Length();
   for (; j <= len; j++) {
-    TCollection_AsciiString aPattern;
-    TCollection_AsciiString aKey (theFormats->Value(j));
-    aKey += ".Pattern";
+    TCollection_AsciiString aKey, aPattern;
+    aKey = theFormats->Value(j) + ".ExportPattern";
     if (myResMgr->Find(aKey.ToCString()))
       aPattern = myResMgr->Value(aKey.ToCString());
     else {
-      aPattern = theFormats->Value(j);
-      aPattern += " Files ( *.* )";
+      aKey = theFormats->Value(j) + ".Pattern";
+      if (myResMgr->Find(aKey.ToCString()))
+        aPattern = myResMgr->Value(aKey.ToCString());
+      else {
+        aPattern = theFormats->Value(j);
+        aPattern += " Files ( *.* )";
+      }
     }
     thePatterns->Append(aPattern);
   }
index e7c263c721a77a6f15d842c733cd3868e0aab339..1e9616700a69ede2496030324affa5d5f714be8c 100644 (file)
@@ -50,7 +50,9 @@
 #define UnLoadLib( handle ) dlclose( handle );
 #endif
 
-typedef TopoDS_Shape (*funcPoint)(const TCollection_AsciiString&, TCollection_AsciiString&);
+typedef TopoDS_Shape (*funcPoint)(const TCollection_AsciiString&,
+                                  const TCollection_AsciiString&,
+                                  TCollection_AsciiString&);
 
 //=======================================================================
 //function : GetID
@@ -84,9 +86,10 @@ Standard_Integer GEOMImpl_ImportDriver::Execute(TFunction_Logbook& log) const
   //Standard_Integer aType = aFunction->GetType();
 
   // retrieve the file and plugin library names
-  TCollection_AsciiString aFileName = aCI.GetFileName();
-  TCollection_AsciiString aLibName  = aCI.GetPluginName();
-  if (aFileName.IsEmpty() || aLibName.IsEmpty())
+  TCollection_AsciiString aFileName   = aCI.GetFileName();
+  TCollection_AsciiString aFormatName = aCI.GetFormatName();
+  TCollection_AsciiString aLibName    = aCI.GetPluginName();
+  if (aFileName.IsEmpty() || aFormatName.IsEmpty() || aLibName.IsEmpty())
     return 0;
 
   // load plugin library
@@ -100,7 +103,7 @@ Standard_Integer GEOMImpl_ImportDriver::Execute(TFunction_Logbook& log) const
 
   // perform the import
   TCollection_AsciiString anError;
-  TopoDS_Shape aShape = fp( aFileName, anError );
+  TopoDS_Shape aShape = fp( aFileName, aFormatName, anError );
 
   // unload plugin library
   UnLoadLib( anImportLib );
index 5910164608efb76c5d10c9c1b223c36bbb6714bf..1d2793d2f7b8b8edb4f89c559d4c545e14e8284c 100644 (file)
 extern "C"
 {
 SALOME_WNT_EXPORT
-  int Export(const TopoDS_Shape& theShape, const TCollection_AsciiString& theFileName)
+  int Export(const TopoDS_Shape& theShape,
+             const TCollection_AsciiString& theFileName,
+             const TCollection_AsciiString& theFormatName)
   {
     MESSAGE("Export IGES into file " << theFileName.ToCString());
-    try 
-      {
-       //VRV: OCC 4.0 migration
-       IGESControl_Controller::Init();
-       IGESControl_Writer ICW (Interface_Static::CVal("XSTEP.iges.unit"),
-                               Interface_Static::IVal("XSTEP.iges.writebrep.mode"));
-       //VRV: OCC 4.0 migration
-       
-       ICW.AddShape( theShape );
-       ICW.ComputeModel();
-       if ( ICW.Write( theFileName.ToCString() ) )
-         return 1;
-      }
-    catch(Standard_Failure) 
-      {
-       //THROW_SALOME_CORBA_EXCEPTION("Exception catched in IGESExport", SALOME::BAD_PARAM);
-      }
+    try
+    {
+      // define, whether to write only faces (5.1 IGES format)
+      // or shells and solids also (5.3 IGES format)
+      int aBrepMode = 0;
+      if (theFormatName.IsEqual("IGES_5_3"))
+        aBrepMode = 1;
+
+      // initialize writer
+      IGESControl_Controller::Init();
+      //IGESControl_Writer ICW (Interface_Static::CVal("write.iges.unit"),
+      //                       Interface_Static::IVal("write.iges.brep.mode"));
+      IGESControl_Writer ICW (Interface_Static::CVal("write.iges.unit"), aBrepMode);
+
+      // perform shape writing
+      ICW.AddShape( theShape );
+      ICW.ComputeModel();
+      if ( ICW.Write( theFileName.ToCString() ) )
+        return 1;
+    }
+    catch(Standard_Failure)
+    {
+      //THROW_SALOME_CORBA_EXCEPTION("Exception catched in IGESExport", SALOME::BAD_PARAM);
+    }
     return 0;
   }
 }
index 3a59922c9712f147abf5f9cd412cf31fd319a1f3..b6d2b953b8598e1ee4781f640043a08700494535 100644 (file)
@@ -46,6 +46,7 @@ extern "C"
 {
 SALOME_WNT_EXPORT
   TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
+                       const TCollection_AsciiString& /*theFormatName*/,
                        TCollection_AsciiString&       theError)
   {
     IGESControl_Reader aReader;
index d7ed96b6fcf22f17afe9a7cbdd020ee9ae6aa5f5..1bd902c09d8678e010f2a9b33ce290bc7c294550 100644 (file)
@@ -46,7 +46,9 @@
 extern "C"
 {
 SALOME_WNT_EXPORT
-  int Export(const TopoDS_Shape& theShape, const TCollection_AsciiString& theFileName)
+  int Export(const TopoDS_Shape& theShape,
+             const TCollection_AsciiString& theFileName,
+             const TCollection_AsciiString& /*theFormatName*/)
   {
     MESSAGE("Export STEP into file " << theFileName.ToCString());
 
index 3fb9cc511a2bec645797b29d5470f0c1cd9beced..1eb9ea062330f60aa3d500fb4968224e2fd9f004 100644 (file)
@@ -52,6 +52,7 @@ extern "C"
 {
 SALOME_WNT_EXPORT
   TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
+                       const TCollection_AsciiString& /*theFormatName*/,
                        TCollection_AsciiString&       theError)
   {
     MESSAGE("Import STEP model from file " << theFileName.ToCString());