Mesh OCCGeometry face after defining netgen edges in the face boundary

Hello,

In netgen6.2.23XX and netgen6.2.22XX I’m trying to mesh occ faces after defining the edges at the boundary without success for simple geometries. In a nutshell, I have the follow sequence of calls to the function of the netgen library.

netgen::mesh ngMesh;
occgeom.shape = TheFace;
occgeom.BuildFMap();

For a series of points located at the border of the face.

ngMesh.AddPoint( netgen::Point<3> (n->X(), n->Y(), n->Z()), 1, netgen::EDGEPOINT  )
ngMesh.AddPoint( netgen::Point<3> (n->X(), n->Y(), n->Z()), 1, netgen::FIXEDPOINT  ) // for vertex

For the connectivity of the points define the segments and call

ngMesh.AddSegment (seg);

Then call

ngMesh.CalcSurfacesOfNode();

and then

netgen::mparam.perfstepsstart = MESHCONST_MESHSURFACE;
netgen::mparam.perfstepsend = MESHCONST_MESHSURFACE;
occgeom.GenerateMesh( meshPtr, netgen::mparam );

For an square face, the generated mesh is visually incorrect, with some triangular elements created out of the boundary of the geometry as depicted in the shared image.

Is there any important step/care that must be taken in relation to the added segments for this procedure to work? Studying the FindEdges routine for the newer versions (6.22 and 6.23) I realize that there were some updates in relation to version 6.21, but I still can not figure out how to make this procedure to work again.

I appreciate your help!

Cesar

From this alone it is a bit difficult to say, maybe you could provide some small cpp script?

My best guess is that the face doesn’t build its boundary correctly (there were also some recent changes there). What you can do for this is call something like
occgeom->GetFace(0).GetBoundary().
This returns an array of segments. Check if these segments all have correct orientation.
The segments are now only stored once per edge in direction of the occ edge. If you have edges in reversed direction, you now also must give the segments in that direction.

Hello Christopher!

Thanks for the fast answer. In our code, the nodes and segments are feed in sequence one after the other until the entire wire is meshed.

I added the logic implemented in the OCCFace::GetBoundary() function to the code:

 bool do_swap = edgeOrientation == TopAbs_REVERSED;
 if(seg.epgeominfo[1].dist < seg.epgeominfo[0].dist)
    do_swap = !do_swap;

if ( do_swap )
{     
        swap(seg[0], seg[1]);
        swap(seg.epgeominfo[0].dist, seg.epgeominfo[1].dist);
        swap(seg.epgeominfo[0].u, seg.epgeominfo[1].u);
        swap(seg.epgeominfo[0].v, seg.epgeominfo[1].v);
}

To, in my understanding, take care of the correctness of the segments orientation. But I still getting incorrect result for the 2D mesh. The code is open source and can be found here (Salome NETGENPLUGIN) and the function that takes care of feeding netgen segments into the mesh is called AddSegmentsToMesh inside NETGENPlugin_Mesher.cxx.