StlAPI::Read

Hey I was just wondering if anyone had successfully imported an STL file into OCC using this command OR any other command or script. I need to be able to import STL files into OCC so that I can manipulate them with the BRepAlgoAPI.

Thanks!
Mike

Patrik Mueller's picture

Hi,

you could try the following:

Handle(StlMesh_Mesh) theSTLMesh = theSTLMesh = RWStl::ReadFile(aFile);

After reading you have to iterate over the domains and try to build a shape having a TopoDS_Face for each STL facet.
But this needs a lot of time and memory!

Greets,

Patrik

Michael Cook's picture

Is the StlAPI::Read() function simply non-functional? Also, has anyone already written a routine to iterate over the domains and try to build a shape having a TopoDS_Face for each STL facet?

Thanks!
Mike

Forum supervisor's picture

Hello Michael,

For your information, a full fledged STL import / export interface is a part of the OMF component (Open CASCADE Mesh Framework, http://www.opencascade.org/support/products/omf/). This interface is capable of transferring STL data to and from OMF mesh data structures.

Best regards,
Forum Supervisor

PG's picture
Michael Cook's picture

Ok nevermind, I already figured out which libraries I needed. But now I have another one! The routine is ALMOST working, it just seems to be inverting many of the faces. Many of the faces are facing to the inside of the object. Does anyone know what might be wrong with the algorithm?

Also, for people who come to this thread with a similar problem to mine, the headers I needed to include are as follows:

#include
#include
#include
#include
#include
#include
#include
#include

Thanks,
Mike

PG's picture
Michael Cook's picture

Hi PG,

Thank you so much for the link. Do you by any chance know which headers are required for the algorithm in question? I get a lot of errors when I try and compile with it, it would help me out a lot if you knew this.

In the mean time I will try and hack through it, and if I get it figured out I'll post another reply. But until I do its safe to assume I haven't gotten it working.

Thanks,
Mike

Michael Cook's picture

Replying to myself becuase I posted these in a bad reply order, the above reply to PG is actually later in time than the lower reply. Sorry for the confusion.