Main Content

stlread

Create triangulation from STL file

Description

example

TR = stlread(filename) returns a triangulation object TR containing the triangles defined in an STL file.

[TR,fileformat,attributes,solidID] = stlread(filename) also returns the file format of filename, attributes when the file is binary, and solid identification numbers when the file is text.

Examples

collapse all

Create and plot a triangulation object from the data contained in the file tristltext.stl.

TR = stlread('tristltext.stl');
triplot(TR)

Input Arguments

collapse all

STL file name, specified as a character vector or scalar string. The file name must end with the .stl or .STL extension. If the file contains degenerate triangles, then stlread automatically removes them.

Example: 'stltextfile.stl'

Output Arguments

collapse all

Triangulation, returned as a triangulation object.

File format, returned as either 'binary' or 'text'.

Binary attributes, returned as a uint16 vector. When the input file is binary, attributes contains coded information about the triangles. Its length is equal to the number of triangles in the triangulation. If the input file is a text file, then attributes is an empty array.

Solid grouping index, returned as a vector of identification numbers. When the input file is a text file, the identification numbers assign each triangle to a grouping of triangles in the triangulation. When the input file is binary, solidID contains all ones. The length of solidID is equal to the number of triangles in the triangulation.

Data Types: double

Extended Capabilities

Thread-Based Environment
Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.

Version History

Introduced in R2018b