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

*** empty log message ***

parent 5c691135
No related branches found
No related tags found
No related merge requests found
#ifndef H_GEntity
#define H_GEntity
#include "Range.h"
#include "SPoint3.h"
#include <list>
class GModel;
class MeshRep;
class GVertex;
class GEdge;
class GFace;
class GRegion;
//class MeshRep;
/** A geometric model entity. All enitites are owned by a GModel. */
class GEntity {
int tag;
GModel *model;
DiscreteRep *mesh, *modelMesh;
int _tag;
GModel *_model;
// DiscreteRep *mesh, *modelMesh;
public:
GEntity(GModel *model, int tag);
enum GeomType{
Unknown,
Point,
Line,
Circle,
Ellipse,
ParametricCurve,
Plane,
Nurb,
Cylinder,
Sphere,
Cone,
Torus,
ParametricSurface,
ThreeDimVolume
};
GEntity(GModel *m, int t) : _model(m),_tag(t){}
virtual ~GEntity();
/** Return a renderable representation of the entity.*/
virtual MeshRep * getGeometry() ;
// virtual MeshRep * getGeometry() ;
/** Return a mesh of the entity */
virtual MeshRep * getMesh() ;
// virtual MeshRep * getMesh() ;
/// Spatial dimension of the entity.
virtual int dim() const = 0;
......@@ -40,16 +66,16 @@ public:
virtual GeomType geomType() const = 0;
/// True if parametric space is continuous in the "dim" direction.
virtual bool continuous(int dim) const;
virtual bool continuous(int dim) const {return true;}
/// True if entity is periodic in the "dim" direction.
virtual bool periodic(int dim) const;
virtual bool periodic(int dim) const {return false;}
/// True if there are parametric degeneracies in the "dim" direction.
virtual bool degenerate(int dim) const;
virtual bool degenerate(int dim) const {return false;}
/// Orientation of the parametric space w.r.t. the entity.
virtual int geomDirection() const;
// virtual int geomDirection() const;
/// Parametric bounds of the entity in the "i" direction.
virtual Range<double> parBounds(int i) const;
......@@ -64,7 +90,10 @@ public:
virtual void * getNativePtr() const= 0;
/// The model owning this entity.
GModel *model() const;
GModel *model() const {return _model;}
// The tag of the entity
int tag () const {return _tag;}
};
......
......@@ -58,6 +58,7 @@ public:
/* true if the surface underlying the face is periodic and we
need to worry about that. */
virtual bool surfPeriodic(int dim) const = 0;
virtual int inClosure(GEntity *ent) const {throw;}
protected:
};
......
......@@ -11,6 +11,8 @@ public:
GRegion(GModel *model, int tag) : GEntity (model,tag) {}
virtual ~GRegion();
virtual int dim() const {return 3;}
virtual int inClosure(GEntity *ent) const {throw;}
virtual GeomType geomType() const {return ThreeDimVolume;}
};
#endif
......
......@@ -13,6 +13,10 @@ public:
virtual GPoint point() const = 0;
void addEdge ( GEdge *e );
void delEdge ( GEdge *e );
virtual int dim() const {return 0;}
virtual int inClosure(GEntity *ent) const {throw;}
virtual GeomType geomType() const {return Point;}
protected:
std::list<GEdge*> l_edges;
};
......
# $Id: Makefile,v 1.74 2006-03-10 06:39:46 geuzaine Exp $
# $Id: Makefile,v 1.75 2006-07-09 15:22:57 remacle Exp $
#
# Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
#
......@@ -38,6 +38,11 @@ SRC = CAD.cpp \
ExtrudeParams.cpp \
Geo.cpp \
GeoUtils.cpp \
GVertex.cpp\
GEdge.cpp\
GFace.cpp\
GRegion.cpp\
GModel.cpp\
gmshModel.cpp\
gmshEdge.cpp\
gmshFace.cpp\
......
#ifndef _H_GMSH_DEFS_
#define _H_GMSH_DEFS_
#ifdef _HAVE_SGMODEL_
#include "SGModel.h"
#include "GVPoint.h"
#include "GEPoint.h"
#include "GFPoint.h"
#include "Pair.h"
#else
#include "SPoint2.h"
class GRegion;
class GFace;
class GEdge;
class GVertex;
class SGModel {
public:
SGModel ( const char * ){}
void add(GRegion *r){}
void add(GFace *f){}
void add(GEdge *e){}
void add(GVertex *v){}
};
class GeoRep {
};
struct GVPoint
{
double X,Y,Z;
GVPoint (double _x, double _y, double _z, const GVertex *v):X(_x),Y(_y),Z(_z){};
};
struct GEPoint
{
double X,Y,Z;
GEPoint (double _x, double _y, double _z, const GEdge *e, double par):X(_x),Y(_y),Z(_z){};
};
struct GFPoint
{
double X,Y,Z;
GFPoint (double _x, double _y, double _z,
const GFace *e, const SPoint2 & par):X(_x),Y(_y),Z(_z){};
};
class Logical{
public:
enum Value{
False = 0,
True,
Unknown
};
};
class GeomType{
public:
enum Value{
Unknown,
Point,
Line,
Circle,
Ellipse,
ParametricCurve,
Plane,
Nurb,
Cylinder,
Sphere,
Cone,
Torus,
ParametricSurface
};
};
#endif
#endif
......@@ -4,7 +4,7 @@
#include "CAD.h"
#include "Geo.h"
gmshEdge::gmshEdge(SGModel *model,Curve *edge,GVertex *v1,GVertex *v2)
gmshEdge::gmshEdge(GModel *model,Curve *edge,GVertex *v1,GVertex *v2)
: GEdge ( model, edge->Num, v1, v2 ), c(edge)
{}
......@@ -47,13 +47,13 @@ SBoundingBox3d gmshEdge::bounds() const
return bbox;
}
GEPoint gmshEdge::point(double par) const
GPoint gmshEdge::point(double par) const
{
Vertex a = InterpolateCurve(c, par, 0);
return GEPoint(a.Pos.X,a.Pos.Y,a.Pos.Z,this,par);
return GPoint(a.Pos.X,a.Pos.Y,a.Pos.Z,this,par);
}
GEPoint gmshEdge::closestPoint(const SPoint3 & qp)
GPoint gmshEdge::closestPoint(const SPoint3 & qp)
{
Vertex v;
Vertex a;
......@@ -62,7 +62,7 @@ GEPoint gmshEdge::closestPoint(const SPoint3 & qp)
v.Pos.Y = qp.y();
v.Pos.Z = qp.z();
ProjectPointOnCurve (c,&v,&a,&der);
return GEPoint(a.Pos.X,a.Pos.Y,a.Pos.Z,this,a.u);
return GPoint(a.Pos.X,a.Pos.Y,a.Pos.Z,this,a.u);
}
int gmshEdge::containsParam(double pt) const
......@@ -89,19 +89,19 @@ double gmshEdge::parFromPoint(const SPoint3 &pt) const
return a.u;
}
Logical::Value gmshEdge::continuous(int) const
bool gmshEdge::continuous(int) const
{
return Logical::True;
return true;
}
Logical::Value gmshEdge::degenerate(int) const
bool gmshEdge::degenerate(int) const
{
return Logical::False;
return false;
}
Logical::Value gmshEdge::periodic(int dim) const
bool gmshEdge::periodic(int dim) const
{
return Logical::False;
return false;
}
int gmshEdge::isSeam(GFace *face) const
......@@ -115,21 +115,21 @@ double gmshEdge::period() const
return 0;
}
GeomType::Value gmshEdge::geomType() const
GEntity::GeomType gmshEdge::geomType() const
{
switch (c->Typ)
{
case MSH_SEGM_LINE : return GeomType::Line;
case MSH_SEGM_PARAMETRIC : return GeomType::ParametricCurve;
case MSH_SEGM_LINE : return Line;
case MSH_SEGM_PARAMETRIC : return ParametricCurve;
case MSH_SEGM_CIRC :
case MSH_SEGM_CIRC_INV : return GeomType::Circle;
case MSH_SEGM_CIRC_INV : return Circle;
case MSH_SEGM_ELLI:
case MSH_SEGM_ELLI_INV: return GeomType::Ellipse;
case MSH_SEGM_ELLI_INV: return Ellipse;
case MSH_SEGM_BSPLN:
case MSH_SEGM_BEZIER:
case MSH_SEGM_NURBS:
case MSH_SEGM_SPLN: return GeomType::Nurb;
default : return GeomType::Unknown;
case MSH_SEGM_SPLN: return Nurb;
default : return Unknown;
}
}
......
#ifndef _H_GMSH_EDGE_
#define _H_GMSH_EDGE_
#include "gmshDefs.h"
#include "GEdge.h"
#include "gmshModel.h"
#include "gmshVertex.h"
#include "Mesh.h"
#include "Range.h"
#ifdef _HAVE_SGMODEL_
#include "GEdge.h"
#else
class GEdge {
public:
GEdge (SGModel *model, int tag, GVertex *v0, GVertex *v1)
{};
};
#endif
class gmshEdge : public GEdge{
public:
gmshEdge(SGModel *model,Curve *edge,GVertex *v1,GVertex *v2);
gmshEdge(GModel *model,Curve *edge,GVertex *v1,GVertex *v2);
virtual ~gmshEdge();
int isSeam(GFace *face) const;
double period() const;
Range<double> parBounds(int i) const;
virtual Logical::Value periodic(int dim=0) const;
virtual GeomType::Value geomType() const;
virtual Logical::Value degenerate(int) const;
virtual Logical::Value continuous(int dim) const;
virtual bool periodic(int dim=0) const;
virtual GeomType geomType() const;
virtual bool degenerate(int) const;
virtual bool continuous(int dim) const;
// Geometric Ops
SBoundingBox3d bounds() const;
virtual GEPoint point(double p) const;
virtual GEPoint closestPoint(const SPoint3 & queryPoint);
virtual GPoint point(double p) const;
virtual GPoint closestPoint(const SPoint3 & queryPoint);
virtual int containsPoint(const SPoint3 &pt) const;
virtual int containsParam(double pt) const;
virtual SVector3 firstDer(double par) const;
......@@ -45,13 +35,7 @@ public:
void * getNativePtr() const;
virtual GVertex * split(double par);
Curve *c;
virtual GeoRep * geometry() {return 0;}
#ifdef _HAVE_SGMODEL_
virtual SSList<GEPoint> intersect(int fAxis, double fPar, GFace *f)
{
throw;
}
#endif
// virtual GeoRep * geometry() {return 0;}
virtual double parFromPoint(const SPoint3 &pt) const;
protected:
};
......
......@@ -58,18 +58,19 @@ double * gmshFace::nthDerivative(const SPoint2 &param, int n, double *array) con
throw;
}
GFPoint gmshFace::point(const SPoint2 &pt) const
GPoint gmshFace::point(const SPoint2 &pt) const
{
return point(pt.x(),pt.y());
}
GFPoint gmshFace::point(double par1,double par2) const
GPoint gmshFace::point(double par1,double par2) const
{
double pp[2]={par1,par2};
Vertex v = InterpolateSurface( s, par1, par2,0,0);
return GFPoint(v.Pos.X,v.Pos.Y,v.Pos.Z,this,SPoint2(par1,par2));
return GPoint(v.Pos.X,v.Pos.Y,v.Pos.Z,this,pp);
}
GFPoint gmshFace::closestPoint(const SPoint3 & qp)
GPoint gmshFace::closestPoint(const SPoint3 & qp)
{
Vertex v;
......@@ -79,8 +80,8 @@ GFPoint gmshFace::closestPoint(const SPoint3 & qp)
if ( s->Typ != MSH_SURF_PLAN )
ProjectPointOnSurface(s, v);
return GFPoint(v.Pos.X,v.Pos.Y,v.Pos.Z,
this,SPoint2(v.us[0],v.us[1]));
return GPoint(v.Pos.X,v.Pos.Y,v.Pos.Z,
this,v.us);
}
int gmshFace::containsParam(const SPoint2 &pt) const
......@@ -109,32 +110,32 @@ SPoint2 gmshFace::parFromPoint(const SPoint3 &qp) const
GeoRep * gmshFace::geometry()
{ return new gmshGeoRep(this,2); }
*/
Logical::Value gmshFace::continuous(int dim) const
bool gmshFace::continuous(int dim) const
{
return Logical::True;
return true;
}
Logical::Value gmshFace::periodic(int dim) const
bool gmshFace::periodic(int dim) const
{
return Logical::False;
return false;
}
Logical::Value gmshFace::degenerate(int dim) const
bool gmshFace::degenerate(int dim) const
{
return Logical::False;
return false;
}
GeomType::Value gmshFace::geomType() const
GEntity::GeomType gmshFace::geomType() const
{
int type;
type = s->Typ;
//if(type == CONE_TYPE)
//return GeomType::Cone;
if(type == MSH_SURF_NURBS)
return GeomType::Nurb;
return Nurb;
if(type == MSH_SURF_PLAN)
return GeomType::Plane;
return GeomType::Unknown;
return Plane;
return Unknown;
}
......
#ifndef _H_GMSH_FACE_
#define _H_GMSH_FACE_
#include "gmshDefs.h"
#include "GFace.h"
#include "gmshModel.h"
#include "gmshVertex.h"
#include "Mesh.h"
#include "Range.h"
#ifdef _HAVE_SGMODEL_
#include "GFace.h"
static SSList<GEdge*> e;
static SSList<int> d;
#else
class GFace {
public:
GFace ()
{};
};
#endif
class gmshFace : public GFace
{
public:
#ifdef _HAVE_SGMODEL_
gmshFace(SGModel *m,Surface * face):GFace (m,face->Num,e,d), s(face){}
#else
gmshFace(SGModel *m,Surface * face): s(face){}
#endif
virtual ~gmshFace(){}
Range<double> parBounds(int i) const;
virtual int paramDegeneracies(int dir, double *par);
virtual SBoundingBox3d bounds() const;
virtual GFPoint point(double par1, double par2) const;
virtual GFPoint point(const SPoint2 &pt) const;
virtual GFPoint closestPoint(const SPoint3 & queryPoint);
virtual int containsPoint(const SPoint3 &pt) const;
virtual int containsParam(const SPoint2 &pt) const;
virtual SVector3 normal(const SPoint2 &param) const;
virtual Pair<SVector3,SVector3> firstDer(const SPoint2 &param) const;
virtual double * nthDerivative(const SPoint2 &param, int n,
gmshFace(GModel *m,Surface * face):GFace (m,face->Num), s(face){}
virtual ~gmshFace(){}
Range<double> parBounds(int i) const;
virtual int paramDegeneracies(int dir, double *par);
virtual SBoundingBox3d bounds() const;
virtual GPoint point(double par1, double par2) const;
virtual GPoint point(const SPoint2 &pt) const;
virtual GPoint closestPoint(const SPoint3 & queryPoint);
virtual int containsPoint(const SPoint3 &pt) const;
virtual int containsParam(const SPoint2 &pt) const;
virtual SVector3 normal(const SPoint2 &param) const;
virtual Pair<SVector3,SVector3> firstDer(const SPoint2 &param) const;
virtual double * nthDerivative(const SPoint2 &param, int n,
double *array) const;
virtual GeomType::Value geomType() const;
virtual int geomDirection() const;
virtual Logical::Value continuous(int dim) const;
virtual Logical::Value periodic(int dim) const;
virtual Logical::Value degenerate(int dim) const;
virtual double period(int dir) const; // 200306
virtual double tolerance() const;
virtual GeoRep * geometry() {return 0;}
void * getNativePtr() const;
Surface *s;
virtual Logical::Value surfPeriodic(int dim) const
{throw;}
virtual SPoint2 parFromPoint(const SPoint3 &) const;
virtual GEntity::GeomType geomType() const;
virtual int geomDirection() const;
virtual bool continuous(int dim) const;
virtual bool periodic(int dim) const;
virtual bool degenerate(int dim) const;
virtual double period(int dir) const; // 200306
virtual double tolerance() const;
// virtual GeoRep * geometry() {return 0;}
void * getNativePtr() const;
Surface *s;
virtual bool surfPeriodic(int dim) const
{throw;}
virtual SPoint2 parFromPoint(const SPoint3 &) const;
protected:
};
......
......@@ -4,45 +4,8 @@
#include "Message.h"
extern Mesh *THEM;
GFace * gmshModel::faceByTag(int n) const
{
std::list<GFace*>:: const_iterator it = faces.begin();
std::list<GFace*>:: const_iterator end = faces.end();
while (it != end)
{
gmshFace *ff = (gmshFace*) (*it);
if ( ff->s->Num == n)return *it;
++it;
}
return 0;
}
GEdge * gmshModel::edgeByTag(int n) const
{
std::list<GEdge*>:: const_iterator it = edges.begin();
std::list<GEdge*>:: const_iterator end = edges.end();
while (it != end)
{
gmshEdge *ee = (gmshEdge*) (*it);
if ( ee->c->Num == n)return *it;
++it;
}
return 0;
}
GVertex * gmshModel::vertexByTag(int n) const
{
std::list<GVertex*>:: const_iterator it = vertices.begin();
std::list<GVertex*>:: const_iterator end = vertices.end();
while (it != end)
{
gmshVertex *vv = (gmshVertex*) (*it);
if ( vv->v->Num == n)return *it;
++it;
}
return 0;
}
gmshModel::gmshModel(char *geofile)
: SGModel ( "toto" )
: GModel ( geofile )
{
if (geofile)
{
......@@ -62,20 +25,20 @@ gmshModel::gmshModel(char *geofile)
{
points.insert(c->beg);
gmshVertex *v = new gmshVertex ( this, c->beg );
vertices.push_back(v);
//vertices.push_back(v);
add(v);
}
if (points.find(c->end) == points.end())
{
points.insert(c->end);
gmshVertex *v = new gmshVertex ( this , c->end );
vertices.push_back(v);
//vertices.push_back(v);
add(v);
}
gmshEdge *e = new gmshEdge ( this, c ,
vertexByTag(c->beg->Num),
vertexByTag(c->end->Num) );
edges.push_back(e);
// edges.push_back(e);
add(e);
}
}
......@@ -87,7 +50,7 @@ gmshModel::gmshModel(char *geofile)
Surface *s;
List_Read(surfaces, i, &s);
gmshFace *f = new gmshFace ( this, s );
faces.push_back(f);
// faces.push_back(f);
add ( f);
}
List_Delete(surfaces);
......@@ -98,7 +61,7 @@ gmshModel::gmshModel(char *geofile)
Volume *v;
List_Read(volumes, i, &v);
gmshRegion *r = new gmshRegion ( this, v );
regions.push_back(r);
// regions.push_back(r);
add ( r);
}
List_Delete(volumes);
......@@ -112,7 +75,7 @@ gmshModel::gmshModel(char *geofile)
}
SGModel *createGmshModel (char *f )
GModel *createGmshModel (char *f )
{
return new gmshModel (f);
}
......@@ -2,7 +2,6 @@
#define _H_GMSH_MODEL_
#include <list>
#include "gmshDefs.h"
#include "Mesh.h"
#include "Range.h"
#include "Pair.h"
......@@ -14,9 +13,10 @@
#include "gmshFace.h"
#include "gmshEdge.h"
#include "gmshRegion.h"
#include "GModel.h"
class gmshModel : public SGModel {
class gmshModel : public GModel {
public:
gmshModel(char *geofile = 0);
virtual ~gmshModel() {};
......
......@@ -3,29 +3,22 @@
#include "Mesh.h"
#include "gmshModel.h"
#ifdef _HAVE_SGMODEL_
#include "GRegion.h"
#else
class GRegion {
public:
GRegion(SGModel *m, int tag){}
};
#endif
class gmshRegion : public GRegion {
public:
gmshRegion(SGModel *m, Volume *_v)
gmshRegion(GModel *m, Volume *_v)
: GRegion(m, _v->Num), v(_v)
{
}
virtual ~gmshRegion() {}
virtual GeoRep * geometry(){return 0;}
// virtual GeoRep * geometry(){return 0;}
virtual double tolerance() const {return 1.e-14;}
void * getNativePtr() {return v;}
void * getNativePtr() const {return v;}
Volume *v;
protected:
......
......@@ -3,29 +3,18 @@
#include "Mesh.h"
#include "gmshModel.h"
#ifdef _HAVE_SGMODEL_
#include "GVertex.h"
#else
class GVertex {
public:
GVertex(SGModel *m, int tag){}
};
#endif
class gmshVertex : public GVertex {
public:
gmshVertex(SGModel *m, Vertex *_v) : GVertex(m, _v->Num), v(_v){}
gmshVertex(GModel *m, Vertex *_v) : GVertex(m, _v->Num), v(_v){}
virtual ~gmshVertex() {}
virtual GVPoint point() const
virtual GPoint point() const
{
return GVPoint ( v->Pos.X,v->Pos.Y,v->Pos.Z, this);
return GPoint ( v->Pos.X,v->Pos.Y,v->Pos.Z,this);
}
virtual GeoRep * geometry() {return 0;}
virtual double tolerance() const {return 1.e-14;}
void * getNativePtr() const {return v;}
Vertex *v;
protected:
......
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