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

Search the Forums
See All Topics

StlMesh_MeshExplorer slow destructor?

StlMesh_MeshExplorer slow destructor?
spam killer 2013/02/12 14:10

I have a STL file with 379836 triangles. I use "StlMesh_MeshExplorer" to iterate through the triangles. When my StlMesh_MeshExplorer leaves the scope it takes ~1-2 Minutes until the debugger returns and moves on. Why takes the destructor of "StlMesh_MeshExplorer" so long?

Here is my sample code:

const Handle_StlMesh_Mesh & aStlMesh = _Mesh;
Standard_Integer NumberDomains = aStlMesh->NbDomains();
Standard_Real x1, x2, x3, y1, y2, y3, z1, z2, z3,xn,yn,zn;               
     StlMesh_MeshExplorer aMExp(aStlMesh);
     for(int i=1; i<=NumberDomains; i++)
          for(aMExp.InitTriangle(i); aMExp.MoreTriangle(); aMExp.NextTriangle())

I am using oce-0.11 (based on OCCT 6.5.4)

jelle 2013/02/12 16:29
StlMesh is suboptimal if you just want to render some mesh.
It converts the mesh to BRep, which is why its *so* slow...
Take a look at this thread
And the XSDRAWSTL* classes...

In my experience you'll be able to load / render an order of magnitude faster, so worth to take a look into this matter

spam killer 2013/02/12 17:13
I enumerate the vertices in order to calculate the gravity center an some other data. No need to render anything. The solution I have found is to completly set StlMesh_MeshExplorer aside:

int domainCount = aStlMesh->NbDomains();
for(int domainIndex = 1; domainIndex <= domainCount; domainIndex++)
     int triangleCount = aStlMesh->NbTriangles(domainIndex);
     const StlMesh_SequenceOfMeshTriangle & triangles = aStlMesh->Triangles(domainIndex);
     const TColgp_SequenceOfXYZ & vertices = aStlMesh->Vertices(domainIndex);
     for (int triangleIndex = 1; triangleIndex <= triangleCount; triangleIndex++)
          const Handle_StlMesh_MeshTriangle & triangle = triangles.Value(triangleIndex);
          int v1, v2, v3;
          triangle->GetVertexAndOrientation(v1, v2, v3, xn, yn, zn);
          const gp_XYZ & p1 = vertices.Value(v1);
          const gp_XYZ & p2 = vertices.Value(v2);
          const gp_XYZ & p3 = vertices.Value(v3);
          // and so on...

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