Meshing with BRepMesh_IncrementalMesh - what controls accuracy?

Meshing with  BRepMesh_IncrementalMesh - what controls accuracy?
I am loading shapes from STE files,  and meshing them with  BRepMesh_IncrementalMesh
I am using BRepMesh_FastDiscret to set the parameters of 

    BRepMesh_FastDiscret::Parameters m_MeshParams;

    //Set the meshing parameters 
    m_MeshParams.Deflection = 1e-5; //This one is important. Higher values are quicker but less accurate. Use 1e-3 for fast preview, 1e-5 or smaller for accurracy 
    m_MeshParams.Angle = 0.5;
    m_MeshParams.Relative = Standard_True;
    m_MeshParams.InParallel = Standard_True;
    //aMeshParams.MinSize = aMinSize; //?? default is Standard_True
    //aMeshParams.InternalVerticesMode = isIntVertices; //!!jw?? default is Standard_True
    //aMeshParams.ControlSurfaceDeflection = isControlSurDef; //?? default is Standard_True
    m_MeshParams.AdaptiveMin = Standard_True;

     const TopoDS_Shape& aShape = .... // comes in from STEP load
    BRepMesh_IncrementalMesh m(aShape, meshParams);

This works, but it isn't giving resulats as acurate as I'd hoped. 
For instance, when getting normals of the  meshes produced, some of them I expect to be exactly aligned to the carninal axes, eg (0,0,1), but instead get them slightly off,
e.g  (1e-7, 1e-6, 1.00001)

I am comparing these numbers  to the results I get from EWDraw 
EWDraw is an Active X control  that sits on top of OpenCascade - I can't use it in this project we don't support Active X.
But I have for comparrison an exisitng setup using  EWDraw to load and examine STEP files. 

I have tried playing with the BRepMesh_FastDiscret paramaters.
Deflection seems to make the biggest difference, making it smaller gives more accurate results, at the expense of speed.
However, it still is not as accurate as I'd hoped.
Can anyone advise on fine tuning the  BRepMesh_FastDiscret parameters?

Or are there any alternatives to BRepMesh_IncrementalMesh?

Any help appreciated!



Qr Qr's picture

Try Netgen or gmsh.

Jim Williams's picture

Can you elaborate please?

What are netgen and gmsh?

Qr Qr's picture

These are the two popular open-source meshers which are purposed for generating of quality tessellations. You can easily find them: and It should be noted that BRepMesh is different in nature. BRepMesh is a faceter for generation of visualization polygons. It is not designed for analysis, and therefore it does not offer too much flexibility in tuning its parameters.

Jim Williams's picture

Thank you.


Alexander Trotsenko's picture

Try to decrease the value of the m_MeshParams.Angle parameter. It should have an effect to the triangulation accuracy. See