Main Content

stlread

Create triangulation from STL file

Description

example

TR= stlread(filename)返回一个triangulationobjectTRcontaining the triangles defined in an STL file.

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

Examples

collapse all

Create and plot atriangulationobject from the data contained in the filetristltext.stl.

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

Figure contains an axes object. The axes object contains an object of type line.

Input Arguments

collapse all

STL file name, specified as a character vector or scalarstring. The file name must end with the.stlor.STLextension. If the file contains degenerate triangles, thenstlreadautomatically removes them.

Example:'stltextfile.stl'

Output Arguments

collapse all

Triangulation, returned as atriangulationobject.

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

Binary attributes, returned as auint16vector. When the input file is binary,attributescontains 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, thenattributesis 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,solidIDcontains all ones. The length ofsolidIDis equal to the number of triangles in the triangulation.

Data Types:double

Version History

Introduced in R2018b

See Also