new interface

This commit is contained in:
Joachim Schoeberl 2009-07-13 13:03:01 +00:00
parent d4830f6316
commit 7ac50aacf6
5 changed files with 253 additions and 187 deletions

View File

@ -1,25 +1,55 @@
class Ng_Element
{
class Ng_Points
{
public:
int num;
const int * ptr;
int Size() const { return num; }
int operator[] (int i) const { return ptr[i]-1; }
};
class Ng_Vertices
{
public:
int num;
const int * ptr;
int Size() const { return num; }
int operator[] (int i) const { return ptr[i]-1; }
};
class Ng_Edges
{
public:
int num;
const int * ptr;
int Size() const { return num; }
int operator[] (int i) const { return abs (ptr[i])-1; }
};
class Ng_Faces
{
public:
int num;
const int * ptr;
int Size() const { return num; }
int operator[] (int i) const { return (ptr[i]-1) / 8; }
};
public:
NG_ELEMENT_TYPE type;
int npoints;
int nv;
int * points;
NG_ELEMENT_TYPE GetType() const { return type; }
NG_ELEMENT_TYPE GetType() const
{
return type;
}
int GetNP() const
{
return npoints;
}
int operator[] (int i) const
{
return points[i]-1;
}
Ng_Points points; // all points
Ng_Vertices vertices;
Ng_Edges edges;
Ng_Faces faces;
};

View File

@ -848,163 +848,6 @@ for (i = 1; i <= ne; i++)
int MeshTopology :: GetNVertices (ELEMENT_TYPE et)
{
switch (et)
{
case SEGMENT:
case SEGMENT3:
return 2;
case TRIG:
case TRIG6:
return 3;
case QUAD:
case QUAD6:
case QUAD8:
return 4;
case TET:
case TET10:
return 4;
case PYRAMID:
return 5;
case PRISM:
case PRISM12:
return 6;
case HEX:
return 8;
default:
cerr << "Ng_ME_GetNVertices, illegal element type " << et << endl;
}
return 0;
}
int MeshTopology :: GetNPoints (ELEMENT_TYPE et)
{
switch (et)
{
case SEGMENT:
return 2;
case SEGMENT3:
return 3;
case TRIG:
return 3;
case TRIG6:
return 6;
case QUAD:
case QUAD6:
case QUAD8:
return 4;
case TET:
return 4;
case TET10:
return 10;
case PYRAMID:
return 5;
case PRISM:
case PRISM12:
return 6;
case HEX:
return 8;
default:
cerr << "Ng_ME_GetNVertices, illegal element type " << et << endl;
}
return 0;
}
int MeshTopology :: GetNEdges (ELEMENT_TYPE et)
{
switch (et)
{
case SEGMENT:
case SEGMENT3:
return 1;
case TRIG:
case TRIG6:
return 3;
case QUAD:
case QUAD6:
case QUAD8:
return 4;
case TET:
case TET10:
return 6;
case PYRAMID:
return 8;
case PRISM:
case PRISM12:
return 9;
case HEX:
return 12;
default:
cerr << "Ng_ME_GetNEdges, illegal element type " << et << endl;
}
return 0;
}
int MeshTopology :: GetNFaces (ELEMENT_TYPE et)
{
switch (et)
{
case SEGMENT:
case SEGMENT3:
return 0;
case TRIG:
case TRIG6:
return 1;
case QUAD:
case QUAD6:
case QUAD8:
return 1;
case TET:
case TET10:
return 4;
case PYRAMID:
return 5;
case PRISM:
case PRISM12:
return 5;
case HEX:
return 6;
default:
cerr << "Ng_ME_GetNVertices, illegal element type " << et << endl;
}
return 0;
}
const Point3d * MeshTopology :: GetVertices (ELEMENT_TYPE et)
{

View File

@ -56,10 +56,10 @@ public:
int GetNFaces () const
{ return face2vert.Size(); }
static int GetNVertices (ELEMENT_TYPE et);
static int GetNPoints (ELEMENT_TYPE et);
static int GetNEdges (ELEMENT_TYPE et);
static int GetNFaces (ELEMENT_TYPE et);
static inline int GetNVertices (ELEMENT_TYPE et);
static inline int GetNPoints (ELEMENT_TYPE et);
static inline int GetNEdges (ELEMENT_TYPE et);
static inline int GetNFaces (ELEMENT_TYPE et);
static const Point3d * GetVertices (ELEMENT_TYPE et);
inline static const ELEMENT_EDGE * GetEdges (ELEMENT_TYPE et);
@ -97,6 +97,14 @@ public:
int GetSurfaceElementEdges (int elnr, int * edges, int * orient) const;
const int * GetElementEdgesPtr (int elnr) const { return &edges[elnr][0]; }
const int * GetSurfaceElementEdgesPtr (int selnr) const { return &surfedges[selnr][0]; }
const int * GetSegmentElementEdgesPtr (int selnr) const { return &segedges[selnr]; }
const int * GetElementFacesPtr (int elnr) const { return &faces[elnr][0]; }
const int * GetSurfaceElementFacesPtr (int selnr) const { return &surffaces[selnr]; }
void GetSurface2VolumeElement (int selnr, int & elnr1, int & elnr2) const
{
elnr1 = surf2volelement.Get(selnr)[0];
@ -126,6 +134,163 @@ public:
int MeshTopology :: GetNVertices (ELEMENT_TYPE et)
{
switch (et)
{
case SEGMENT:
case SEGMENT3:
return 2;
case TRIG:
case TRIG6:
return 3;
case QUAD:
case QUAD6:
case QUAD8:
return 4;
case TET:
case TET10:
return 4;
case PYRAMID:
return 5;
case PRISM:
case PRISM12:
return 6;
case HEX:
return 8;
default:
cerr << "Ng_ME_GetNVertices, illegal element type " << et << endl;
}
return 0;
}
int MeshTopology :: GetNPoints (ELEMENT_TYPE et)
{
switch (et)
{
case SEGMENT:
return 2;
case SEGMENT3:
return 3;
case TRIG:
return 3;
case TRIG6:
return 6;
case QUAD:
case QUAD6:
case QUAD8:
return 4;
case TET:
return 4;
case TET10:
return 10;
case PYRAMID:
return 5;
case PRISM:
case PRISM12:
return 6;
case HEX:
return 8;
default:
cerr << "Ng_ME_GetNVertices, illegal element type " << et << endl;
}
return 0;
}
int MeshTopology :: GetNEdges (ELEMENT_TYPE et)
{
switch (et)
{
case SEGMENT:
case SEGMENT3:
return 1;
case TRIG:
case TRIG6:
return 3;
case QUAD:
case QUAD6:
case QUAD8:
return 4;
case TET:
case TET10:
return 6;
case PYRAMID:
return 8;
case PRISM:
case PRISM12:
return 9;
case HEX:
return 12;
default:
cerr << "Ng_ME_GetNEdges, illegal element type " << et << endl;
}
return 0;
}
int MeshTopology :: GetNFaces (ELEMENT_TYPE et)
{
switch (et)
{
case SEGMENT:
case SEGMENT3:
return 0;
case TRIG:
case TRIG6:
return 1;
case QUAD:
case QUAD6:
case QUAD8:
return 1;
case TET:
case TET10:
return 4;
case PYRAMID:
return 5;
case PRISM:
case PRISM12:
return 5;
case HEX:
return 6;
default:
cerr << "Ng_ME_GetNVertices, illegal element type " << et << endl;
}
return 0;
}

View File

@ -46,8 +46,6 @@ namespace netgen {
DemoScanner :: DemoScanner (ifstream & ascanin)
{
int i;
scanin = &ascanin;
token = DTOK_END;
num_value = 0;

View File

@ -95,9 +95,19 @@ template <> DLL_HEADER Ng_Element Ng_GetElement<1> (int nr)
Ng_Element ret;
ret.type = NG_ELEMENT_TYPE(el.GetType());
ret.npoints = el.GetNP();
ret.points = (int*)&(el[0]);
ret.points.num = el.GetNP();
ret.points.ptr = (int*)&(el[0]);
ret.vertices.num = 2;
ret.vertices.ptr = (int*)&(el[0]);
ret.edges.num = 1;
ret.edges.ptr = mesh->GetTopology().GetSegmentElementEdgesPtr (nr);
ret.faces.num = 0;
ret.faces.ptr = NULL;
return ret;
}
@ -107,8 +117,18 @@ template <> DLL_HEADER Ng_Element Ng_GetElement<2> (int nr)
Ng_Element ret;
ret.type = NG_ELEMENT_TYPE(el.GetType());
ret.npoints = el.GetNP();
ret.points = (int*)&el[0];
ret.points.num = el.GetNP();
ret.points.ptr = (int*)&el[0];
ret.vertices.num = el.GetNV();
ret.vertices.ptr = (int*)&(el[0]);
ret.edges.num = MeshTopology::GetNEdges (el.GetType());
ret.edges.ptr = mesh->GetTopology().GetSurfaceElementEdgesPtr (nr);
ret.faces.num = MeshTopology::GetNFaces (el.GetType());
ret.faces.ptr = mesh->GetTopology().GetSurfaceElementFacesPtr (nr);
return ret;
}
@ -118,8 +138,18 @@ template <> DLL_HEADER Ng_Element Ng_GetElement<3> (int nr)
Ng_Element ret;
ret.type = NG_ELEMENT_TYPE(el.GetType());
ret.npoints = el.GetNP();
ret.points = (int*)&el[0];
ret.points.num = el.GetNP();
ret.points.ptr = (int*)&el[0];
ret.vertices.num = el.GetNV();
ret.vertices.ptr = (int*)&(el[0]);
ret.edges.num = MeshTopology::GetNEdges (el.GetType());
ret.edges.ptr = mesh->GetTopology().GetElementEdgesPtr (nr);
ret.faces.num = MeshTopology::GetNFaces (el.GetType());
ret.faces.ptr = mesh->GetTopology().GetElementFacesPtr (nr);
return ret;
}