DOKK / manpages / debian 12 / pdl / PDL::IO::STL.3pm.en
STL(3pm) User Contributed Perl Documentation STL(3pm)

PDL::IO::STL - read/write 3D stereolithography files

 use PDL;
 use PDL::IO::STL;
 ($vertices, $faceidx, $colours) = rstl('owl.stl'); # read an STL file
 wstl('file.stl', $vertices, $faceidx, $colours); # write an STL file

Normal-vector information is currently ignored. The "attribute byte count", used sometimes to store colour information, is currently ignored.

This module is based on CAD::Format::STL, but with "binmode" on opened filehandles and little-endian (i.e. network) order forced on the binary format.

Read an STL file (ASCII or binary), returning vertices and face-indices.

 ($vertices, $faceidx, $colours) = rstl('owl.stl'); # read an STL file

Simple PDL FITS writer

  wstl 'file.stl', $vertices, $faceidx;
  wstl 'file.stl', $vertices, $faceidx, \%OPTIONS;
  wstl $fh, $vertices, $faceidx, \%OPTIONS;

Passing a file-handle is supported, so multiple parts can be written to an ASCII file with several calls.

"wstl" accepts several options that may be passed in as a hash ref if desired:

Whether to write out the file as ASCII or binary.
The part name to use.

Ed J, based on Eric Wilhelm's code in CAD::Format::STL.

2023-04-27 perl v5.36.0