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);
//sewedObj.NonManifoldMode();
for (exp1.Init (shape, TopAbs_FACE); exp1.More(); exp1.Next())
{
TopoDS_Face face = TopoDS::Face (exp1.Current());
sewedObj.Add(face);
}
sewedObj.Perform();
if (!sewedObj.SewedShape().IsNull())
ashape = sewedObj.SewedShape();
else
qDebug() << " not possible";
// ===============================================================================================
// Triangulation part
// removes all the triangulations of the faces ,
//and all the polygons on the triangulations of the edges:
BRepTools::Clean(ashape);
// adds a triangulation of the shape aShape with the deflection aDeflection:
BRepMesh::Mesh(ashape,aDeflection);
BRep_Builder builder;
TopoDS_Compound ResultShape;
builder.MakeCompound(ResultShape);
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()<<nt<<endl;
qDebug()<<"Number of Triangles : = "<<nnn<<endl;
// takes the node indices of each triangle in n1,n2,n3:
triangles(nt).Get(n1,n2,n3);
// takes the node points:
gp_Pnt aPnt1 = aPoints(n1);
gp_Pnt aPnt2 = aPoints(n2);
gp_Pnt aPnt3 = aPoints(n3);