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

*** empty log message ***

parent 46858a0c
No related branches found
No related tags found
No related merge requests found
...@@ -83,7 +83,7 @@ class GEntity { ...@@ -83,7 +83,7 @@ class GEntity {
virtual ~GEntity() {}; virtual ~GEntity() {};
// Spatial dimension of the entity // Spatial dimension of the entity
virtual int dim() const = 0; virtual int dim() const {throw;}
// Returns true if ent is in the closure of this entity // Returns true if ent is in the closure of this entity
virtual int inClosure(GEntity *ent) const {throw;} virtual int inClosure(GEntity *ent) const {throw;}
...@@ -101,7 +101,7 @@ class GEntity { ...@@ -101,7 +101,7 @@ class GEntity {
virtual std::list<GVertex*> vertices() const{throw;} virtual std::list<GVertex*> vertices() const{throw;}
/// Underlying geometric representation of this entity. /// Underlying geometric representation of this entity.
virtual GeomType geomType() const = 0; virtual GeomType geomType() const {throw;}
// True if parametric space is continuous in the "dim" direction. // True if parametric space is continuous in the "dim" direction.
virtual bool continuous(int dim) const {return true;} virtual bool continuous(int dim) const {return true;}
...@@ -122,7 +122,7 @@ class GEntity { ...@@ -122,7 +122,7 @@ class GEntity {
virtual int containsPoint(const SPoint3 &pt) const{throw;} virtual int containsPoint(const SPoint3 &pt) const{throw;}
// Get the native pointer of the particular representation // Get the native pointer of the particular representation
virtual void * getNativePtr() const= 0; virtual void * getNativePtr() const {throw;}
// The model owning this entity. // The model owning this entity.
GModel *model() const {return _model;} GModel *model() const {return _model;}
...@@ -178,16 +178,7 @@ class GEntity { ...@@ -178,16 +178,7 @@ class GEntity {
virtual std::string getAdditionalInfoString() { return std::string(""); } virtual std::string getAdditionalInfoString() { return std::string(""); }
}; };
// A minimal, non-abstract entity that can be used for sorting class GEntityLessThan {
class dummyEntity : public GEntity {
public:
dummyEntity(GModel *model, int tag) : GEntity(model, tag){}
virtual int dim() const {return -1;}
virtual GeomType geomType() const {return Unknown;}
virtual void * getNativePtr() const {return 0;}
};
class EntityLessThan {
public: public:
bool operator()(const GEntity *ent1, const GEntity *ent2) const bool operator()(const GEntity *ent1, const GEntity *ent2) const
{ {
......
#include "GModel.h" #include "GModel.h"
int GModel::numRegion() const
{
return regions.size();
}
int GModel::numFace () const
{
return faces.size();
}
int GModel::numEdge () const
{
return edges.size();
}
int GModel::numVertex() const
{
return vertices.size();
}
int GModel::meshStatus() int GModel::meshStatus()
{ {
for(riter it = firstRegion(); it != lastRegion(); ++it) for(riter it = firstRegion(); it != lastRegion(); ++it)
...@@ -35,40 +15,40 @@ int GModel::meshStatus() ...@@ -35,40 +15,40 @@ int GModel::meshStatus()
GRegion * GModel::regionByTag(int n) const GRegion * GModel::regionByTag(int n) const
{ {
dummyEntity tmp((GModel*)this, n); GEntity tmp((GModel*)this, n);
riter it = regions.find((GRegion*)&tmp); riter it = regions.find((GRegion*)&tmp);
if(it != regions.end()) if(it != regions.end())
return (GRegion *) (*it); return *it;
else else
return 0; return 0;
} }
GFace * GModel::faceByTag(int n) const GFace * GModel::faceByTag(int n) const
{ {
dummyEntity tmp((GModel*)this, n); GEntity tmp((GModel*)this, n);
fiter it = faces.find((GFace*)&tmp); fiter it = faces.find((GFace*)&tmp);
if(it != faces.end()) if(it != faces.end())
return (GFace *) (*it); return *it;
else else
return 0; return 0;
} }
GEdge * GModel::edgeByTag(int n) const GEdge * GModel::edgeByTag(int n) const
{ {
dummyEntity tmp((GModel*)this, n); GEntity tmp((GModel*)this, n);
eiter it = edges.find((GEdge*)&tmp); eiter it = edges.find((GEdge*)&tmp);
if(it != edges.end()) if(it != edges.end())
return (GEdge *) (*it); return *it;
else else
return 0; return 0;
} }
GVertex * GModel::vertexByTag(int n) const GVertex * GModel::vertexByTag(int n) const
{ {
dummyEntity tmp((GModel*)this, n); GEntity tmp((GModel*)this, n);
viter it = vertices.find((GVertex*)&tmp); viter it = vertices.find((GVertex*)&tmp);
if(it != vertices.end()) if(it != vertices.end())
return (GVertex *) (*it); return *it;
else else
return 0; return 0;
} }
...@@ -93,20 +73,15 @@ int GModel::renumberMeshVertices() ...@@ -93,20 +73,15 @@ int GModel::renumberMeshVertices()
bool GModel::noPhysicals() bool GModel::noPhysicals()
{ {
bool somePhysicals = false;
for(viter it = firstVertex(); it != lastVertex(); ++it) for(viter it = firstVertex(); it != lastVertex(); ++it)
if((*it)->physicals.size()){ somePhysicals = true; break; } if((*it)->physicals.size()) return false;
if(!somePhysicals) for(eiter it = firstEdge(); it != lastEdge(); ++it)
for(eiter it = firstEdge(); it != lastEdge(); ++it) if((*it)->physicals.size()) return false;
if((*it)->physicals.size()){ somePhysicals = true; break; } for(fiter it = firstFace(); it != lastFace(); ++it)
if(!somePhysicals) if((*it)->physicals.size()) return false;
for(fiter it = firstFace(); it != lastFace(); ++it) for(riter it = firstRegion(); it != lastRegion(); ++it)
if((*it)->physicals.size()){ somePhysicals = true; break; } if((*it)->physicals.size()) return false;
if(!somePhysicals) return true;
for(riter it = firstRegion(); it != lastRegion(); ++it)
if((*it)->physicals.size()){ somePhysicals = true; break; }
return !somePhysicals;
} }
static void addInGroup(GEntity* ge, std::map<int, std::vector<GEntity*> > &group) static void addInGroup(GEntity* ge, std::map<int, std::vector<GEntity*> > &group)
...@@ -146,4 +121,3 @@ SBoundingBox3d GModel::recomputeBounds() ...@@ -146,4 +121,3 @@ SBoundingBox3d GModel::recomputeBounds()
boundingBox = bb; boundingBox = bb;
return bounds(); return bounds();
} }
...@@ -16,20 +16,20 @@ class GModel ...@@ -16,20 +16,20 @@ class GModel
{ {
protected: protected:
std::string modelName; std::string modelName;
std::set<GRegion*, EntityLessThan> regions; std::set<GRegion*, GEntityLessThan> regions;
std::set<GFace*, EntityLessThan> faces; std::set<GFace*, GEntityLessThan> faces;
std::set<GEdge*, EntityLessThan> edges; std::set<GEdge*, GEntityLessThan> edges;
std::set<GVertex*, EntityLessThan> vertices; std::set<GVertex*, GEntityLessThan> vertices;
SBoundingBox3d boundingBox; SBoundingBox3d boundingBox;
public: public:
GModel(const std::string &name) : modelName(name) {} GModel(const std::string &name) : modelName(name) {}
virtual ~GModel() {} virtual ~GModel() {}
typedef std::set<GRegion*, EntityLessThan>::iterator riter; typedef std::set<GRegion*, GEntityLessThan>::iterator riter;
typedef std::set<GFace*, EntityLessThan>::iterator fiter; typedef std::set<GFace*, GEntityLessThan>::iterator fiter;
typedef std::set<GEdge*, EntityLessThan>::iterator eiter; typedef std::set<GEdge*, GEntityLessThan>::iterator eiter;
typedef std::set<GVertex*, EntityLessThan>::iterator viter; typedef std::set<GVertex*, GEntityLessThan>::iterator viter;
// Returns the geometric tolerance for the entire model. // Returns the geometric tolerance for the entire model.
virtual double tolerance() const { return 1.e-14; } virtual double tolerance() const { return 1.e-14; }
...@@ -38,10 +38,10 @@ class GModel ...@@ -38,10 +38,10 @@ class GModel
virtual int meshStatus(); virtual int meshStatus();
// Get the number of regions in this model. // Get the number of regions in this model.
int numRegion() const; int numRegion() const { return regions.size(); }
int numFace() const; int numFace() const { return faces.size(); }
int numEdge() const; int numEdge() const { return edges.size(); }
int numVertex() const; int numVertex() const { return vertices.size(); }
// Get an iterator initialized to the first entity in this model. // Get an iterator initialized to the first entity in this model.
riter firstRegion() { return regions.begin(); } riter firstRegion() { return regions.begin(); }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment