From db4f0d28c3551253e53ec2e7f5e9e50bb8e25664 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Remacle=20=28students=29?=
 <jean-francois.remacle@uclouvain.be>
Date: Mon, 21 Sep 2009 08:10:54 +0000
Subject: [PATCH] fix compile

---
 CMakeLists.txt                                |  2 +-
 Geo/GFaceCompound.cpp                         |  2 +-
 Parser/Gmsh.y                                 | 24 ++++-
 Solver/elasticitySolver.cpp                   | 20 ++---
 contrib/DiscreteIntegration/Integration3D.cpp | 10 +--
 contrib/DiscreteIntegration/recurCut.cpp      | 57 ------------
 contrib/DiscreteIntegration/recurCut.h        | 88 ++-----------------
 7 files changed, 46 insertions(+), 157 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 25842832fd..09742f650a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -69,7 +69,7 @@ set(GMSH_API
   Mesh/meshGEdge.h Mesh/meshGFace.h Mesh/meshGFaceOptimize.h 
     Mesh/meshGFaceDelaunayInsertion.h
   Solver/dofManager.h Solver/femTerm.h Solver/laplaceTerm.h Solver/elasticityTerm.h
-    Solver/linearSystem.h Solver/linearSystemGmm.h Solver/linearSystemFull.h 
+    Solver/linearSystem.h Solver/linearSystemGMM.h Solver/linearSystemFull.h 
   Post/PView.h Post/PViewData.h Plugin/PluginManager.h
   Graphics/drawContext.h
   contrib/kbipack/gmp_normal_form.h contrib/kbipack/gmp_matrix.h 
diff --git a/Geo/GFaceCompound.cpp b/Geo/GFaceCompound.cpp
index c704de7ead..fda0b1799e 100644
--- a/Geo/GFaceCompound.cpp
+++ b/Geo/GFaceCompound.cpp
@@ -22,7 +22,7 @@
 #include "distanceTerm.h"
 #include "crossConfTerm.h"
 #include "convexCombinationTerm.h"
-#include "linearSystemGmm.h"
+#include "linearSystemGMM.h"
 #include "linearSystemCSR.h"
 #include "linearSystemFull.h"
 
diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y
index f9cb4d2e7b..1bd9069618 100644
--- a/Parser/Gmsh.y
+++ b/Parser/Gmsh.y
@@ -9,7 +9,7 @@
 #include <time.h>
 #include "GmshConfig.h"
 #include "GmshMessage.h"
-#include "GmshMatrix.h"
+#include "fullMatrix.h"
 #include "MallocUtils.h"
 #include "ListUtils.h"
 #include "TreeUtils.h"
@@ -72,7 +72,7 @@ void yyerror(const char *s);
 void yymsg(int level, const char *fmt, ...);
 void skip_until(const char *skip, const char *until);
 int PrintListOfDouble(char *format, List_T *list, char *buffer);
-gmshMatrix<double> ListOfListOfDouble2Matrix(List_T *list);
+fullMatrix<double> ListOfListOfDouble2Matrix(List_T *list);
 %}
 
 %union {
@@ -1920,6 +1920,22 @@ LevelSet :
           Tree_Add(GModel::current()->getGEOInternals()->LevelSets, &l);
         }
       }
+      else if(!strcmp($2, "Reverse")){
+        int t = (int)$4;
+        if(FindLevelSet(t)){
+	  yymsg(0, "Levelset %d already exists", t);
+        }
+        else {
+          double d;
+          List_Read($7, 0, &d);
+          LevelSet *pl = FindLevelSet((int)d);
+          gLevelset *ls = NULL;
+          if(!pl) yymsg(0, "Levelset Reverse %d : unknown levelset %d", t, (int)d);
+          else ls = new gLevelsetReverse(pl->ls);
+          LevelSet *l = Create_LevelSet(t, ls);
+          Tree_Add(GModel::current()->getGEOInternals()->LevelSets, &l);
+        }
+      }
 #if !defined(HAVE_NO_POST)
       else if(!strcmp($2, "PostView")){
         int t = (int)$4;
@@ -3879,7 +3895,7 @@ int PrintListOfDouble(char *format, List_T *list, char *buffer)
   return 0;
 }
 
-gmshMatrix<double> ListOfListOfDouble2Matrix(List_T *list)
+fullMatrix<double> ListOfListOfDouble2Matrix(List_T *list)
 {
   int M = List_Nbr(list);
   int N = 0;
@@ -3887,7 +3903,7 @@ gmshMatrix<double> ListOfListOfDouble2Matrix(List_T *list)
     List_T *line = *(List_T**)List_Pointer_Fast(list, i);
     N = std::max(N, List_Nbr(line));
   }
-  gmshMatrix<double> mat(M, N);
+  fullMatrix<double> mat(M, N);
   for(int i = 0; i < M; i++){
     List_T *line = *(List_T**)List_Pointer_Fast(list, i);
     for(int j = 0; j < List_Nbr(line); j++){
diff --git a/Solver/elasticitySolver.cpp b/Solver/elasticitySolver.cpp
index a94ffafcb1..5410382b57 100644
--- a/Solver/elasticitySolver.cpp
+++ b/Solver/elasticitySolver.cpp
@@ -63,60 +63,60 @@ void elasticitySolver::readInputFile(const std::string &fn)
   FILE *f = fopen(fn.c_str(), "r");
   char what[256];
   while(!feof(f)){
-    fscanf(f, "%s", what);
+    if(fscanf(f, "%s", what) != 1) return;
     // printf("%s\n", what);
     if (!strcmp(what,"ElasticMaterial")){
       double E, nu;
       int physical;
-      fscanf(f, "%d %lf %lf", &physical, &E, &nu);
+      if(fscanf(f, "%d %lf %lf", &physical, &E, &nu) != 3) return;
       elasticConstants[physical] = std::make_pair(E, nu);    
     }
     else if (!strcmp(what, "NodalDisplacement")){
       double val;
       int node, comp;
-      fscanf(f, "%d %d %lf", &node, &comp, &val);
+      if(fscanf(f, "%d %d %lf", &node, &comp, &val) != 3) return;
       nodalDisplacements[ std::make_pair(node, comp) ] = val;    
     }
     else if (!strcmp(what, "EdgeDisplacement")){
       double val;
       int edge, comp;
-      fscanf(f, "%d %d %lf", &edge, &comp, &val);
+      if(fscanf(f, "%d %d %lf", &edge, &comp, &val) != 3) return;
       edgeDisplacements[ std::make_pair(edge, comp) ] = val;    
     }
     else if (!strcmp(what, "FaceDisplacement")){
       double val;
       int face, comp;
-      fscanf(f, "%d %d %lf", &face, &comp, &val);
+      if(fscanf(f, "%d %d %lf", &face, &comp, &val) != 3) return;
       faceDisplacements[ std::make_pair(face, comp) ] = val;    
     }
     else if (!strcmp(what, "NodalForce")){
       double val1, val2, val3;
       int node;
-      fscanf(f, "%d %lf %lf %lf", &node, &val1, &val2, &val3);
+      if(fscanf(f, "%d %lf %lf %lf", &node, &val1, &val2, &val3) != 4) return;
       nodalForces[node] = SVector3(val1, val2, val3);    
     }
     else if (!strcmp(what, "LineForce")){
       double val1, val2, val3;
       int node;
-      fscanf(f, "%d %lf %lf %lf", &node, &val1, &val2, &val3);
+      if(fscanf(f, "%d %lf %lf %lf", &node, &val1, &val2, &val3) != 4) return;
       //printf("%d %lf %lf %lf\n", node, val1, val2, val3);
       lineForces[node] = SVector3(val1, val2, val3);    
     }
     else if (!strcmp(what, "FaceForce")){
       double val1, val2, val3;
       int face;
-      fscanf(f, "%d %lf %lf %lf", &face, &val1, &val2, &val3);
+      if(fscanf(f, "%d %lf %lf %lf", &face, &val1, &val2, &val3) != 4) return;
       faceForces[face] = SVector3(val1, val2, val3);    
     }
     else if (!strcmp(what, "VolumeForce")){
       double val1, val2, val3;
       int volume;
-      fscanf(f, "%d %lf %lf %lf", &volume, &val1, &val2, &val3);
+      if(fscanf(f, "%d %lf %lf %lf", &volume, &val1, &val2, &val3) != 4) return;
       volumeForces[volume] = SVector3(val1, val2, val3);    
     }
     else if (!strcmp(what, "MeshFile")){
       char name[245];
-      fscanf(f, "%s", name);
+      if(fscanf(f, "%s", name) != 1) return;
       setMesh(name);
     }
   }
diff --git a/contrib/DiscreteIntegration/Integration3D.cpp b/contrib/DiscreteIntegration/Integration3D.cpp
index e7288d6fd7..9b21033c04 100644
--- a/contrib/DiscreteIntegration/Integration3D.cpp
+++ b/contrib/DiscreteIntegration/Integration3D.cpp
@@ -2064,7 +2064,7 @@ bool DI_Line::cut (const gLevelset &Ls, std::vector<DI_IntegrationPoint> &ip,
 
   RecurElement re(&ll);
   bool signChange = re.cut(recurLevel, this, Ls, -1., nodeLs);
-  re.pushSubLines(ll_subLines);
+  pushSubElements(&re, ll_subLines);
 
   if(signChange){
     for(int l = 0; l < (int)RPN.size(); l++) {
@@ -2162,7 +2162,7 @@ bool DI_Triangle::cut (const gLevelset &Ls, std::vector<DI_IntegrationPoint> &ip
 
   RecurElement re(&tt);
   bool signChange = re.cut(recurLevel, this, Ls, -1., nodeLs);
-  re.pushSubTriangles(tt_subTriangles);
+  pushSubElements(&re, tt_subTriangles);
 
   if(signChange){
     for(int l = 0; l < (int)RPN.size(); l++) {
@@ -2356,7 +2356,7 @@ bool DI_Quad::cut (const gLevelset &Ls, std::vector<DI_IntegrationPoint> &ip,
 
   RecurElement re(&qq);
   bool signChange = re.cut(recurLevel, this, Ls, -1., nodeLs);
-  re.pushSubQuads(qq_subQuads);
+  pushSubElements(&re, qq_subQuads);
 
   if(signChange) {
     for(int l = 0; l < (int)RPN.size(); l++) {
@@ -2565,7 +2565,7 @@ bool DI_Tetra::cut (const gLevelset &Ls, std::vector<DI_IntegrationPoint> &ip,
 
   RecurElement re(&tt);
   bool signChange = re.cut(recurLevel, this, Ls, -1., nodeLs);
-  re.pushSubTetras(tt_subTetras);
+  pushSubElements(&re, tt_subTetras);
 
   if(signChange) {
     for(int l = 0; l < (int)RPN.size(); l++) {
@@ -2749,7 +2749,7 @@ bool DI_Hexa::cut (const gLevelset &Ls, std::vector<DI_IntegrationPoint> &ip,
 
   RecurElement re(&hh);
   bool signChange = re.cut(recurLevel, this, Ls, -1., nodeLs);
-  re.pushSubHexas(hh_subHexas);
+  pushSubElements(&re, hh_subHexas);
 
   if(signChange){
     for(int l = 0; l < (int)RPN.size(); l++) {
diff --git a/contrib/DiscreteIntegration/recurCut.cpp b/contrib/DiscreteIntegration/recurCut.cpp
index b94b06ec9b..14cabddd82 100644
--- a/contrib/DiscreteIntegration/recurCut.cpp
+++ b/contrib/DiscreteIntegration/recurCut.cpp
@@ -364,63 +364,6 @@ bool RecurElement::cut(int maxlevel, const DI_Element *e, const gLevelset &LS, d
   return iC;
 }
 
-void RecurElement::pushSubLines (std::vector<DI_Line> &v)
-{
-  if(type() != DI_LIN) return;
-  if(visible)
-    v.push_back(DI_Line(*((DI_Line*)el)));
-  if(sub[0]){
-    for (int i = 0; i < nbSub(); i++)
-      sub[i]->pushSubLines(v);
-  }
-}
-
-void RecurElement::pushSubTriangles (std::vector<DI_Triangle> &v)
-{
-  if(type() != DI_TRI) return;
-  if(visible)
-    v.push_back(DI_Triangle(*((DI_Triangle*)el)));
-  if(sub[0]){
-    for (int i = 0; i < nbSub(); i++)
-      sub[i]->pushSubTriangles(v);
-  }
-}
-
-void RecurElement::pushSubQuads (std::vector<DI_Quad> &v)
-{
-  if(type() != DI_QUA) return;
-  if(visible)
-    v.push_back(DI_Quad(*((DI_Quad*)el)));
-  if(sub[0]){
-    for (int i = 0; i < nbSub(); i++)
-      sub[i]->pushSubQuads(v);
-  }
-}
-
-void RecurElement::pushSubTetras (std::vector<DI_Tetra> &v)
-{
-  if(type() != DI_TET) return;
-  if(visible)
-    v.push_back(DI_Tetra(*((DI_Tetra*)el)));
-  if(sub[0]){
-    for (int i = 0; i < nbSub(); i++)
-      sub[i]->pushSubTetras(v);
-  }
-}
-
-void RecurElement::pushSubHexas (std::vector<DI_Hexa> &v)
-{
-  if(type() != DI_HEX) return;
-  if(visible)
-    v.push_back(DI_Hexa(*((DI_Hexa*)el)));
-  if(sub[0]){
-    for (int i = 0; i < nbSub(); i++)
-      sub[i]->pushSubHexas(v);
-  }
-}
-
-
-
 
 /*
 //----------------------------------------------------------------------------------------------
diff --git a/contrib/DiscreteIntegration/recurCut.h b/contrib/DiscreteIntegration/recurCut.h
index b7d56b0f83..1144606ca2 100644
--- a/contrib/DiscreteIntegration/recurCut.h
+++ b/contrib/DiscreteIntegration/recurCut.h
@@ -25,88 +25,18 @@ class RecurElement
   // return false if the element is not crossed or run along by the levelset
   bool cut (int maxlevel, const DI_Element *e, const gLevelset &LS, double TOL = -1.,
             std::map<int, double> nodeLs[8] = NULL);
-  // push the DI_Elements of the visible RecurElements into v
-  void pushSubLines (std::vector<DI_Line> &v);
-  void pushSubTriangles (std::vector<DI_Triangle> &v);
-  void pushSubQuads (std::vector<DI_Quad> &v);
-  void pushSubTetras (std::vector<DI_Tetra> &v);
-  void pushSubHexas (std::vector<DI_Hexa> &v);
 };
 
-/*
-class RecurTriangle
+// push the DI_Elements of the visible RecurElements into v
+template <class T>
+static void pushSubElements (RecurElement *re, std::vector<T> &v)
 {
- public:
-  bool visible;
-  bool isCrossed;
-  DI_Triangle *tri;
-  RecurTriangle *sub[4];
-  RecurTriangle *super;
-  RecurTriangle(DI_Triangle triangle) : visible(false), isCrossed(false)
-  {
-    tri = new DI_Triangle(triangle);
-    sub[0] = sub[1] = sub[2] = sub[3] = super = NULL;
-  }
-  RecurTriangle (const RecurTriangle &cp) : visible(cp.visible),isCrossed(cp.isCrossed){
-    tri = new DI_Triangle(*(cp.tri));
-    for(int i=0;i<4;i++) sub[i]=cp.sub[i];
-    super = cp.super;
+  if(re->visible)
+    v.push_back(T(*((T*)re->el)));
+  if(re->sub[0]){
+    for(int i = 0; i < re->nbSub(); i++)
+      pushSubElements(re->sub[i], v);  
   }
-  ~RecurTriangle() {
-    delete tri;
-    if(sub[0]) delete sub[0];
-    if(sub[1]) delete sub[1];
-    if(sub[2]) delete sub[2];
-    if(sub[3]) delete sub[3];
-  }
-  void setVisibility (bool vis) {visible=vis;}
-  // return the reference triangle at the root of the tree structure
-  RecurTriangle* root();
-  // return a mean value of the levelset in the triangle
-  inline double V() const {return (tri->ls(0) + tri->ls(1) + tri->ls(2))/3.;}
-  // creates RecurTriangles forming a mesh of the DI_Triangle tri with refined elements close to the zero levelset
-  // return false if the triangle is not crossed or run along by the final levelset
-  bool cut (int maxlevel, const DI_Triangle *e, const std::vector<const gLevelset *> RPN, double TOL=-1.);
-  // push the DI_Triangles of the visible RecurTriangles into vT
-  void pushTriangles (std::vector<DI_Triangle> &vT);
-};
-
-class RecurQuad
-{
- public:
-  bool visible;
-  bool isCrossed;
-  DI_Quad *quad;
-  RecurQuad *sub[4];
-  RecurQuad *super;
-  RecurQuad (DI_Quad q) : visible(false), isCrossed(false)
-  {
-    quad = new DI_Quad(q);
-    sub[0] = sub[1] = sub[2] = sub[3] = super = NULL;
-  }
-  RecurQuad (const RecurQuad &cp) : visible(cp.visible),isCrossed(cp.isCrossed) {
-    quad = new DI_Quad(*(cp.quad));
-    for(int i=0;i<4;i++) sub[i]=cp.sub[i];
-    super=cp.super;
-  }
-  ~RecurQuad() {
-    delete quad;
-    if(sub[0]) delete sub[0];
-    if(sub[1]) delete sub[1];
-    if(sub[2]) delete sub[2];
-    if(sub[3]) delete sub[3];
-  }
-  void setVisibility (bool vis) {visible=vis;}
-  // return the reference quad at the root of the tree structure
-  RecurQuad* root();
-  // return a mean value of the levelset in the quad
-  inline double V() const {return (quad->ls(0) + quad->ls(1) + quad->ls(2) + quad->ls(3))/4.;}
-  // creates RecurQuads forming a mesh of the DI_Quad quad with refined elements close to the zero levelset
-  // return false if the quad is not crossed or run along by the final levelset
-  bool cut (int maxlevel, const DI_Quad *e, const std::vector<const gLevelset *> RPN, double TOL=-1.);
-  // push the DI_Quads of the visible RecurQuads into vQ
-  void pushQuads (std::vector<DI_Quad> &vQ);
-};
-*/
+}
 
 #endif
-- 
GitLab