Scilab Home Page | Wiki | Bug Tracker | Forge | Mailing List Archives | Scilab Online Help | ATOMS
File : Details
Login with GitLab

STL Files

Read and write STL files (ascii and binary formats)
(257 downloads for this version - 805 downloads for all versions)
Details
Version
2.0
A more recent valid version with binaries for Scilab exists: 2.1
Author
Jerome Briot
Maintainer
Jerome Briot
Category
License
Supported Scilab Version
6.0
Creation Date
March 19, 2017
Description
            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"            
Files (1)
[20.55 kB]
Miscellaneous file

News (0)
Comments (1)     Leave a comment 
Comment from Luc Blecha -- August 10, 2018, 11:09:40 AM    
There is a bug during reading STL normals. I had to change line 47
        t.normals = matrix(t.normals, 3, -1)
to
	t.normals = t.normals'

Otherwize, all fine. Thanks for the nice work.
Answer from Jerome Briot -- August 11, 2018, 02:28:11 PM    
Hi,

I cant't reproduce this bug with the numerous files I have. 

Could you email me one of your file ?

By the way, I fixed another bug and published a new version 2.1 of this toolbox.

Thanks
Leave a comment
You must register and log in before leaving a comment.
Login with GitLab
Email notifications
Send me email when this toolbox has changes, new files or a new release.
You must register and log in before setting up notifications.