Newer
Older
#include "Range.h"
#include "SPoint3.h"
class GVertex;
class GEdge;
class GFace;
class GRegion;
// A geometric model entity. All enitites are owned by a GModel.
// All known entity types
enum GeomType {
Unknown,
Point,
Line,
Circle,
Ellipse,
ParametricCurve,
Plane,
Nurb,
Cylinder,
Sphere,
Cone,
Torus,
ParametricSurface,
char *name[] = {
"Unknown",
"Point",
"Line",
"Circle",
"Ellipse",
"ParametricCurve",
"DiscreteCurve",
"Plane",
"Nurb",
"Cylinder",
"Sphere",
"Cone",
"Torus",
"ParametricSurface",
"DiscreteSurface",
"Volume"
unsigned int type = (unsigned int)geomType();
if(type >= sizeof(name) / sizeof(name[0]))
return "Undefined";
char tmp[256];
sprintf(tmp, "%s %d", getTypeString().c_str(), tag());
return std::string(tmp);
}
GEntity(GModel *m, int t) : _model(m), _tag(t)
{
drawAttributes.Visible = VIS_GEOM | VIS_MESH;
// Returns true if ent is in the closure of this entity
virtual int inClosure(GEntity *ent) const {throw;}
// Regions that bound this entity or that this entity bounds.
virtual std::list<GRegion*> regions() const{throw;}
// Faces that bound this entity or that this entity bounds.
virtual std::list<GFace*> faces() const{throw;}
// Edges that bound this entity or that this entity bounds.
virtual std::list<GEdge*> edges() const{throw;}
virtual std::list<GVertex*> vertices() const{throw;}
/// Underlying geometric representation of this entity.
virtual GeomType geomType() const = 0;
// True if parametric space is continuous in the "dim" direction.
virtual bool continuous(int dim) const {return true;}
// True if entity is periodic in the "dim" direction.
virtual bool periodic(int dim) const {return false;}
// True if there are parametric degeneracies in the "dim" direction.
virtual bool degenerate(int dim) const {return false;}
// Parametric bounds of the entity in the "i" direction.
virtual Range<double> parBounds(int i) const{throw;}
virtual double tolerance() const {return 1.e-14;}
// True if the entity contains the given point to within tolerance.
virtual int containsPoint(const SPoint3 &pt) const{throw;}
// Get the native pointer of the particular representation
virtual void * getNativePtr() const= 0;
GModel *model() const {return _model;}
// The tag of the entity
int tag () const {return _tag;}
virtual SBoundingBox3d bounds() const{throw;}
// The mesh vertices uniquely owned by the entity
std::vector<MVertex*> mesh_vertices;
// The physical entitites (if any) that contain this entity
std::vector<int> physicals;
// The standard drawing attributes of the entity
struct {
// Returns a renderable representation of the geometry
virtual MRep *geomRep(){ return _geom; }
// Returns a renderable representation of the mesh
virtual MRep *meshRep(){ return _mesh; }
// A minimal, non-abstract entity that can be used for sorting
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:
bool operator()(const GEntity *ent1, const GEntity *ent2) const
{
return ent1->tag() < ent2->tag();
}
};