GetElement returns Facet-Array. Since for 1D these are point numbers, and point numbers are (still) 1-based, we have to return also the base

This commit is contained in:
Joachim Schöberl 2017-04-03 11:17:47 +02:00
parent 240a132078
commit 619f9ff47f
2 changed files with 10 additions and 7 deletions

View File

@ -78,10 +78,11 @@ namespace netgen
{
public:
size_t num;
int base;
const int * ptr;
size_t Size() const { return num; }
int operator[] (size_t i) const { return ptr[i]; }
int operator[] (size_t i) const { return ptr[i]-base; }
};

View File

@ -96,15 +96,14 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<1> (size_t nr) const
if (mesh->GetDimension() == 2)
{
ret.facets.num = 1;
ret.facets.base = 0;
ret.facets.ptr = (int*)ret.edges.ptr;
}
else
{
ret.facets.num = 0;
ret.facets.ptr = nullptr;
// not working as long as vertices are 1-based
// ret.facets.num = 2;
// ret.facets.ptr = (int*)&(el[0]);
ret.facets.num = 2;
ret.facets.base = 1;
ret.facets.ptr = (int*)&(el[0]);
}
// ret.is_curved = mesh->GetCurvedElements().IsSegmentCurved(nr);
@ -142,11 +141,13 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<2> (size_t nr) const
if (mesh->GetDimension() == 3)
{
ret.facets.num = ret.faces.num;
ret.facets.base = 0;
ret.facets.ptr = (int*)ret.faces.ptr;
}
else
{
ret.facets.num = ret.edges.num;
ret.facets.base = 0;
ret.facets.ptr = (int*)ret.edges.ptr;
}
ret.is_curved = el.IsCurved();
@ -176,6 +177,7 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<3> (size_t nr) const
ret.faces.ptr = (T_FACE2*)mesh->GetTopology().GetElementFacesPtr (nr);
ret.facets.num = ret.faces.num;
ret.facets.base = 0;
ret.facets.ptr = (int*)ret.faces.ptr;
ret.is_curved = el.IsCurved();