Salome HOME
PAL10324. Fix MakePartition() for the case theMaterials.IsNull()
[modules/geom.git] / src / GEOMImpl / GEOMImpl_IInsertOperations.cxx
index 3ef52949892fb3a66a3b99da22d0d39e756a915a..54155661bac4ab7de8dcf9007c320b1c3fb2b852 100644 (file)
@@ -1,3 +1,22 @@
+// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 #include <Standard_Stream.hxx>
 
 #include <GEOMImpl_IInsertOperations.hxx>
@@ -121,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
@@ -176,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
@@ -242,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);
   }
@@ -291,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);
   }
@@ -358,12 +387,21 @@ Standard_Boolean GEOMImpl_IInsertOperations::InitResMgr()
 #else
     aResDir += "/share/salome/resources";
 #endif
-    TCollection_AsciiString aUserResDir (getenv("HOME"));
+    char * dir = getenv("GEOM_ENGINE_RESOURCES_DIR");
+    TCollection_AsciiString aUserResDir;
+    if ( dir )
+    {
+      aUserResDir = dir;
+    }
+    else
+    {
+      aUserResDir = getenv("HOME");
 #ifdef WNT
-    aUserResDir += "\\.salome\\resources";
+      aUserResDir += "\\.salome\\resources";
 #else
-    aUserResDir += "/.salome/resources";
+      aUserResDir += "/.salome/resources";
 #endif
+    }
     myResMgr = new Resource_Manager ("ImportExport", aResDir, aUserResDir, Standard_False);
 
     if (!myResMgr->Find("Import") && !myResMgr->Find("Export")) {