Toolbox to read and write STL files (ascii and binary formats)
* Installation:
1. Download and extract the Zip file
2. Run builder.sce script in the sources folder
3. Run loader.sce script in the sources folder
4. Run demos in the *demos* folder
* To read data from a STL file:
t = stlread(filename, fmt)
* To write data to a STL file:
stlwrite(t, filename, fmt)
Arguments:
- filename: a character string containing the path of the STL file
- fmt: a character string specifying the format of the STL file (e.g.
"ascii" or "binary")
- t: a tlist of type stldata
* Data storage:
Data are stored in a tlist of type stldata
The list fields are:
- header: the string at the begining of the STL file
- x: a [3xn] matrix wich represent the X coordinates of the model (one colum per
facet)
- y: a [3xn] matrix wich represent the Y coordinates of the model (one colum per
facet)
- z: a [3xn] matrix wich represent the Z coordinates of the model (one colum per
facet)
- normals: a [3xn] matrix wich represent the normals of the model (one colum per
facet)
* Data display in the Scilab console:
The display of the data is overloaded. Example:
-->t
t =
Summary
Header: >3D Systems - View: ship.stl
#faces: 828 triangles
#vertices: 2484 (non unique)
Vertices coordinates [x y z] (first 5 only)
2.02900 1.62800 0.91100
2.22900 1.62800 0.91100
2.22900 1.67200 0.91100
2.22900 1.67200 0.91100
2.02900 1.67200 0.91100
...
Normals coordinates [x y z] (first 5 only)
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
1.00000 1.00000 1.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
...
* 3D model display:
The 3D model is displayed using the plot3d function:
figure
tcolor = 2*ones(1, size(t.x,"c"))
plot3d(t.x, t.y, list(t.z,tcolor));
a = gca()
a.isoview = "on"
* Bibliography
- John Burkardt's website: http://people.sc.fsu.edu/~jburkardt/data/data.html
- The STL Library: http://www.eng.nus.edu.sg/LCEL/RP/u21/wwwroot/stl_library.htm)
* Version history
2.1 - August 11, 2018 - Bug fix when reading header in STL binary file.
2.0 - March 19, 2017 - First release for Scilab 6
1.0 - August 26, 2016 - First release for Scilab 5.5