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

*** empty log message ***

parent 503c5ecb
No related branches found
No related tags found
No related merge requests found
#include "GEdge.h"
#include <algorithm>
void GEdge::addFace ( GFace *e )
{
l_faces.push_back (e);
}
void GEdge::delFace ( GFace *e )
{
l_faces.erase(std::find(l_faces.begin(),l_faces.end(),e));
}
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
#include "GEntity.h" #include "GEntity.h"
#include "GVertex.h" #include "GVertex.h"
#include "SVector3.h"
#include "SPoint3.h"
#include "SPoint2.h"
/** A model edge. */ /** A model edge. */
...@@ -14,22 +17,17 @@ public: ...@@ -14,22 +17,17 @@ public:
GVertex *_v1) GVertex *_v1)
: GEntity (model,tag),v0(_v0),v1(_v1) : GEntity (model,tag),v0(_v0),v1(_v1)
{ {
v0->add_edge (this); v0->addEdge (this);
v1->add_edge (this); v1->addEdge (this);
} }
virtual ~GEdge() virtual ~GEdge()
{ {
v0->del_edge (this); v0->delEdge (this);
v1->del_edge (this); v1->delEdge (this);
} }
virtual int dim() const {return 1;} 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 periodic(int dim=0) const = 0;
virtual bool continuous(int dim=0) const = 0; virtual bool continuous(int dim=0) const = 0;
...@@ -43,10 +41,10 @@ public: ...@@ -43,10 +41,10 @@ public:
virtual double parFromPoint(const SPoint3 &) const = 0; virtual double parFromPoint(const SPoint3 &) const = 0;
/** Get the point for the given parameter location. */ /** Get the point for the given parameter location. */
virtual GEPoint point(double p) const = 0; virtual GPoint point(double p) const = 0;
/** Get the closest point on the edge to the given point. */ /** Get the closest point on the edge to the given point. */
virtual GEPoint closestPoint(const SPoint3 & queryPoint); virtual GPoint closestPoint(const SPoint3 & queryPoint);
/** True if the edge contains the given parameter. */ /** True if the edge contains the given parameter. */
virtual int containsParam(double pt) const = 0; virtual int containsParam(double pt) const = 0;
...@@ -60,15 +58,14 @@ public: ...@@ -60,15 +58,14 @@ public:
/** reparmaterize the point onto the given face. */ /** reparmaterize the point onto the given face. */
virtual SPoint2 reparamOnFace(GFace *face, double epar,int dir) const = 0; virtual SPoint2 reparamOnFace(GFace *face, double epar,int dir) const = 0;
void addFace ( GFace *f ){ l_faces.push_back (f); } void addFace ( GFace *f );
void delFace ( GFace *f ){ l_faces.erase(std::find(l_faces.begin(),l_faces.end(),f)); } void delFace ( GFace *f );
protected: protected:
GVertex v0,v1; GVertex *v0,*v1;
std::list<GFace *> l_faces; std::list<GFace *> l_faces;
}; };
......
#include "GFace.h"
#include "GEdge.h"
GFace::~GFace ()
{
std::list<GEdge*>::iterator it = l_edges.begin();
while (it != l_edges.end())
{
(*it)->delFace(this);
++it;
}
}
#ifndef H_GFace
#define H_GFace
class GRegion;
#include "GPoint.h"
#include "GEntity.h"
#include "SPoint2.h"
#include "SVector3.h"
#include "Pair.h"
/** A model face.
*/
class GFace : public GEntity
{
protected:
std::list<GEdge *> l_edges;
std::list<int> l_dirs;
GRegion *r1, *r2;
public:
GFace(GModel *model, int tag) : GEntity (model,tag),r1(0),r2(0){}
virtual ~GFace();
void addRegion ( GRegion *r ){ r1?r2=r:r1=r; }
void delRegion ( GRegion *r ){ if(r1==r)r1=r2;r2=0; }
virtual int dim() const {return 2;}
/** Get the location of any parametric degeneracies on the face in the
given parametric direction. */
virtual int paramDegeneracies(int dir, double *par) = 0;
/** Return the point on the face corresponding to the given parameter. */
virtual GPoint point(double par1, double par2) const = 0;
virtual GPoint point(const SPoint2 &pt) const = 0;
/** Return the parmater location on the face given a point in space that
is on the face. */
virtual SPoint2 parFromPoint(const SPoint3 &) const = 0;
/** True if the parameter value is interior to the face. */
virtual int containsParam(const SPoint2 &pt) const = 0;
/** Period of the face in the given direction. */
virtual double period(int dir) const;
/** Return the point on the face closest to the given point. */
virtual GPoint closestPoint(const SPoint3 & queryPoint);
/** Return the normal to the face at the given parameter location. */
virtual SVector3 normal(const SPoint2 &param) const = 0;
/** Return the first derivate of the face at the parameter location. */
virtual Pair<SVector3,SVector3> firstDer(const SPoint2 &param) const = 0;
/** Return the nth derivate of the face at the parametric location. */
virtual double * nthDerivative(const SPoint2 &param, int n,
double *array) const;
/* true if the surface underlying the face is periodic and we
need to worry about that. */
virtual bool surfPeriodic(int dim) const = 0;
protected:
};
#endif
#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();
}
GRegion * GModel::regionByTag(int n) const
{
std::list<GRegion*>:: const_iterator it = regions.begin();
std::list<GRegion*>:: const_iterator end = regions.end();
while (it != end)
{
GRegion *rr = (GRegion*) (*it);
if ( rr->tag() == n)return *it;
++it;
}
return 0;
}
GFace * GModel::faceByTag(int n) const
{
std::list<GFace*>:: const_iterator it = faces.begin();
std::list<GFace*>:: const_iterator end = faces.end();
while (it != end)
{
GFace *ff = (GFace*) (*it);
if ( ff->tag() == n)return *it;
++it;
}
return 0;
}
GEdge * GModel::edgeByTag(int n) const
{
std::list<GEdge*>:: const_iterator it = edges.begin();
std::list<GEdge*>:: const_iterator end = edges.end();
while (it != end)
{
GEdge *ee = (GEdge*) (*it);
if ( ee->tag() == n)return *it;
++it;
}
return 0;
}
GVertex * GModel::vertexByTag(int n) const
{
std::list<GVertex*>:: const_iterator it = vertices.begin();
std::list<GVertex*>:: const_iterator end = vertices.end();
while (it != end)
{
GVertex *vv = (GVertex*) (*it);
if ( vv->tag() == n)return *it;
++it;
}
return 0;
}
#ifndef H_GModel #ifndef H_GModel
#define H_GModel #define H_GModel
#include <algorithm>
#include "GVertex.h" #include "GVertex.h"
#include "GEdge.h" #include "GEdge.h"
#include "GFace.h" #include "GFace.h"
...@@ -13,10 +14,10 @@ class GModel ...@@ -13,10 +14,10 @@ class GModel
public: public:
virtual ~GModel(); virtual ~GModel();
typedef std::list<GRegion*>::const_iterator riter; typedef std::list<GRegion*>::iterator riter;
typedef std::list<GFace*>::const_iterator fiter; typedef std::list<GFace*>::iterator fiter;
typedef std::list<GEdge*>::const_iterator eiter; typedef std::list<GEdge*>::iterator eiter;
typedef std::list<GVertex*>::const_iterator viter; typedef std::list<GVertex*>::iterator viter;
/** Returns the geometric tolerance for the entire model. */ /** Returns the geometric tolerance for the entire model. */
virtual double tolerance() const =0; virtual double tolerance() const =0;
...@@ -28,39 +29,39 @@ public: ...@@ -28,39 +29,39 @@ public:
int numVertex() const; int numVertex() const;
/** Get the nth region in this model. */ /** Get the nth region in this model. */
GRegion * region(int n) const; // GRegion * region(int n) const;
GFace * face (int n) const; // GFace * face (int n) const;
GEdge * edge (int n) const; // GEdge * edge (int n) const;
GVertex * vertex(int n) const; // GVertex * vertex(int n) const;
/** Get an iterator initialized to the first entity in this model. */ /** Get an iterator initialized to the first entity in this model. */
riter firstRegion() const {return regions.begin();} riter firstRegion() {return regions.begin();}
fiter firstFace() const {return faces.begin();} fiter firstFace() {return faces.begin();}
eiter firstEdge() const {return edges.begin();} eiter firstEdge() {return edges.begin();}
viter firstVertex() const {return vertices.begin();} viter firstVertex() {return vertices.begin();}
riter lastRegion() const {return regions.end();} riter lastRegion() {return regions.end();}
fiter lastFace() const {return faces.end();} fiter lastFace() {return faces.end();}
eiter lastEdge() const {return edges.end();} eiter lastEdge() {return edges.end();}
viter lastVertex() const {return vertices.end();} viter lastVertex() {return vertices.end();}
/** Find the region with the given tag. */ /** Find the region with the given tag. */
virtual GRegion * regionByTag(int n) const; virtual GRegion * regionByTag(int n) const;
virtual GFace * faceByTag(int n) const; virtual GFace * faceByTag (int n) const;
virtual GEdge * edgeByTag(int n) const; virtual GEdge * edgeByTag (int n) const;
virtual GVertex * vertexByTag(int n) const; virtual GVertex * vertexByTag(int n) const;
virtual GRegion * regionByID(int n) const; // virtual GRegion * regionByID(int n) const;
virtual GFace * faceByID(int n) const; // virtual GFace * faceByID (int n) const;
virtual GEdge * edgeByID(int n) const; // virtual GEdge * edgeByID (int n) const;
virtual GVertex * vertexByID(int n) const; // virtual GVertex * vertexByID(int n) const;
virtual void setGeomTolerance(double) {}; virtual void setGeomTolerance(double) {};
void setDisplayCoherence(int ); // default is coherent // void setDisplayCoherence(int ); // default is coherent
void add(GRegion *r){regions.push_back(r);} void add(GRegion *r){regions.push_back(r);}
void add(GFace *f) {regions.push_back(f);} void add(GFace *f) {faces.push_back(f);}
void add(GEdge *e) {regions.push_back(e);} void add(GEdge *e) {edges.push_back(e);}
void add(GVertex *v){regions.push_back(v);} void add(GVertex *v){vertices.push_back(v);}
void remove(GRegion *r){regions.erase(std::find(firstRegion(),lastRegion(),r));} void remove(GRegion *r){regions.erase(std::find(firstRegion(),lastRegion(),r));}
void remove(GFace *f){faces.erase(std::find(firstFace(),lastFace(),f));} void remove(GFace *f){faces.erase(std::find(firstFace(),lastFace(),f));}
......
#include "GRegion.h"
#include "GFace.h"
GRegion::~GRegion ()
{
std::list<GFace*>::iterator it = l_faces.begin();
while (it != l_faces.end())
{
(*it)->delRegion(this);
++it;
}
}
#ifndef H_GRegion
#define H_GRegion
#include "GEntity.h"
/** A model region. */
class GRegion : public GEntity {
std::list<GFace *> l_faces;
std::list<int> l_dirs;
public:
GRegion(GModel *model, int tag) : GEntity (model,tag) {}
virtual ~GRegion();
virtual int dim() const {return 3;}
};
#endif
#include "GVertex.h"
#include <algorithm>
void GVertex::addEdge ( GEdge *e )
{
l_edges.push_back (e);
}
void GVertex::delEdge ( GEdge *e )
{
l_edges.erase(std::find(l_edges.begin(),l_edges.end(),e));
}
#ifndef H_GVertex
#define H_GVertex
#include "GEntity.h"
#include "GPoint.h"
/** A model vertex. */
class GVertex : public GEntity
{
public:
GVertex(GModel *m, int tag) : GEntity (m,tag) {}
virtual ~GVertex() {}
virtual GPoint point() const = 0;
void addEdge ( GEdge *e );
void delEdge ( GEdge *e );
protected:
std::list<GEdge*> l_edges;
};
#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