Segfault during mesh generation 1D

Hello, I am meshing a very big and complex geometry, ca 600`000 edges, many many faces, one volume and I’m hitting a segfault during the 1D mesh generation.

I run it through a debugger and the stacktrace is

// ng/ngpkg.cpp:1389
if(optstring)
  mparam.optimize3d = *optstring;
int res = ng_geometry -> GenerateMesh (mesh, mparam);
// libsrc/meshing/basegeom.cpp:1258
if(mparam.perfstepsstart <= MESHCONST_MESHEDGES)
  FindEdges(*mesh, mparam);
// libsrc/meshing/basegeom.cpp:646
if(is_identified_edge)
{
    params.SetSize(2);
    params[0] = 0.;
    params[1] = 1.;
}
else
{
    edge->Divide(mparam, mesh, edge_points, params);

// libsrc/meshing/basegeom.cpp:498
double safety = 0.5*(1.-mparam.grading);

double lam = 0.0;
Point<3> p = GetPoint(0.0);
// libsrc/occ/occ_edge.cpp:48
Point<3> OCCEdge::GetPoint(double t) const
{
    return occ2ng( curve->Value(s0+t*(s1-s0)) );

and I can see in the debugger that curve is 0x0, id est, nullptr.

Can anyone share help? :slight_smile:

Massimiliano

Can you identifiy the edge in the geometry and have a look at it? Do you know does it have some kind of “speciality”? I didn’t know that there could be edges without a curve in occ (which contains its parametrization), except maybe from degenerated ones but these we remove (but maybe not fully correctly)?

What you can also try is the geometry.Heal function (in cpp HealGeometry). it removes degenerated faces and fixes small gaps and stuff like that. If it is afterwards fine, there was just some broken part in the geometry.

If you can share the geometry I can have a look sometime later this week you can DM me.

I tried the healing procedure but it took forever so I stopped it at some point. I haven’t tried to identify the edge in question but there are no special edges.

I tried with other similar geometries coming from the same pipeline and I get the same result.

Hi Christopher,

I encounter the same issue. I can confirm, that edges may have no curve in case they are degenerated.

Here is an example (v6.2.2403):

TopoDS_Shape s;
BinTools::Read(s, std::string("C:\\temp\\sbin.brep").c_str());
auto occgeo = std::make_shared<netgen::OCCGeometry>(s);

netgen::MeshingParameters mp;
mp.perfstepsend = netgen::MESHCONST_MESHSURFACE;

auto mesh = std::make_shared<netgen::Mesh>();
mesh->SetGeometry(occgeo);
occgeo->GenerateMesh(mesh, mp);

sbin.brep (584.2 KB)

A handling of these cases without changing initial geometry would be good.

Kind regards,
Matthias

I added checks BRep_Tool::Degenerated(edge) inside OCCGeometry :: BuildFMap in order to not add degenerated edges into the edge map emap but the issue still ocurs.

Inside NetgenGeometry :: FindEdges I changed

        // ignore collapsed edges
        if(startp == endp && edge->GetLength() < 1e-10 * bounding_box.Diam())
            continue;

into

        // ignore collapsed edges
        if (edge->IsDegenerated())
            continue;

and the issue doesn’t occur anymore.

Ah good catch! Sorry last weeks were quite full with usermeeting so haven’t had time to look closely, but this makes sense. Changed it on master.