Problem with parametric representation


I am new to this forum, so I hope that I have published this question in the correct place.

I have been using gmsh for quite some time and have written the attached python code based on gmsh's use of OCC to create a geometry. There appears to be some problem with the way the 2D surface mesh is created. I messaged Christophe at gmsh and he suggested there was a problem with the generation of the geometry, (perhaps the parametric representation of either the curve or the surface). He generated the attached debugSurface.brep for me to show to this community, as well as the attached surface mesh (an OCC generated STL triangulation).

If anyone has any suggestions, that would be greatly appreciated.

Thank you,


Sergey Slyadnev's picture

Hello Peter,

It's no surprise that your model yields faulty meshes given that it does not have a closed contour in the parameter space of the face (notice the gaps):

You can autorepair this face with shape healing (see the Draw script below) but it won't close the gaps and only increase the tolerances (though, you may want to experiment with reprojecting 3D curves). Another issue is that your planar surface is a B-spline surface which is probably not intentional. I do not know how to run the provided python script with gmesh, but if you're able to narrow down your problem to the reproducible Tcl script (or C++ code) with OpenCascade, it will be easier to discover the problematic place in your modeling pipeline.

The script for autohealing is this one (to run in Draw console of OpenCascade):

restore debugSurface.brep shape
axo; fit
explode shape f
pcurve shape_1
av2d; 2dfit
fixshape res shape_1
tolerance res
p.johnston_157388's picture


Thanks for your reply. Unfortunately, I don't understand your comments as the output comes from some 3rd party software, gmsh, that is using OCC commands. I am not dealing with native OCC or its interface.

However, further correspondence with Christophe from gmsh suggests that 'the issue is related to the "unification" of surfaces that is performed after a BooleanUnion operation, through the OpenCASCADE "ShapeUpgrade_UnifySameDomain" class'. His conclusion is that 'the bad surface is generated by ShapeUpgrade_UnifySameDomain'.

Unfortunately, I don't understand what is happening here - I am just the go-between.