From e63fac92a389cf3aa2a3fc19b2e0be9d93c66a8f Mon Sep 17 00:00:00 2001
From: Emilie Marchandise <emilie.marchandise@uclouvain.be>
Date: Wed, 14 Sep 2011 06:13:22 +0000
Subject: [PATCH] Saveall option for printing stuff

---
 Geo/GFaceCompound.cpp               |  6 +++---
 Geo/GRbf.cpp                        |  2 +-
 Mesh/meshGFace.cpp                  | 14 ++++++++------
 Mesh/meshGFaceDelaunayInsertion.cpp | 10 ++++++----
 Mesh/meshGFaceOptimize.cpp          | 16 +++++++++-------
 5 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/Geo/GFaceCompound.cpp b/Geo/GFaceCompound.cpp
index 935ff58135..c2f7e79a8f 100644
--- a/Geo/GFaceCompound.cpp
+++ b/Geo/GFaceCompound.cpp
@@ -427,7 +427,7 @@ void GFaceCompound::fillNeumannBCS() const
   }
 
   //printing
-  if(!CTX::instance()->mesh.saveAll){
+  if(CTX::instance()->mesh.saveAll){
     if (fillTris.size() > 0){
       char name[256];
       std::list<GFace*>::const_iterator itf = _compound.begin();
@@ -2071,8 +2071,8 @@ int GFaceCompound::genusGeom() const
 
 void GFaceCompound::printStuff(int iNewton) const
 {
-  //if( !CTX::instance()->mesh.saveAll) return;  
- 
+  if( !CTX::instance()->mesh.saveAll) return;  
+
   std::list<GFace*>::const_iterator it = _compound.begin();
  
   char name0[256], name1[256], name2[256], name3[256];
diff --git a/Geo/GRbf.cpp b/Geo/GRbf.cpp
index b7dce8a7fd..e921d4a7d7 100644
--- a/Geo/GRbf.cpp
+++ b/Geo/GRbf.cpp
@@ -220,7 +220,7 @@ void GRbf::buildOctree(double radius){
 //compute curvature from level set
 
 void GRbf::curvatureRBF(const fullMatrix<double> &cntrs,
-		     fullMatrix<double> &curvature){
+			fullMatrix<double> &curvature){
 
   fullMatrix<double> extX, surf, sx,sy,sz, sxx,syy,szz, sxy,sxz,syz,sLap;
   setup_level_set(cntrs,normals,extX, surf);
diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp
index e3bb665277..f747fe2ee1 100644
--- a/Mesh/meshGFace.cpp
+++ b/Mesh/meshGFace.cpp
@@ -1597,12 +1597,14 @@ void meshGFace::operator() (GFace *gf)
   if (backgroundMesh::current()){
     backgroundMesh::unset();
   }    
-  backgroundMesh::set(gf);
-  char name[256];
-  sprintf(name,"bgm-%d.pos",gf->tag());
-  backgroundMesh::current()->print(name,gf);
-  sprintf(name,"cross-%d.pos",gf->tag());
-  backgroundMesh::current()->print(name,gf,1);
+  if (CTX::instance()->mesh.saveAll){
+    backgroundMesh::set(gf);
+    char name[256];
+    sprintf(name,"bgm-%d.pos",gf->tag());
+    backgroundMesh::current()->print(name,gf);
+    sprintf(name,"cross-%d.pos",gf->tag());
+    backgroundMesh::current()->print(name,gf,1);
+  }
   (*this)(gf);
 }
 
diff --git a/Mesh/meshGFaceDelaunayInsertion.cpp b/Mesh/meshGFaceDelaunayInsertion.cpp
index 4b8c37725f..1c09478da7 100644
--- a/Mesh/meshGFaceDelaunayInsertion.cpp
+++ b/Mesh/meshGFaceDelaunayInsertion.cpp
@@ -1185,10 +1185,12 @@ void bowyerWatsonFrontalLayers(GFace *gf, bool quad)
     CTX::instance()->mesh.lcFromCurvature = CurvControl;    
     backgroundMesh::set(gf);
     char name[256];
-    sprintf(name,"bgm-%d.pos",gf->tag());
-    backgroundMesh::current()->print(name,gf);
-    sprintf(name,"cross-%d.pos",gf->tag());
-    backgroundMesh::current()->print(name,gf,1);
+    if (CTX::instance()->mesh.saveAll){
+      sprintf(name,"bgm-%d.pos",gf->tag());
+      backgroundMesh::current()->print(name,gf);
+      sprintf(name,"cross-%d.pos",gf->tag());
+      backgroundMesh::current()->print(name,gf,1);
+    }
     // FIXME DELETE CURRENT MESH
     gf->triangles = TR;    
   }
diff --git a/Mesh/meshGFaceOptimize.cpp b/Mesh/meshGFaceOptimize.cpp
index e1c4131aaa..2ce231bbfb 100644
--- a/Mesh/meshGFaceOptimize.cpp
+++ b/Mesh/meshGFaceOptimize.cpp
@@ -1872,18 +1872,19 @@ void recombineIntoQuads(GFace *gf,
   double t1 = Cpu();
 
   bool haveParam = true;
+  bool saveAll = CTX::instance()->mesh.saveAll;
   if(gf->geomType() == GEntity::DiscreteSurface && !gf->getCompound())
     haveParam = false;
 
   if(haveParam && topologicalOpti)
     removeFourTrianglesNodes(gf, false);
 
-  gf->model()->writeMSH("before.msh");
+  if (saveAll) gf->model()->writeMSH("before.msh");
   int success = _recombineIntoQuads(gf, 0);
 
   // gf->addLayersOfQuads(1, 0);
 
-  gf->model()->writeMSH("raw.msh");
+  if (saveAll) gf->model()->writeMSH("raw.msh");
   if(haveParam && nodeRepositioning)
     laplaceSmoothing(gf, CTX::instance()->mesh.nbSmoothing);
 
@@ -1891,17 +1892,18 @@ void recombineIntoQuads(GFace *gf,
   if(success && CTX::instance()->mesh.algoRecombine == 1){
     if(topologicalOpti){
       if(haveParam){
-        gf->model()->writeMSH("smoothed.msh");
+        if (saveAll) gf->model()->writeMSH("smoothed.msh");
         int COUNT = 0;
         char NAME[256];
+
         while(1){
           int x = removeTwoQuadsNodes(gf);
-          if(x){ sprintf(NAME,"iter%dTQ.msh",COUNT++); gf->model()->writeMSH(NAME);}
+          if(x && saveAll){ sprintf(NAME,"iter%dTQ.msh",COUNT++); gf->model()->writeMSH(NAME);}
           int y = removeDiamonds(gf);
-          if(y){ sprintf(NAME,"iter%dD.msh",COUNT++); gf->model()->writeMSH(NAME); }
+          if(y && saveAll){ sprintf(NAME,"iter%dD.msh",COUNT++); gf->model()->writeMSH(NAME); }
           laplaceSmoothing(gf);
           int z = 0; //edgeSwapQuadsForBetterQuality(gf);
-          if(z){ sprintf(NAME,"iter%dS.msh",COUNT++); gf->model()->writeMSH(NAME); }
+          if(z && saveAll){ sprintf(NAME,"iter%dS.msh",COUNT++); gf->model()->writeMSH(NAME); }
           if (!(x+y+z)) break;
         }
       }
@@ -1920,7 +1922,7 @@ void recombineIntoQuads(GFace *gf,
   _recombineIntoQuads(gf, 0);
   if(haveParam)  laplaceSmoothing(gf, CTX::instance()->mesh.nbSmoothing);
 
-  //  gf->model()->writeMSH("after.msh");
+  if (saveAll) gf->model()->writeMSH("after.msh");
 
   double t2 = Cpu();
   Msg::Info("Simple recombination algorithm completed (%g s)", t2 - t1);
-- 
GitLab