Cannot Load/Save STL file

Hi,

I want to load 2 STL files, perform a boolean action and save the result.

At the moment, when writing the resulting file with stlAPI::Write, I always got an 'empty' file.

Thus, I just try to load and save an input file and I do have the same empty file on output.

StlAPI::Read(shapes[i], fileNames[i]); seems to load the file  (it took 6 seconds in debug, the mesh contains 1184 points, 2364 triangles & 2364 normals.

Using StlAPI::Write result in an empty file.

I'm using opencascade 7.0.0 for windows, visual studio 2013.

 

Can someone point me to what i'm doing wrong ?

 

Thanks

 

 

Forum supervisor's picture

Hello Vincent,

It seems that our Mesh Framework component ( http://www.opencascade.com/content/mesh-framework ) can provide the functionality you are looking for.

We have sent the initial information about this component to your personal email.

Best regards,

Forum supervisor

Thorsten H.'s picture
Vincent Daanen's picture

Hi,

did not try RWStl because I need to export a shape, resulting from a processing.

Thus my workflow is:

  • load shape_ 1 & shape_2 from STL files
  • perform processing on shapes -> resultingShape
  • export resultingShape as STL

​I'm currently experiencing using BRepMesh_IncrementalMesh​ to create a mesh and then exports it..

Thorsten H.'s picture

I am using BRepMesh_IncrementalMesh this way to get triangles:

BRepMesh_IncrementalMesh(shape, 0.001);
for (TopExp_Explorer ex(shape, TopAbs_FACE); ex.More(); ex.Next())
{
  // Triangulate current face
  TopoDS_Face F = TopoDS::Face(ex.Current());
  TopLoc_Location L = TopLoc_Location();
  Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L);
  int nbtris = facing->NbTriangles();

  const Poly_Array1OfTriangle & triangles = facing->Triangles();
  const TColgp_Array1OfPnt & nodes = facing->Nodes();
  for (int i = facing->NbTriangles(); i >= 1; i--)
  {
    Poly_Triangle triangle = triangles(i);

    Standard_Integer node1, node2, node3;
    triangle.Get(node1, node2, node3);

    gp_Pnt v1 = nodes(node1);
    gp_Pnt v2 = nodes(node2);
    gp_Pnt v3 = nodes(node3);

    //...
  }
}

To build a "StlMesh_Mesh" from I am using StlMesh_Mesh::AddDomain, StlMesh_Mesh::AddVertex and StlMesh_Mesh::AddTriangle.