Skip to content
Snippets Groups Projects
Commit 503c5ecb authored by Jean-François Remacle's avatar Jean-François Remacle
Browse files

*** empty log message ***

parent 7ab77427
No related branches found
No related tags found
No related merge requests found
#ifndef H_GEdge
#define H_GEdge
#include "GEntity.h"
#include "GVertex.h"
/** A model edge. */
class GEdge : public GEntity {
public:
GEdge(GModel *model,
int tag,
GVertex *_v0,
GVertex *_v1)
: GEntity (model,tag),v0(_v0),v1(_v1)
{
v0->add_edge (this);
v1->add_edge (this);
}
virtual ~GEdge()
{
v0->del_edge (this);
v1->del_edge (this);
}
virtual int dim() const {return 1;}
virtual std::list<GRegion*> regions() const;
virtual std::list<GFace*> faces() const;
virtual std::list<GEdge*> edges() const;
virtual std::list<GVertex*> vertices() const;
virtual bool periodic(int dim=0) const = 0;
virtual bool continuous(int dim=0) const = 0;
virtual int inClosure(GEntity *ent) const; // if ent is in closure of this edge
// Geometric ops
/** Get parameter on edge for given point. */
virtual double param(const GPoint &pt);
/** Get the parameter location for a point in space on the edge. */
virtual double parFromPoint(const SPoint3 &) const = 0;
/** Get the point for the given parameter location. */
virtual GEPoint point(double p) const = 0;
/** Get the closest point on the edge to the given point. */
virtual GEPoint closestPoint(const SPoint3 & queryPoint);
/** True if the edge contains the given parameter. */
virtual int containsParam(double pt) const = 0;
/** Get first derivative of edge at the given parameter. */
virtual SVector3 firstDer(double par) const = 0;
/** Get nth derivative at the given paramater. */
virtual void nthDerivative(double param, int n, double *array) const=0;
/** reparmaterize the point onto the given face. */
virtual SPoint2 reparamOnFace(GFace *face, double epar,int dir) const = 0;
void addFace ( GFace *f ){ l_faces.push_back (f); }
void delFace ( GFace *f ){ l_faces.erase(std::find(l_faces.begin(),l_faces.end(),f)); }
protected:
GVertex v0,v1;
std::list<GFace *> l_faces;
};
#endif
#ifndef H_GEntity
#define H_GEntity
class GModel;
class MeshRep;
/** A geometric model entity. All enitites are owned by a GModel. */
class GEntity {
int tag;
GModel *model;
DiscreteRep *mesh, *modelMesh;
public:
GEntity(GModel *model, int tag);
virtual ~GEntity();
/** Return a renderable representation of the entity.*/
virtual MeshRep * getGeometry() ;
/** Return a mesh of the entity */
virtual MeshRep * getMesh() ;
/// Spatial dimension of the entity.
virtual int dim() const = 0;
/** Returns true if ent is in the closure of this entity */
virtual int inClosure(GEntity *ent) const =0;
/// Regions that bound this entity or that this entity bounds.
virtual std::list<GRegion*> regions() const;
/// Faces that bound this entity or that this entity bounds.
virtual std::list<GFace*> faces() const;
/// Edges that bound this entity or that this entity bounds.
virtual std::list<GEdge*> edges() const;
/// Vertices that bound this entity.
virtual std::list<GVertex*> vertices() const;
/// 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;
/// True if entity is periodic in the "dim" direction.
virtual bool periodic(int dim) const;
/// True if there are parametric degeneracies in the "dim" direction.
virtual bool degenerate(int dim) const;
/// Orientation of the parametric space w.r.t. the entity.
virtual int geomDirection() const;
/// Parametric bounds of the entity in the "i" direction.
virtual Range<double> parBounds(int i) const;
/// Modeler tolerance for the entity.
virtual double tolerance() const;
/// True if the entity contains the given point to within tolerance.
virtual int containsPoint(const SPoint3 &pt) const;
/// Get the native pointer of the particular representation
virtual void * getNativePtr() const= 0;
/// The model owning this entity.
GModel *model() const;
};
#endif
#ifndef H_GModel
#define H_GModel
#include "GVertex.h"
#include "GEdge.h"
#include "GFace.h"
#include "GRegion.h"
/** A geometric model. The model is a non-manifold B-Rep. */
class GModel
{
public:
virtual ~GModel();
typedef std::list<GRegion*>::const_iterator riter;
typedef std::list<GFace*>::const_iterator fiter;
typedef std::list<GEdge*>::const_iterator eiter;
typedef std::list<GVertex*>::const_iterator viter;
/** Returns the geometric tolerance for the entire model. */
virtual double tolerance() const =0;
/** Get the number of regions in this model. */
int numRegion() const;
int numFace () const;
int numEdge () const;
int numVertex() const;
/** Get the nth region in this model. */
GRegion * region(int n) const;
GFace * face (int n) const;
GEdge * edge (int n) const;
GVertex * vertex(int n) const;
/** Get an iterator initialized to the first entity in this model. */
riter firstRegion() const {return regions.begin();}
fiter firstFace() const {return faces.begin();}
eiter firstEdge() const {return edges.begin();}
viter firstVertex() const {return vertices.begin();}
riter lastRegion() const {return regions.end();}
fiter lastFace() const {return faces.end();}
eiter lastEdge() const {return edges.end();}
viter lastVertex() const {return vertices.end();}
/** Find the region with the given tag. */
virtual GRegion * regionByTag(int n) const;
virtual GFace * faceByTag(int n) const;
virtual GEdge * edgeByTag(int n) const;
virtual GVertex * vertexByTag(int n) const;
virtual GRegion * regionByID(int n) const;
virtual GFace * faceByID(int n) const;
virtual GEdge * edgeByID(int n) const;
virtual GVertex * vertexByID(int n) const;
virtual void setGeomTolerance(double) {};
void setDisplayCoherence(int ); // default is coherent
void add(GRegion *r){regions.push_back(r);}
void add(GFace *f) {regions.push_back(f);}
void add(GEdge *e) {regions.push_back(e);}
void add(GVertex *v){regions.push_back(v);}
void remove(GRegion *r){regions.erase(std::find(firstRegion(),lastRegion(),r));}
void remove(GFace *f){faces.erase(std::find(firstFace(),lastFace(),f));}
void remove(GEdge *e){edges.erase(std::find(firstEdge(),lastEdge(),e));}
void remove(GVertex *v){vertices.erase(std::find(firstVertex(),lastVertex(),v));}
protected:
GModel(const std::string &name);
std::list<GRegion*> regions;
std::list<GFace*> faces;
std::list<GEdge*> edges;
std::list<GVertex*> vertices;
};
#endif
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