Help using netgen library to define simple Mesh using plain C++

Hello I am trying to understand how create simple meshes using only C++. All the tutorials that I found use python but I need plain C++.

An example of this tutorial in C++ would be awesome:

I am trying to reverse engineer it but I am having problem adding the Facedescriptors. In particular I get an access violation exception with the following code:

using namespace netgen;
Mesh mesh = Mesh();
FaceDescriptor fd(1, 1, 0, 1);

Can you help me finding the problem?


I think I’ve found the root of the problem: after the creation of the object FaceDescriptor the private member bcname is null, but from the source code it should be the string “default”. That is causing the exception problem on the assignement of the object.
I tried also to explicitly set the member calling SetBCName but it is still null after the call. :woozy_face:

Example code based on AddRegion method of python_mesh.cpp:

Mesh mesh;
int dims = mesh.GetDimension();
int dim = 2;
auto& regionnames = mesh.GetRegionNamesCD(dims - dim);
string regionName = "material";
int idx = regionnames.Size();
if (dim == 2) {
    FaceDescriptor fd;