For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Failure triangulation after sewing with OCC

Game Milky's picture

Dear Supervisors and users,

I have a shape imported from Iges file. I want to sew and then triangulate the surfaces. And i face two problems in this regard

1. Triangulation without sewing works well for some cases. But in most cases it get stop after it perform some triangulation without any error message.

2. Triangulation after sewing end with a message :terminate called after throwing an instance of 'Standard_ConstructionError'.

What mistakes i do? Here below the CODE!

TopoDS_Shape ashape; //ashape is imported from IGES
int tol=1;
TopExp_Explorer exp1;
Standard_Integer NumberofFreewires3,NumberofFreeegdges3;
BRepOffsetAPI_Sewing sewedObj(tol,true);
for (exp1.Init (shape, TopAbs_FACE); exp1.More(); exp1.Next())
TopoDS_Face face = TopoDS::Face (exp1.Current());
if (!sewedObj.SewedShape().IsNull())
ashape = sewedObj.SewedShape();

// ===============================================================================================
// Triangulation part

Standard_Real aDeflection=1;
// aDeflection = ... ;

// removes all the triangulations of the faces ,
//and all the polygons on the triangulations of the edges:

// adds a triangulation of the shape aShape with the deflection aDeflection:
BRep_Builder builder;
TopoDS_Compound ResultShape;


TopExp_Explorer aExpFace,aExpEdge;

{qDebug() TopoDS_Face aFace = TopoDS::Face(aExpFace.Current());
TopLoc_Location aLocation;

// takes the triangulation of the face aFace:

Standard_Integer nbNodes, nbTriangles;
Standard_Boolean UVNodes;
gp_Pnt2d uv; gp_Pnt vertex; gp_Vec faceNormale;
Handle(Poly_Triangulation) aTr = BRep_Tool::Triangulation(aFace,aLocation);

if(!aTr.IsNull()) // if this triangulation is not NULL

// takes the array of nodes for this triangulation:

const TColgp_Array1OfPnt& aNodes = aTr->Nodes();

// takes the array of triangles for this triangulation:
const Poly_Array1OfTriangle& triangles = aTr->Triangles();

// create array of node points in absolute coordinate system
TColgp_Array1OfPnt aPoints(1, aNodes.Length());
Standard_Integer i;

for(i = 1; i

aPoints(i) = aNodes(i).Transformed(aLocation);

// Takes the node points of each triangle of this triangulation.
// takes a number of triangles:
Standard_Integer nnn = aTr->NbTriangles();
// qDebug() // qDebug()

Standard_Integer nt,n1,n2,n3;
for( nt = 1 ; nt


qDebug() qDebug()

// takes the node indices of each triangle in n1,n2,n3:
// takes the node points:
gp_Pnt aPnt1 = aPoints(n1);
gp_Pnt aPnt2 = aPoints(n2);
gp_Pnt aPnt3 = aPoints(n3);

Handle(Geom_TrimmedCurve) meshSegment1 = GC_MakeSegment(aPnt1 , aPnt2);

Handle(Geom_TrimmedCurve) meshSegment2 = GC_MakeSegment(aPnt1 , aPnt3);

Handle(Geom_TrimmedCurve) meshSegment3 = GC_MakeSegment(aPnt2 , aPnt3);

TopoDS_Edge meshEdge1 = BRepBuilderAPI_MakeEdge(meshSegment1);

TopoDS_Edge meshEdge2 = BRepBuilderAPI_MakeEdge(meshSegment2);

TopoDS_Edge meshEdge3 = BRepBuilderAPI_MakeEdge(meshSegment3);

// BRepBuilderAPI_MakeWire meshWire(meshEdge1 , meshEdge3 , meshEdge2);
TopoDS_Wire meshwire =BRepBuilderAPI_MakeWire(meshEdge1 , meshEdge3 , meshEdge2);
TopoDS_Face myFace = BRepBuilderAPI_MakeFace(meshwire);


builder.Add(ResultShape, myFace);


TopoDS_Shape aShape = ResultShape;

Thank you in advance to through the code! and comments and helps.


Game Milky's picture

I am sorry but, i made silly mistake,

for(aExpFace.Init(shape,TopAbs_FACE);aExpFace.More();aExpFace.Next()) should be


I am sorry, but error number one is as it is?

I sewed ashape and try to triangulate it, But end without any error!

It just end in between triangulation process! Without any error message!


With Best Regards


Game Milky's picture

STILL searching for the possible reason, But couldn't find the solution, any body help please!