Salome HOME
PAL12003: Problem when importing IGS geometry. Export to IGES 5.3 (supporting BRep...
authorjfa <jfa@opencascade.com>
Mon, 27 Mar 2006 08:48:01 +0000 (08:48 +0000)
committerjfa <jfa@opencascade.com>
Mon, 27 Mar 2006 08:48:01 +0000 (08:48 +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 1d09a7c04da63842d4cd184bf21cea052801bfaa..127d1d49f0615e5b974b4894bdfb363a83a68fe8 100644 (file)
@@ -21,7 +21,9 @@ extern "C"
 #ifdef WNT
   __declspec(__dllexport)
 #endif
-  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 492019032e5228e9bb9b56ffd003a539bcd12f18..47981c071beaf595cc8dfa5f046e82e51be19ead 100644 (file)
@@ -23,6 +23,7 @@ extern "C"
   __declspec(__dllexport)
 #endif
   TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
+                       const TCollection_AsciiString& /*theFormatName*/,
                        TCollection_AsciiString&       theError)
   {
     MESSAGE("Import BREP from file " << theFileName);
index 21f8c4639bf2854510e3efa5dceab858fc59e22e..b055f5c31825d61940d8b70530597036830b6048 100644 (file)
@@ -28,7 +28,9 @@ using namespace std;
 #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
@@ -70,9 +72,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
@@ -85,7 +88,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 d70a033a926acb982f9a0039908266f6d908398f..b91e81787eb69ee324aade89b45e30cff1b0ea8f 100644 (file)
@@ -6,6 +6,7 @@
 #define EXP_ARG_REF  1
 #define EXP_ARG_FILE 2
 #define EXP_ARG_PLUG 3
+#define EXP_ARG_FORM 4
 
 class GEOMImpl_IImportExport
 {
@@ -17,15 +18,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 a3a60ebbeb485b3c0611498209da89e8f575d3ea..375de21e48e6b11061996f374b8209953cfd6fb7 100644 (file)
@@ -126,18 +126,19 @@ 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);
-  char* aFileName = (char*)theFileName;
-  aCI.SetFileName(aFileName);
-
   char* aFormatName = (char*)theFormatName;
   Handle(TCollection_HAsciiString) aHLibName;
   if (!IsSupported(Standard_False, aFormatName, aHLibName)) {
     return;
   }
   TCollection_AsciiString aLibName = aHLibName->String();
+
+  //Set parameters
+  GEOMImpl_IImportExport aCI (aFunction);
+  aCI.SetOriginal(aRefFunction);
+  char* aFileName = (char*)theFileName;
+  aCI.SetFileName(aFileName);
+  aCI.SetFormatName(aFormatName);
   aCI.SetPluginName(aLibName);
 
   //Perform the Export
@@ -189,17 +190,18 @@ 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);
-  char* aFileName = (char*)theFileName;
-  aCI.SetFileName(aFileName);
-
   char* aFormatName = (char*)theFormatName;
   Handle(TCollection_HAsciiString) aHLibName;
   if (!IsSupported(Standard_True, aFormatName, aHLibName)) {
     return result;
   }
   TCollection_AsciiString aLibName = aHLibName->String();
+
+  //Set parameters
+  GEOMImpl_IImportExport aCI (aFunction);
+  char* aFileName = (char*)theFileName;
+  aCI.SetFileName(aFileName);
+  aCI.SetFormatName(aFormatName);
   aCI.SetPluginName(aLibName);
 
   //Perform the Import
@@ -262,14 +264,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);
   }
@@ -311,14 +317,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 5f3fef22192809224930f5281056a72830c3f6ac..7b6497b73f0fd213804689b27bd826fc00b16d76 100644 (file)
@@ -30,7 +30,9 @@ using namespace std;
 #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
@@ -64,9 +66,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
@@ -80,7 +83,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 8ce7f9933a6bd6bef99a5da29f435253cdcda1fc..032d313c8268063c2e0b282d8e59594f3ed481b9 100644 (file)
@@ -23,26 +23,35 @@ extern "C"
 #ifdef WNT
   __declspec(__dllexport)
 #endif
-  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
+    {
+      // 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);
        
-       ICW.AddShape( theShape );
-       ICW.ComputeModel();
-       if ( ICW.Write( theFileName.ToCString() ) )
-         return 1;
-      }
+      // 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);
-      }
+    {
+      //THROW_SALOME_CORBA_EXCEPTION("Exception catched in IGESExport", SALOME::BAD_PARAM);
+    }
     return 0;
   }
 }
index f0cb68c8b9443dec63b9f5c2c1113fcff749b44b..1552243de7d11705c4d44f1027040d330c47df70 100644 (file)
@@ -23,6 +23,7 @@ extern "C"
   __declspec(__dllexport)
 #endif
   TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
+                       const TCollection_AsciiString& /*theFormatName*/,
                        TCollection_AsciiString&       theError)
   {
     IGESControl_Reader aReader;
index 83c88215bb9cbae327819ddea2499bfc391a18ca..b91eac90b97d4d282a9941ffc1d35adf9bde9e94 100644 (file)
@@ -23,7 +23,9 @@ extern "C"
 #ifdef WNT
   __declspec(__dllexport)
 #endif
-  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 02a0dd823b2e6a8b04fbb8627370e204ce1900e1..4f897463f73c4a930eaed29d59485d0a6d7f47cf 100644 (file)
@@ -29,6 +29,7 @@ extern "C"
   __declspec(__dllexport)
 #endif
   TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
+                       const TCollection_AsciiString& /*theFormatName*/,
                        TCollection_AsciiString&       theError)
   {
     MESSAGE("Import STEP model from file " << theFileName.ToCString());