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

Search the Forums
See All Topics
Open CASCADEShowroomGet it!Developer CornerSupport and ProductsAbout us
Technical overview
Areas of use
Advantages
FAQ
Screenshots
Shape factory
Shape gallery
Demonstrations
What's new
System requirements
Download Center
Public license
Documentation
Getting started
Forums
Open Source community
Training and e-learning
A-la Carte Support
Value-added software
Complementary Components
Customer Corner
Company Profile
Marketing Materials
Contact Us
News
Home / Developer Corner / Forums / Usage issues / Failure triangulation after sewing with OCC

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

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

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

qDebug()<<"DOne";

      TopExp_Explorer aExpFace,aExpEdge;
      for(aExpFace.Init(shape,TopAbs_FACE);aExpFace.More();aExpFace.Next())

      {qDebug()<<"DOne";
      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()<<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);

      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);

      if(!myFace.IsNull())

            builder.Add(ResultShape, myFace);
      else
            continue;
      }

      }
      else
            continue;

}
      TopoDS_Shape aShape = ResultShape;

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

Game

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

for(aExpFace.Init(ashape,TopAbs_FACE);aExpFace.More();aExpFace.Next())

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!

Help?

With Best Regards

Game
Game Milky 2012/11/27 18:41
     

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

Regards


Game
 
 
Latest news
  • Open CASCADE Technology 6.7.0 is available for download!
  • Open CASCADE Technology 6.6.0 is available for download!
  • Open CASCADE Technology 6.5.5 is available for download!

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