use FlatArray for edges and faces in mesh interface V2

This commit is contained in:
Joachim Schoeberl 2024-02-21 08:41:17 +01:00
parent 6813c519b6
commit 4f0b15ef55
2 changed files with 42 additions and 17 deletions

View File

@ -111,6 +111,7 @@ namespace netgen
int operator[] (size_t i) const { return ptr[i]-POINTINDEX_BASE; } int operator[] (size_t i) const { return ptr[i]-POINTINDEX_BASE; }
}; };
/*
class Ng_Edges class Ng_Edges
{ {
public: public:
@ -130,6 +131,7 @@ namespace netgen
size_t Size() const { return num; } size_t Size() const { return num; }
int operator[] (size_t i) const { return ptr[i]; } int operator[] (size_t i) const { return ptr[i]; }
}; };
*/
class Ng_Facets class Ng_Facets
{ {
@ -151,8 +153,10 @@ namespace netgen
int GetIndex() const { return index-1; } int GetIndex() const { return index-1; }
Ng_Points points; // all points Ng_Points points; // all points
Ng_Vertices vertices; Ng_Vertices vertices;
Ng_Edges edges; // Ng_Edges edges;
Ng_Faces faces; FlatArray<T_EDGE2> edges;
// Ng_Faces faces;
FlatArray<T_FACE2> faces;
Ng_Facets facets; Ng_Facets facets;
bool is_curved; bool is_curved;
}; };

View File

@ -56,15 +56,20 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<0> (size_t nr) const
ret.vertices.num = 1; ret.vertices.num = 1;
ret.vertices.ptr = (int*)&el.pnum; ret.vertices.ptr = (int*)&el.pnum;
/*
ret.edges.num = 0; ret.edges.num = 0;
ret.edges.ptr = NULL; ret.edges.ptr = NULL;
*/
ret.edges.Assign ( FlatArray<T_EDGE2> (0, nullptr) );
/*
ret.faces.num = 0; ret.faces.num = 0;
ret.faces.ptr = NULL; ret.faces.ptr = NULL;
*/
ret.faces.Assign ( { 0, nullptr } );
ret.facets.num = 1; ret.facets.num = 1;
ret.facets.base = 1; ret.facets.base = POINTINDEX_BASE;
ret.facets.ptr = (int*)&el.pnum; ret.facets.ptr = (int*)&el.pnum;
if (mesh->GetDimension() == 1) if (mesh->GetDimension() == 1)
@ -107,12 +112,18 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<1> (size_t nr) const
ret.vertices.num = 2; ret.vertices.num = 2;
ret.vertices.ptr = (int*)&(el[0]); ret.vertices.ptr = (int*)&(el[0]);
/*
ret.edges.num = 1; ret.edges.num = 1;
ret.edges.ptr = mesh->GetTopology().GetSegmentElementEdgesPtr (nr); ret.edges.ptr = mesh->GetTopology().GetSegmentElementEdgesPtr (nr);
*/
ret.edges.Assign ( FlatArray<T_EDGE2> (1, const_cast<T_EDGE2*>( mesh->GetTopology().GetSegmentElementEdgesPtr (nr))));
/*
ret.faces.num = 0; ret.faces.num = 0;
ret.faces.ptr = NULL; ret.faces.ptr = NULL;
*/
ret.faces.Assign ( { 0, nullptr });
if (mesh->GetDimension() == 3) if (mesh->GetDimension() == 3)
{ {
ret.facets.num = 0; ret.facets.num = 0;
@ -123,7 +134,7 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<1> (size_t nr) const
{ {
ret.facets.num = 1; ret.facets.num = 1;
ret.facets.base = 0; ret.facets.base = 0;
ret.facets.ptr = ret.edges.ptr; ret.facets.ptr = ret.edges.Data();
} }
else else
{ {
@ -157,23 +168,27 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<2> (size_t nr) const
ret.vertices.num = el.GetNV(); ret.vertices.num = el.GetNV();
ret.vertices.ptr = (int*)&(el[0]); ret.vertices.ptr = (int*)&(el[0]);
/*
ret.edges.num = MeshTopology::GetNEdges (el.GetType()); ret.edges.num = MeshTopology::GetNEdges (el.GetType());
ret.edges.ptr = mesh->GetTopology().GetSurfaceElementEdgesPtr (nr); ret.edges.ptr = mesh->GetTopology().GetSurfaceElementEdgesPtr (nr);
*/
ret.edges.Assign (mesh->GetTopology().GetEdges (SurfaceElementIndex(nr)));
/*
ret.faces.num = MeshTopology::GetNFaces (el.GetType()); ret.faces.num = MeshTopology::GetNFaces (el.GetType());
ret.faces.ptr = mesh->GetTopology().GetSurfaceElementFacesPtr (nr); ret.faces.ptr = mesh->GetTopology().GetSurfaceElementFacesPtr (nr);
*/
ret.faces.Assign ( { 1, const_cast<int*>(mesh->GetTopology().GetSurfaceElementFacesPtr (nr)) });
if (mesh->GetDimension() == 3) if (mesh->GetDimension() == 3)
{ {
ret.facets.num = ret.faces.num; ret.facets.num = ret.faces.Size();
ret.facets.base = 0; ret.facets.base = 0;
ret.facets.ptr = ret.faces.ptr; ret.facets.ptr = ret.faces.Data();
} }
else else
{ {
ret.facets.num = ret.edges.num; ret.facets.num = ret.edges.Size();
ret.facets.base = 0; ret.facets.base = 0;
ret.facets.ptr = ret.edges.ptr; ret.facets.ptr = ret.edges.Data();
} }
ret.is_curved = el.IsCurved(); ret.is_curved = el.IsCurved();
return ret; return ret;
@ -194,15 +209,21 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<3> (size_t nr) const
ret.vertices.num = el.GetNV(); ret.vertices.num = el.GetNV();
ret.vertices.ptr = (int*)&(el[0]); ret.vertices.ptr = (int*)&(el[0]);
/*
ret.edges.num = MeshTopology::GetNEdges (el.GetType()); ret.edges.num = MeshTopology::GetNEdges (el.GetType());
ret.edges.ptr = mesh->GetTopology().GetElementEdgesPtr (nr); ret.edges.ptr = mesh->GetTopology().GetElementEdgesPtr (nr);
*/
ret.edges.Assign (mesh->GetTopology().GetEdges (ElementIndex(nr)));
/*
ret.faces.num = MeshTopology::GetNFaces (el.GetType()); ret.faces.num = MeshTopology::GetNFaces (el.GetType());
ret.faces.ptr = mesh->GetTopology().GetElementFacesPtr (nr); ret.faces.ptr = mesh->GetTopology().GetElementFacesPtr (nr);
*/
ret.facets.num = ret.faces.num; ret.faces.Assign (mesh->GetTopology().GetFaces (ElementIndex(nr)));
ret.facets.num = ret.faces.Size();
ret.facets.base = 0; ret.facets.base = 0;
ret.facets.ptr = ret.faces.ptr; ret.facets.ptr = ret.faces.Data();
ret.is_curved = el.IsCurved(); ret.is_curved = el.IsCurved();
return ret; return ret;