How to set Ng_Meshing_Parameters to create a mesh using C++

Hello, I tried varius combination of parameters but I obtain always the same result.
I am trying to create a fine solid mesh of a 1x1x1 cube, but I obtain always the same number of volume elements (12).

I am trying with this parameters:
Ng_Meshing_Parameters mp = Ng_Meshing_Parameters();
mp.maxh = 0.2;
mp.elementsperedge = 5;
mp.elementspercurve = 2;
mp.grading = 0.3;

but Ng_GenerateVolumeMesh(mesh, &mp) gives always the same result.

Thanks,
Stenio

This is the code I used:

Ng_Init();

Ng_Mesh* mesh = Ng_NewMesh();

double v = {
0, 0, 0,
1, 0, 0,
1, 1, 0,
0, 1, 0,
0, 0, 1,
1, 0, 1,
1, 1, 1,
0, 1, 1,
};
Ng_AddPoint(mesh, v + 0);
Ng_AddPoint(mesh, v + 3);
Ng_AddPoint(mesh, v + 6);
Ng_AddPoint(mesh, v + 9);
Ng_AddPoint(mesh, v + 12);
Ng_AddPoint(mesh, v + 15);
Ng_AddPoint(mesh, v + 18);
Ng_AddPoint(mesh, v + 21);

// Creazione delle facce (triangoli)
int trig = {
1, 4, 3,
1, 3, 2,
1, 6, 5,
1, 2, 6,
2, 7, 6,
2, 3, 7,
3, 8, 7,
3, 4, 8,
4, 5, 8,
4, 1, 5,
5, 7, 8,
5, 6, 7
};
Ng_AddSurfaceElement(mesh, NG_TRIG, trig + 0);
Ng_AddSurfaceElement(mesh, NG_TRIG, trig + 3);
Ng_AddSurfaceElement(mesh, NG_TRIG, trig + 6);
Ng_AddSurfaceElement(mesh, NG_TRIG, trig + 9);
Ng_AddSurfaceElement(mesh, NG_TRIG, trig + 12);
Ng_AddSurfaceElement(mesh, NG_TRIG, trig + 15);
Ng_AddSurfaceElement(mesh, NG_TRIG, trig + 18);
Ng_AddSurfaceElement(mesh, NG_TRIG, trig + 21);
Ng_AddSurfaceElement(mesh, NG_TRIG, trig + 24);
Ng_AddSurfaceElement(mesh, NG_TRIG, trig + 27);
Ng_AddSurfaceElement(mesh, NG_TRIG, trig + 30);
Ng_AddSurfaceElement(mesh, NG_TRIG, trig + 33);

Ng_Meshing_Parameters mp = Ng_Meshing_Parameters();
mp.maxh = 0.1;
mp.elementsperedge = 8;

Ng_Result res = Ng_GenerateVolumeMesh(mesh, &mp);

from your code you already set the surface mesh explicitly. then the volume mesher has a hard time to fullfill your requirements like segmentsperedge = 8 :wink:

i guess you want to mesh everything by using a stl triangulation as input. for this use the stl geometry

That was exactly what I was thinking! :grinning:
Infact I finally did it using the STL functions.

Thanks.