py-stl / stl2pov
(tl;dr: download the latest version.)
Introduction
The origin of this software was found in the desire of the author to render 3D CAD models using the POV-ray raytracer. Next to geometric primitives, POV-ray can also use meshes. One obvious way to generate those from CAD software is to use the STereoLithography ("stl") file format.
History
The first effort produced the stl2pov program, written in C. This went through the usual evolution of fixing bugs and adding features. And it reached a point where the original design ran into its limits; it ran very slow on large files because it tried to detect and correct errors (like e.g. gaps or degenerate facets) in the stl file. This turned out to be very hard to do correctly. The key problem is that only the program that generates the stl file has the geometric information and context to produce a correct stl file.
Later the author converted that program to Python as a learning experience and to easy portability. This resulted in a more re-usable version of the software to parse STL files as a Python module. This paved the way for more programs to use it.
Design
The current version is written in python, and requires version 2.x. Additionally, the stl2pdf program requires the cairo library and its python bindings.
The module stl.py reads both text and binary StereoLithography ("stl") files and creates stl.Surface objects. The actual interpreting is done in a generator method, so it is possible to read large stl files without blocking the program. The module xform.py handles coordinate transforms and projections.
The programs stl2pov, stl2ps, stl2pdf and stlinfo use this library to convert stl files to POV-ray meshes, PostScript and PDF files respectively, and to provide human readable information.
Programs
stl2pov
This is a refactoring of the C version 2.x. Version 2 was too slow, basically because it tried to do too much. This version is a straight translator. It produces a POV-ray mesh declaration that you can use in your scenes. N.B.: you have to instantiate the mesh as an object, give it material properties, define a light and a camera &c.
stl2ps
This is a new script that produces a view of the STL object looking down parallel to the positive Z-axis on the centre of the object. Rotating the object is supported. Currently the output uses only grayscale and a very simple shading algorithm. It does not draw facets that point away from the viewer. The remaining facets are sorted back to front by average depth of their vertices. The removal of completely occluded surfaces has been tested and dropped as too expensive. Shadows and more sophisticated lighting effects are not planned, but patches are welcome.
stl2pdf
This is basically a variant of stl2ps using the cairo library to generate PDF output directly.
stlinfo
print human readable information about the STL file or a human readable (text) version of the STL file.
Download
| source archive: | py-stl-3.1.zip |
|---|---|
| GPG signature: | -----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (FreeBSD)
iEYEABECAAYFAk/NC+4ACgkQEnfvsMMhpyVNQACgjN9efsOAykm3/eUuYNYDaMOf
tUYAnj1CV/L2eJzXMXQhEeaNOZF+DUpV
=QZHD
-----END PGP SIGNATURE-----
|
| SHA256 checksum: | |
| d5a2eccbd627d05b28d3b6d619202d3a55b4d94dbf21a63b68109688ebc8e929 | |
| Requirements: | python, cairo |
For those who do not want to use Python, below is the latest version written in C. This only contains the stl2pov program!
| source: | stl2pov-2.5.0.tar.gz |
|---|---|
| GPG signature: | -----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (FreeBSD)
iEYEABECAAYFAlAeqgAACgkQEnfvsMMhpyUuhwCfRHALuSNewPhYFG1FaKBkJ5jG
GB0An28fcZXNk2uc9AOI2pTOTbjwSb6f
=bYCu
-----END PGP SIGNATURE-----
|
| SHA256 checksum: | |
| 6a22915b7577db1166b03805ceb1aa01d2aa4afff67267fd4ef0246b701e3ab2 | |
| Requirements: | C development environment, make. |