Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Search the Forums
See All Topics

Failure triangulation after sewing with OCC

Failure triangulation after sewing with OCC
Game Milky 2012/11/26 13:35
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();
qDebug() << " not possible";

      //     ===============================================================================================
      // 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;

      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 < aNodes.Length()+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()<<i<<endl;
      // qDebug()<<"Number of Triangles : = "<<nnn<<endl;

      Standard_Integer nt,n1,n2,n3;
      for( nt = 1 ; nt < nnn+1 ; nt++)


            qDebug()<<"Number of Triangles : = "<<nnn<<endl;

      // 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 2012/11/26 14:09

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 2012/11/27 18:41

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


Latest news
  • Open CASCADE CAD Assistant for iOS platform is available!
  • Open CASCADE Technology 6.9.0 is available for download!
  • JT Assistant for Android

  • © OPEN CASCADE 2000 - 2015  |  Search  |  Contacts   |  Site map