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

manage GModel::list automatically (like PView::list)
parent 7008d187
No related branches found
No related tags found
No related merge requests found
// $Id: Box.cpp,v 1.37 2007-09-10 04:47:01 geuzaine Exp $
// $Id: Box.cpp,v 1.38 2007-09-21 21:14:00 geuzaine Exp $
//
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
//
......@@ -78,7 +78,7 @@ int GMSHBOX(int argc, char *argv[])
{
ParUtil::Instance()->init(argc, argv);
GModel::list.push_back(new GModel);
new GModel;
THEM = new Mesh;
InitSymbols();
......
// $Id: Main.cpp,v 1.110 2007-09-10 05:31:35 geuzaine Exp $
// $Id: Main.cpp,v 1.111 2007-09-21 21:14:00 geuzaine Exp $
//
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
//
......@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
}
// Create a new model
GModel::list.push_back(new GModel);
new GModel;
THEM = new Mesh;
// Initialize the symbol tree that will hold variable names
......
// $Id: GModel.cpp,v 1.47 2007-09-12 20:14:34 geuzaine Exp $
// $Id: GModel.cpp,v 1.48 2007-09-21 21:14:00 geuzaine Exp $
//
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
//
......@@ -27,6 +27,20 @@
std::vector<GModel*> GModel::list;
GModel::GModel(std::string name)
: modelName(name), normals(0)
{
list.push_back(this);
}
GModel::~GModel()
{
std::vector<GModel*>::iterator it = std::find(list.begin(), list.end(), this);
if(it != list.end()) list.erase(it);
deleteOCCInternals();
destroy();
}
GModel *GModel::current()
{
if(list.empty()){
......@@ -68,7 +82,7 @@ void GModel::destroy()
BGMReset();
}
GRegion * GModel::regionByTag(int n) const
GRegion *GModel::regionByTag(int n) const
{
GEntity tmp((GModel*)this, n);
riter it = regions.find((GRegion*)&tmp);
......@@ -78,7 +92,7 @@ GRegion * GModel::regionByTag(int n) const
return 0;
}
GFace * GModel::faceByTag(int n) const
GFace *GModel::faceByTag(int n) const
{
GEntity tmp((GModel*)this, n);
fiter it = faces.find((GFace*)&tmp);
......@@ -88,7 +102,7 @@ GFace * GModel::faceByTag(int n) const
return 0;
}
GEdge * GModel::edgeByTag(int n) const
GEdge *GModel::edgeByTag(int n) const
{
GEntity tmp((GModel*)this, n);
eiter it = edges.find((GEdge*)&tmp);
......@@ -98,7 +112,7 @@ GEdge * GModel::edgeByTag(int n) const
return 0;
}
GVertex * GModel::vertexByTag(int n) const
GVertex *GModel::vertexByTag(int n) const
{
GEntity tmp((GModel*)this, n);
viter it = vertices.find((GVertex*)&tmp);
......@@ -291,7 +305,7 @@ bool GModel::noPhysicalGroups()
return true;
}
static void addInGroup(GEntity* ge, std::map<int, std::vector<GEntity*> > &group)
static void addInGroup(GEntity *ge, std::map<int, std::vector<GEntity*> > &group)
{
for(unsigned int i = 0; i < ge->physicals.size(); i++){
// physicals can be stored with negative signs when the entity
......
......@@ -32,8 +32,6 @@
// OCC Internals have to be stored in the model
class OCC_Internals;
// Fourier Internals have to be stored in the model
class F_Internals;
// A geometric model. The model is a "not yet" non-manifold B-Rep.
class GModel
......@@ -41,7 +39,6 @@ class GModel
protected:
void deleteOCCInternals();
OCC_Internals *occ_internals;
F_Internals *f_internals;
std::string modelName;
std::set<GRegion*, GEntityLessThan> regions;
......@@ -52,9 +49,8 @@ class GModel
std::map<int, std::string> physicalNames;
public:
GModel() : modelName("Untitled"), normals(0) {}
GModel(const std::string &name) : modelName(name), normals(0) {}
~GModel(){ deleteOCCInternals(); destroy(); }
GModel(std::string name="");
~GModel();
// the static list of all loaded models
static std::vector<GModel*> list;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment