edgeTriangulation isNul after connecting shapes coming from IGES file.


After importing some IGES files and connecting included shapes, I get sometimes edgeTriangulation.isNull() on some or all edges.

Does anyone knows why ?
Thank you for help.

This an abstract of my code :

I first import IGES file:
IGESControl_Reader reader;
Standard_Integer readStatus = reader.ReadFile(filename);

switch (readStatus)
case IFSelect_RetVoid:
throw WException("Load IGES empty.");
case IFSelect_RetError:
throw WException("Load IGES error.");
case IFSelect_RetFail:
throw WException("Load IGES fail.");
case IFSelect_RetStop:
throw WException("Load IGES stop.");
case IFSelect_RetDone:
// Load IGES readStatus=IFSelect_RetDone"

// Tranlate IGES -> OCC.

TopoDS_Shape initialShape = reader.OneShape();

Then, I sew the shape:
if (sewing)
BRepOffsetAPI_Sewing sewedObj(sewingDistance);

if (!sewedObj.SewedShape().IsNull())
shape = sewedObj.SewedShape();
shape = initialShape;
shape = initialShape;

Then, I triangulate:

BRepMesh_FastDiscret *TheDiscret = new BRepMesh_FastDiscret(
deflection, //const Standard_Real defle,
shape, //const TopoDS_Shape &shape,
bbox, //const Bnd_Box &B,
angle, //const Standard_Real angle,
Standard_True, //const Standard_Boolean withShare,
Standard_True, //const Standard_Boolean inshape,
Standard_False, //const Standard_Boolean relative,
Standard_False //const Standard_Boolean shapetrigu

for (exp02.Init(aShape, TopAbs_FACE); exp02.More(); exp02.Next())
TopoDS_Face face = TopoDS::Face(exp02.Current());

if (!faceTriangulation.IsNull())
TopExp_Explorer exp03;
for (exp03.Init(face, TopAbs_EDGE); exp03.More(); exp03.Next())
TopoDS_Edge edge = TopoDS::Edge(exp03.Current().Composed(face.Orientation()));

// Edge triangulation
Handle_Poly_PolygonOnTriangulation edgeTriangulation = BRep_Tool::PolygonOnTriangulation(edge, faceTriangulation, edge.Location());
if (edgeTriangulation.IsNull())


Pawel's picture

Hi Jean-Yves,

does the problem also occur without sewing?

Some models are simply either corrupt, misinterpreted (especially IGES) or not translated properly.

You could try ShapeFix after importing.


Jean-Yves Brud's picture

Dear Pawel.

The problem does not occur without sewing.

Yes the problem is cause by corrupted IGES file.
I open also the file in CAD software and try to sew. The software
is warning about topological error on somme edges.

I add ShapeFix which improve the results (but remain some edge error).
May be do I have to change the healing precision or more
fixing processing ?
This the code I had. After it, I try a second sewing:

// ------------------
// Fixing the shell.
// -----------------

// Creates tools for fixing a shell.
Handle(ShapeFix_Shell) SFS = new ShapeFix_Shell;

// Initialize the fixing tool by the shell.
TopoDS_Shell shell = TopoDS::Shell(shape);

// Fixing the set shell.

// Getting the result.
TopoDS_Shape aResult = SFS->Shape();
shape = aResult;

// ------------------
// Fixing wireframes.
// ------------------
Handle(ShapeFix_Wireframe) SFWF = new ShapeFix_Wireframe(shape);

// Set mode for removing small edges.

aResult = SFWF->Shape();

Cauchy Ding's picture

Hi Jean,

I have also suffered by the stitching problem for a log time. The stitching will introduce face topology error. The stitching algorithm heavily rely on the tolerance on each vertex and edge. And I think it's too later to use ShapeFix_* to fix errors after stitching.