From 5cb40de3febaf621025d9cd01104d60f1bb75289 Mon Sep 17 00:00:00 2001 From: Emilie Marchandise <emilie.marchandise@uclouvain.be> Date: Fri, 21 Oct 2011 19:26:54 +0000 Subject: [PATCH] gmshLevelset OK for python binding --- Geo/MElementCut.cpp | 2 -- Geo/gmshLevelset.h | 17 ++++++++++------- Parser/Gmsh.y | 8 ++++---- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Geo/MElementCut.cpp b/Geo/MElementCut.cpp index 676cee9c34..3146757b26 100644 --- a/Geo/MElementCut.cpp +++ b/Geo/MElementCut.cpp @@ -1338,9 +1338,7 @@ GModel *buildCutMesh(GModel *gm, gLevelset *ls, } for(DI_Point::Container::iterator it = cp.begin(); it != cp.end(); it++) delete *it; - printf("coucou delet dim =%d\n", gmEntities[i]->dim()); for(unsigned int k = 0; k < lines.size(); k++) delete lines[k]; - printf("coucou delet \n"); for(unsigned int k = 0; k < triangles.size(); k++) delete triangles[k]; for(unsigned int k = 0; k < quads.size(); k++) delete quads[k]; for(unsigned int k = 0; k < tetras.size(); k++) delete tetras[k]; diff --git a/Geo/gmshLevelset.h b/Geo/gmshLevelset.h index 1b75008932..de05cd67ed 100644 --- a/Geo/gmshLevelset.h +++ b/Geo/gmshLevelset.h @@ -271,13 +271,16 @@ class gLevelsetTools : public gLevelset { protected: std::vector<gLevelset *> children; + bool _delChildren;//flag to delete only if called from gmsh Parser public: gLevelsetTools () {} - gLevelsetTools (std::vector<gLevelset *> &p) {children = p;} + gLevelsetTools (const std::vector<gLevelset *> &p, bool delC=false) {children = p; _delChildren=delC;} gLevelsetTools (const gLevelsetTools &); - ~gLevelsetTools () { - for(int i = 0; i < (int)children.size(); i++) - delete children[i]; + virtual ~gLevelsetTools () { + if (_delChildren){ + for(int i = 0; i < (int)children.size(); i++) + delete children[i]; + } } double operator () (const double x, const double y, const double z) const { double d = (*children[0])(x, y, z); @@ -328,7 +331,7 @@ public: class gLevelsetCut : public gLevelsetTools { public: - gLevelsetCut (std::vector<gLevelset *> p) : gLevelsetTools(p) { } + gLevelsetCut (std::vector<gLevelset *> p, bool delC=false) : gLevelsetTools(p,delC) { } double choose (double d1, double d2) const { return (d1 > -d2) ? d1 : -d2; // greater of d1 and -d2 } @@ -341,7 +344,7 @@ public: class gLevelsetUnion : public gLevelsetTools { public: - gLevelsetUnion (std::vector<gLevelset *> p) : gLevelsetTools(p) { } + gLevelsetUnion (std::vector<gLevelset *> p, bool delC=false) : gLevelsetTools(p,delC) { } gLevelsetUnion(const gLevelsetUnion &lv):gLevelsetTools(lv){} virtual gLevelset * clone() const{return new gLevelsetUnion(*this);} @@ -355,7 +358,7 @@ public: class gLevelsetIntersection : public gLevelsetTools { public: - gLevelsetIntersection (std::vector<gLevelset *> p) : gLevelsetTools(p) { } + gLevelsetIntersection (std::vector<gLevelset *> p, bool delC=false) : gLevelsetTools(p,delC) { } gLevelsetIntersection(const gLevelsetIntersection &lv):gLevelsetTools(lv) { } virtual gLevelset *clone() const { return new gLevelsetIntersection(*this); } diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y index 5f3f1726a1..ae3e8afe78 100644 --- a/Parser/Gmsh.y +++ b/Parser/Gmsh.y @@ -1987,7 +1987,7 @@ LevelSet : if(!pl) yymsg(0, "Levelset Union %d : unknown levelset %d", t, (int)d); else vl.push_back(pl->ls); } - gLevelset *ls = new gLevelsetUnion(vl); + gLevelset *ls = new gLevelsetUnion(vl, True); LevelSet *l = Create_LevelSet(t, ls); Tree_Add(GModel::current()->getGEOInternals()->LevelSets, &l); } @@ -2005,7 +2005,7 @@ LevelSet : if(!pl) yymsg(0, "Levelset Intersection %d : unknown levelset %d", t, (int)d); else vl.push_back(pl->ls); } - gLevelset *ls = new gLevelsetIntersection(vl); + gLevelset *ls = new gLevelsetIntersection(vl, True); LevelSet *l = Create_LevelSet(t, ls); Tree_Add(GModel::current()->getGEOInternals()->LevelSets, &l); } @@ -2023,7 +2023,7 @@ LevelSet : if(!pl) yymsg(0, "Levelset Cut %d : unknown levelset %d", t, (int)d); else vl.push_back(pl->ls); } - gLevelset *ls = new gLevelsetCut(vl); + gLevelset *ls = new gLevelsetCut(vl, True); LevelSet *l = Create_LevelSet(t, ls); Tree_Add(GModel::current()->getGEOInternals()->LevelSets, &l); } @@ -2041,7 +2041,7 @@ LevelSet : if(!pl) yymsg(0, "Levelset Crack %d : unknown levelset %d", t, (int)d); else vl.push_back(pl->ls); } - gLevelset *ls = new gLevelsetCrack(vl); + gLevelset *ls = new gLevelsetCrack(vl, True); LevelSet *l = Create_LevelSet(t, ls); Tree_Add(GModel::current()->getGEOInternals()->LevelSets, &l); } -- GitLab