-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSTEP2STL.cpp
29 lines (20 loc) · 887 Bytes
/
STEP2STL.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <STEPControl_Reader.hxx>
#include <StlAPI_Writer.hxx>
#include <StdPrs_ToolTriangulatedShape.hxx>
#include <Prs3d_Drawer.hxx>
int main()
{
Standard_CString stpFileName = "/home/alex/Documents/STEP2STL/data/screw.step";
Standard_CString stlFileName = "/home/alex/Documents/STEP2STL/data/screw.step.stl";
STEPControl_Reader reader;
IFSelect_ReturnStatus status = reader.ReadFile(stpFileName);
Standard_Integer nbRoots = reader.NbRootsForTransfer();
Standard_Integer nbTrans = reader.TransferRoots();
TopoDS_Shape shape = reader.OneShape();
Handle(Prs3d_Drawer) aDrawer = new Prs3d_Drawer();
Standard_Boolean result = StdPrs_ToolTriangulatedShape::Tessellate(shape, aDrawer);
StlAPI_Writer writer;
//writer.ASCIIMode() = Standard_False;
writer.Write(shape, stlFileName);
return 0;
}