Incorrect normals


I' trying to triangulate and visualize some STEP models in the custom visualizer and I spotted an issue with normals of one specific model (model s1-tu-203 available at the I tried to visualize the same model using CAD Assistant and the normals seem to be correct there (see the attached images Custom_shaded.jpg and CADAssistant_shaded.jpg).

I also noticed that the triangulated mesh looks very different in the custom visualizer compared to the result produced by the CAD Assistant (see the attached images Custom_wireframe.jpg and CADAssistant_wireframe.jpg).

I performed triangulation using BRepMesh_IncrementalMesh class and then I used BRepLib::EnsureNormalConsistency to fix normals on the face edges. The described issue does not appear when I do not use BRepLib::EnsureNormalConsistency.

It looks like there's a problem with the resulting normal of the shared vertex between multiple triangles (in the center of the sphere) produced by BRepLib::EnsureNormalConsistency.

I tried to fiddle with the BRepMesh_IncrementalMesh parameters but the incorrect normals in the center of the sphere still remained even for the more detailed mesh.

Used configuration:

  • OCCT version: 7.4.0
  • BRepLib::EnsureNormalConsistency parameters:
    • AngTol: 0.001
    • ForceComputeNormals: True
  • BRepMesh_IncrementalMesh parameters (the rest was left to defaults):
    • AngularDeflection: 0.296706 (17 deg)
    • LinearDeflection: 0.3
    • MinSize: 1e-7
    • Relative: True
    • AdaptiveMin: False
    • InternalVerticesMode: True
    • ControlSurfaceDeflection: True
    • InParallel: True

My questions are:

  1. Is CAD Assistant using the same BRepMesh_IncrementalMesh algorithm for triangulation and also BRepLib::EnsureNormalConsistency for fixing normals on the edges?
  2. If yes, is there a possibility, that it may be caused by a different BRepMesh_IncrementalMesh or BRepLib::EnsureNormalConsistency parameter settings?
  3. If yes, would it be possible to share those settings?

Thanks in advance.

Kirill Gavrilov's picture

The described issue does not appear when I do not use BRepLib::EnsureNormalConsistency.

Haven't you already answered to your question by localizing, that normals are corrupted by BRepLib::EnsureNormalConsistency()?

ReadStep D s1-tu-203.stp
vinit View1
#XDisplay -dispMode 1 D
XGetOneShape s D
#incmesh s 1; correctnormals s; vdefaults -autoTriang 0
vdisplay -dispMode 1 s

Andrej Kudinov's picture

Kirill, thanks for the answer.

Yes, that is correct. The corrupted normals are produced by BRepLib::EnsureNormalConsistency. I'm trying to figure out why those normals are corrupted, what might be done differently compared to CAD Assistant, and how to fix it.

As I stated before, input triangulation passed to BRepLib::EnsureNormalConsistency is very different compared to the triangulation produced by CAD Assistant which may have an impact on the produced normals. This may be possibly caused by a different triangulation algorithm or the input parameters either of BRepMesh_IncrementalMesh or BRepLib::EnsureNormalConsistency.

I would appreciate any help with narrowing down this issue. Please, let me know if more information is needed.