Skip to content
Snippets Groups Projects
Commit 11b713e3 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

refactoring

parent 6c95b220
Branches
Tags
No related merge requests found
...@@ -27,27 +27,7 @@ ...@@ -27,27 +27,7 @@
#include "Parser.h" #include "Parser.h"
#endif #endif
// GEO_Internals routines void GEO_Internals::_allocateAll()
int compareVertex(const void *a, const void *b);
int compareSurfaceLoop(const void *a, const void *b);
int compareEdgeLoop(const void *a, const void *b);
int compareCurve(const void *a, const void *b);
int compareSurface(const void *a, const void *b);
int compareVolume(const void *a, const void *b);
int compareLevelSet(const void *a, const void *b);
int comparePhysicalGroup(const void *a, const void *b);
void Free_Vertex(void *a, void *b);
void Free_PhysicalGroup(void *a, void *b);
void Free_EdgeLoop(void *a, void *b);
void Free_SurfaceLoop(void *a, void *b);
void Free_Curve(void *a, void *b);
void Free_Surface(void *a, void *b);
void Free_Volume(void *a, void *b);
void Free_LevelSet(void *a, void *b);
void GEO_Internals::alloc_all()
{ {
MaxPointNum = MaxLineNum = MaxLineLoopNum = MaxSurfaceNum = 0; MaxPointNum = MaxLineNum = MaxLineLoopNum = MaxSurfaceNum = 0;
MaxSurfaceLoopNum = MaxVolumeNum = MaxPhysicalNum = 0; MaxSurfaceLoopNum = MaxVolumeNum = MaxPhysicalNum = 0;
...@@ -61,7 +41,7 @@ void GEO_Internals::alloc_all() ...@@ -61,7 +41,7 @@ void GEO_Internals::alloc_all()
PhysicalGroups = List_Create(5, 5, sizeof(PhysicalGroup *)); PhysicalGroups = List_Create(5, 5, sizeof(PhysicalGroup *));
} }
void GEO_Internals::free_all() void GEO_Internals::_freeAll()
{ {
MaxPointNum = MaxLineNum = MaxLineLoopNum = MaxSurfaceNum = 0; MaxPointNum = MaxLineNum = MaxLineLoopNum = MaxSurfaceNum = 0;
MaxSurfaceLoopNum = MaxVolumeNum = MaxPhysicalNum = 0; MaxSurfaceLoopNum = MaxVolumeNum = MaxPhysicalNum = 0;
...@@ -75,12 +55,25 @@ void GEO_Internals::free_all() ...@@ -75,12 +55,25 @@ void GEO_Internals::free_all()
List_Action(PhysicalGroups, Free_PhysicalGroup); List_Delete(PhysicalGroups); List_Action(PhysicalGroups, Free_PhysicalGroup); List_Delete(PhysicalGroups);
} }
void GEO_Internals::reset_physicals() void GEO_Internals::resetPhysicalGroups()
{ {
List_Action(PhysicalGroups, Free_PhysicalGroup); List_Action(PhysicalGroups, Free_PhysicalGroup);
List_Reset(PhysicalGroups); List_Reset(PhysicalGroups);
} }
void GEO_Internals::addVertex(int num, double x, double y, double z, double lc)
{
Vertex *v = Create_Vertex(num, x, y, z, lc, 1.0);
Tree_Add(Points, &v);
}
void GEO_Internals::addVertex(int num, double x, double y, gmshSurface *surface,
double lc)
{
Vertex *v = Create_Vertex(num, x, y, surface, lc);
Tree_Add(Points, &v);
}
// GModel interface // GModel interface
void GModel::_createGEOInternals() void GModel::_createGEOInternals()
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
class GEO_Internals{ class GEO_Internals{
private: private:
void alloc_all(); void _allocateAll();
void free_all(); void _freeAll();
public: public:
// FIXME: all this must (will) become private ; and all the direct calls in // FIXME: all this must (will) become private ; and all the direct calls in
// Gmsh.y should (will) go through an integer-based API similar to the one in // Gmsh.y should (will) go through an integer-based API similar to the one in
...@@ -45,18 +45,19 @@ class GEO_Internals{ ...@@ -45,18 +45,19 @@ class GEO_Internals{
std::map<int, MasterFace> periodicFaces; std::map<int, MasterFace> periodicFaces;
public: public:
GEO_Internals(){ alloc_all(); } GEO_Internals(){ _allocateAll(); }
~GEO_Internals(){ free_all(); } ~GEO_Internals(){ _freeAll(); }
void destroy(){ free_all(); alloc_all(); } void destroy(){ _freeAll(); _allocateAll(); }
void reset_physicals(); void resetPhysicalGroups();
void addCompoundMesh(int dim, List_T *_list) void addCompoundMesh(int dim, List_T *_list)
{ {
std::vector<int> compound; std::vector<int> compound;
for(int i = 0; i < List_Nbr(_list); i++) for(int i = 0; i < List_Nbr(_list); i++)
compound.push_back((int)*(double*)List_Pointer(_list, i)); compound.push_back((int)*(double*)List_Pointer(_list, i));
meshCompounds.insert(std::make_pair(dim,compound)); meshCompounds.insert(std::make_pair(dim, compound));
} }
void addVertex(int num, double x, double y, double z, double lc);
void addVertex(int num, double x, double y, gmshSurface *s, double lc);
}; };
#endif #endif
...@@ -306,7 +306,22 @@ int NEWFIELD(void); ...@@ -306,7 +306,22 @@ int NEWFIELD(void);
int NEWPHYSICAL(void); int NEWPHYSICAL(void);
int compareVertex(const void *a, const void *b); int compareVertex(const void *a, const void *b);
int compareSurfaceLoop(const void *a, const void *b);
int compareEdgeLoop(const void *a, const void *b);
int compareCurve(const void *a, const void *b); int compareCurve(const void *a, const void *b);
int compareSurface(const void *a, const void *b);
int compareVolume(const void *a, const void *b);
int compareLevelSet(const void *a, const void *b);
int comparePhysicalGroup(const void *a, const void *b);
void Free_Vertex(void *a, void *b);
void Free_PhysicalGroup(void *a, void *b);
void Free_EdgeLoop(void *a, void *b);
void Free_SurfaceLoop(void *a, void *b);
void Free_Curve(void *a, void *b);
void Free_Surface(void *a, void *b);
void Free_Volume(void *a, void *b);
void Free_LevelSet(void *a, void *b);
void Projette(Vertex *v, double mat[3][3]); void Projette(Vertex *v, double mat[3][3]);
......
This diff is collapsed.
...@@ -1736,17 +1736,15 @@ Shape : ...@@ -1736,17 +1736,15 @@ Shape :
double y = CTX::instance()->geom.scalingFactor * $6[1]; double y = CTX::instance()->geom.scalingFactor * $6[1];
double z = CTX::instance()->geom.scalingFactor * $6[2]; double z = CTX::instance()->geom.scalingFactor * $6[2];
double lc = CTX::instance()->geom.scalingFactor * $6[3]; double lc = CTX::instance()->geom.scalingFactor * $6[3];
if(lc == 0.) lc = MAX_LC; // no mesh size given at the point
if(factory == "OpenCASCADE" && GModel::current()->getOCCInternals()){ if(factory == "OpenCASCADE" && GModel::current()->getOCCInternals()){
GModel::current()->getOCCInternals()->addVertex(num, x, y, z, lc); GModel::current()->getOCCInternals()->addVertex(num, x, y, z, lc);
} }
else{ else{
if(lc == 0.) lc = MAX_LC; // no mesh size given at the point
Vertex *v;
if(!myGmshSurface) if(!myGmshSurface)
v = Create_Vertex(num, x, y, z, lc, 1.0); GModel::current()->getGEOInternals()->addVertex(num, x, y, z, lc);
else else
v = Create_Vertex(num, x, y, myGmshSurface, lc); GModel::current()->getGEOInternals()->addVertex(num, x, y, myGmshSurface, lc);
Tree_Add(GModel::current()->getGEOInternals()->Points, &v);
} }
AddToTemporaryBoundingBox(x, y, z); AddToTemporaryBoundingBox(x, y, z);
} }
...@@ -3667,7 +3665,7 @@ Delete : ...@@ -3667,7 +3665,7 @@ Delete :
GModel::current()->getGEOInternals()->destroy(); GModel::current()->getGEOInternals()->destroy();
} }
else if(!strcmp($2, "Physicals")){ else if(!strcmp($2, "Physicals")){
GModel::current()->getGEOInternals()->reset_physicals(); GModel::current()->getGEOInternals()->resetPhysicalGroups();
GModel::current()->deletePhysicalGroups(); GModel::current()->deletePhysicalGroups();
} }
else if(!strcmp($2, "Variables")){ else if(!strcmp($2, "Variables")){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment