From 023e4a6bbf926c696691560843939ec058f1cb28 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Mon, 21 Jun 2010 13:55:41 +0000
Subject: [PATCH] Reverted setFileName patch from Laurent for now, as it breaks
 the workflow for solvers (which use the filename to guess which data file to
 read). Laurent's patch would set the filename to the last merged file,
 whereas we currently want the file name to be set to the projet file, i.e.,
 the first merged file.

We should maybe think a bit harder about how to deal with this (maybe each Merge can
set the fileName, but OpenFile takes precedence?)
---
 CMakeLists.txt        |  2 +-
 Common/OpenFile.cpp   | 17 ++++++---------
 Geo/GModelFactory.h   | 51 +++++++++++++++++++++++--------------------
 Geo/GModelIO_Geo.cpp  |  4 +---
 Geo/GModelIO_Mesh.cpp |  2 +-
 5 files changed, 37 insertions(+), 39 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ab89bf5dc8..8151df8d5e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -220,7 +220,7 @@ if(ENABLE_BLAS_LAPACK)
       # on Linux also try to find ATLAS without a Fortran compiler,
       # because cmake ships with a buggy FindBLAS e.g. on Ubuntu Lucid
       # Lynx
-      set(ATLAS_LIBS_REQUIRED lapack f77blas atlas)
+      set(ATLAS_LIBS_REQUIRED lapack f77blas cblas atlas)
       find_all_libraries(LAPACK_LIBRARIES ATLAS_LIBS_REQUIRED "" "")
       if(LAPACK_LIBRARIES)
         set_config_option(HAVE_BLAS "Blas(ATLAS)")
diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp
index 98b7480935..f39bc99d97 100644
--- a/Common/OpenFile.cpp
+++ b/Common/OpenFile.cpp
@@ -216,16 +216,12 @@ void ParseString(std::string str)
   }
 }
 
-static void SetProjectName(std::string fileName)
-{
-  GModel::current()->setFileName(fileName);
-  GModel::current()->setName(SplitFileName(fileName)[1]);
-}
-
 int MergeFile(std::string fileName, bool warnIfMissing)
 {
-  if(GModel::current()->getName() == "")
-    SetProjectName(fileName);
+  if(GModel::current()->getName() == ""){
+    GModel::current()->setFileName(fileName);
+    GModel::current()->setName(SplitFileName(fileName)[1]);
+  }
 
 #if defined(HAVE_FLTK)
   if(FlGui::available())
@@ -260,7 +256,7 @@ int MergeFile(std::string fileName, bool warnIfMissing)
       if(SystemCall(std::string("gunzip -c ") + fileName + " > " + noExt))
         Msg::Error("Failed to uncompress `%s': check directory permissions", 
                    fileName.c_str());
-      SetProjectName(noExt);
+      GModel::current()->setFileName(noExt);
       return MergeFile(noExt);
     }
   }
@@ -422,7 +418,8 @@ void ClearProject()
   for(int i = GModel::list.size() - 1; i >= 0; i--)
     delete GModel::list[i];
   new GModel();
-  SetProjectName(CTX::instance()->defaultFileName);
+  GModel::current()->setFileName(CTX::instance()->defaultFileName);
+  GModel::current()->setName("");
 #if defined(HAVE_FLTK)
   if(FlGui::available()){
     FlGui::instance()->setGraphicTitle(GModel::current()->getFileName());
diff --git a/Geo/GModelFactory.h b/Geo/GModelFactory.h
index ae3f340e0e..79172fedca 100644
--- a/Geo/GModelFactory.h
+++ b/Geo/GModelFactory.h
@@ -19,7 +19,7 @@ class GModel;
 // Abstract CAD creation factory.
 class GModelFactory {
  public:
-  GModelFactory (){}
+  GModelFactory(){}
   virtual ~GModelFactory(){}
 
   // brep primitives
@@ -33,10 +33,10 @@ class GModelFactory {
   virtual GEdge *addCircleArc(GModel *gm, const arcCreationMethod &method,
                               GVertex *start, GVertex *end, 
                               const SPoint3 &aPoint) = 0;
-  virtual GEdge *addSpline (GModel *gm,const splineType &type,
-			    GVertex *start, 
-			    GVertex *end, 
-			    std::vector<std::vector<double> > controlPoints) = 0;
+  virtual GEdge *addSpline(GModel *gm,const splineType &type,
+                           GVertex *start, 
+                           GVertex *end, 
+                           std::vector<std::vector<double> > controlPoints) = 0;
   virtual GEdge *addNURBS(GModel *gm, GVertex *start, GVertex *end,
 			  std::vector<std::vector<double> > controlPoints, 
 			  std::vector<double> knots,
@@ -46,15 +46,17 @@ class GModelFactory {
   // this one tries to build a model face with one single list
   // of faces. If boundaries are co-planar, then it's a plane, 
   // otherwise, we tru ruled, sweep or other kind of surfaces
-  virtual std::vector<GFace *> addRuledFaces (GModel *gm, std::vector<std::vector<GEdge *> > edges) = 0; 
-  virtual GFace * addFace (GModel *gm, std::vector<GEdge *> edges, std::vector< std::vector<double > > points) = 0;
-  virtual GFace * addPlanarFace (GModel *gm, std::vector<std::vector<GEdge *> > edges) = 0;
+  virtual std::vector<GFace *> addRuledFaces(GModel *gm, 
+                                             std::vector<std::vector<GEdge *> > edges) = 0; 
+  virtual GFace *addFace(GModel *gm, std::vector<GEdge *> edges, 
+                         std::vector< std::vector<double > > points) = 0;
+  virtual GFace *addPlanarFace(GModel *gm, std::vector<std::vector<GEdge *> > edges) = 0;
   // sweep stuff
   virtual GEntity *revolve(GModel *gm, GEntity*, std::vector<double> p1, 
                            std::vector<double> p2, double angle) = 0;
   virtual GEntity *extrude(GModel *gm, GEntity*, std::vector<double> p1, 
                            std::vector<double> p2) = 0;
-  virtual GEntity* addPipe (GModel *gm, GEntity *base, std::vector<GEdge *> wire) = 0;
+  virtual GEntity *addPipe(GModel *gm, GEntity *base, std::vector<GEdge *> wire) = 0;
 
   // solid primitives
   virtual GEntity *addSphere(GModel *gm, double cx, double cy, double cz, 
@@ -91,15 +93,15 @@ class GModelFactory {
 
 class OCCFactory : public GModelFactory {
  public:
-  OCCFactory (){}
-  GVertex *addVertex (GModel *gm,double x, double y, double z, double lc);
-  virtual GEdge *addLine (GModel *gm,GVertex *v1, GVertex *v2);
-  GEdge *addCircleArc (GModel *gm,const arcCreationMethod &method,
-		       GVertex *start, GVertex *end, 
-		       const SPoint3 &aPoint);
-  GEdge *addSpline (GModel *gm,const splineType &type,
-		    GVertex *start, GVertex *end, 
-		    std::vector<std::vector<double> > controlPoints);
+  OCCFactory(){}
+  GVertex *addVertex(GModel *gm,double x, double y, double z, double lc);
+  virtual GEdge *addLine(GModel *gm,GVertex *v1, GVertex *v2);
+  GEdge *addCircleArc(GModel *gm,const arcCreationMethod &method,
+                      GVertex *start, GVertex *end, 
+                      const SPoint3 &aPoint);
+  GEdge *addSpline(GModel *gm,const splineType &type,
+                   GVertex *start, GVertex *end, 
+                   std::vector<std::vector<double> > controlPoints);
   GEdge *addNURBS(GModel *gm,
 		  GVertex *start, GVertex *end,
 		  std::vector<std::vector<double> > controlPoints, 
@@ -108,15 +110,16 @@ class OCCFactory : public GModelFactory {
 		  std::vector<int> multiplicity);
   GEntity *revolve(GModel *gm, GEntity*,std::vector<double> p1, 
                    std::vector<double> p2, double angle);
-  GEntity *extrude (GModel *gm, GEntity*,std::vector<double> p1,
-                    std::vector<double> p2);
-  GEntity* addPipe (GModel *gm, GEntity *base, std::vector<GEdge *> wire);
+  GEntity *extrude(GModel *gm, GEntity*,std::vector<double> p1,
+                   std::vector<double> p2);
+  GEntity *addPipe(GModel *gm, GEntity *base, std::vector<GEdge *> wire);
   GEntity *addSphere(GModel *gm,double cx, double cy, double cz, double radius); 
   GEntity *addCylinder(GModel *gm,std::vector<double> p1, std::vector<double> p2, 
                        double radius); 
-  std::vector<GFace *> addRuledFaces (GModel *gm, std::vector<std::vector<GEdge *> > edges); 
-  GFace * addFace (GModel *gm, std::vector<GEdge *> edges, std::vector< std::vector<double > > points);
-  GFace * addPlanarFace (GModel *gm, std::vector<std::vector<GEdge *> > edges);
+  std::vector<GFace *> addRuledFaces(GModel *gm, std::vector<std::vector<GEdge *> > edges); 
+  GFace *addFace(GModel *gm, std::vector<GEdge *> edges,
+                 std::vector< std::vector<double > > points);
+  GFace *addPlanarFace(GModel *gm, std::vector<std::vector<GEdge *> > edges);
   GEntity *addTorus(GModel *gm,std::vector<double> p1, std::vector<double> p2, 
 		     double radius1, double radius2); 
   GEntity *addBlock(GModel *gm,std::vector<double> p1, std::vector<double> p2); 
diff --git a/Geo/GModelIO_Geo.cpp b/Geo/GModelIO_Geo.cpp
index c15ee55094..8c5d0c15a6 100644
--- a/Geo/GModelIO_Geo.cpp
+++ b/Geo/GModelIO_Geo.cpp
@@ -39,9 +39,7 @@ void GModel::_deleteGEOInternals()
 int GModel::readGEO(const std::string &name)
 {
   ParseFile(name, true);
-	GModel *newModel=GModel::current();
-	newModel->setFileName(name);
-  return newModel->importGEOInternals();
+  return GModel::current()->importGEOInternals();
 }
 
 int GModel::exportDiscreteGEOInternals()
diff --git a/Geo/GModelIO_Mesh.cpp b/Geo/GModelIO_Mesh.cpp
index 1a4c13a7d9..31ddc532a0 100644
--- a/Geo/GModelIO_Mesh.cpp
+++ b/Geo/GModelIO_Mesh.cpp
@@ -171,7 +171,7 @@ int GModel::readMSH(const std::string &name)
     Msg::Error("Unable to open file '%s'", name.c_str());
     return 0;
   }
-	setFileName(name);
+
   char str[256] = "XXX";
   double version = 1.0;
   bool binary = false, swap = false, postpro = false;
-- 
GitLab