From 619f9ff47f5672ef3dd0be1988a1907a16165b17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Mon, 3 Apr 2017 11:17:47 +0200 Subject: [PATCH] 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 --- libsrc/include/nginterface_v2.hpp | 5 +++-- libsrc/include/nginterface_v2_impl.hpp | 12 +++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libsrc/include/nginterface_v2.hpp b/libsrc/include/nginterface_v2.hpp index d2407ea8..b6271ecf 100644 --- a/libsrc/include/nginterface_v2.hpp +++ b/libsrc/include/nginterface_v2.hpp @@ -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; } }; diff --git a/libsrc/include/nginterface_v2_impl.hpp b/libsrc/include/nginterface_v2_impl.hpp index 973310a2..472f7e61 100644 --- a/libsrc/include/nginterface_v2_impl.hpp +++ b/libsrc/include/nginterface_v2_impl.hpp @@ -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();