Main Content

readSurfaceMesh

Read 3-D surface mesh data from standard mesh file formats

Since R2022b

    Description

    mesh = readSurfaceMesh(fileName) reads surface mesh data from a supported mesh file format with the specified filename, and returns it as a surfaceMesh object.

    example

    Examples

    collapse all

    Specify a PLY file from which to read surface mesh data.

    fileName = fullfile(toolboxdir("lidar"),"lidardata", ...
    "surfaceMesh","sphere.ply");

    Read surface mesh data from the PLY file into the workspace.

    mesh = readSurfaceMesh(fileName)
    mesh = 
      surfaceMesh with properties:
    
             Vertices: [482x3 double]
                Faces: [956x3 int32]
        VertexNormals: [482x3 double]
         VertexColors: []
          FaceNormals: []
           FaceColors: []
          NumVertices: 482
             NumFaces: 956
    
    

    Display the surface mesh.

    surfaceMeshShow(mesh)

    Specify an STL file from which to read surface mesh data.

    fileName = fullfile(toolboxdir("lidar"),"lidardata", ...
    "surfaceMesh","mobius.stl");

    Read surface mesh data from the STL file into the workspace.

    mesh = readSurfaceMesh(fileName)
    mesh = 
      surfaceMesh with properties:
    
             Vertices: [1050x3 double]
                Faces: [1960x3 int32]
        VertexNormals: []
         VertexColors: []
          FaceNormals: [1960x3 double]
           FaceColors: []
          NumVertices: 1050
             NumFaces: 1960
    
    

    Display the surface mesh.

    surfaceMeshShow(mesh)

    Input Arguments

    collapse all

    Filename of surface mesh data to read, specified as a character vector or string scalar. You must specify the file extension with the filename. If the file is not in your working folder you must specify the full file path. The function supports these standard mesh file formats:

    • STL — Stereolithography file format

    • PLY — Polygon file format

    • FBX® — Autodesk® Filmbox

    • OBJ — Wavefront® OBJ

    • GLTF — GL Transmission Format, glTF™

    • GLB — GL Transmission Format Binary File

    • OFF — Object File Format

    • DAE — COLLADA™ Digital Asset Exchange

    • STEP or STP — Standard for the Exchange of Product Data

    • IGES or IGS — Initial Graphics Exchange Specification

    Data Types: char | string

    Output Arguments

    collapse all

    Surface mesh data, returned as a surfaceMesh object.

    Limitations

    • You cannot read these attributes from an STL file.

      • Vertex normals

      • Vertex colors

      • Face colors

    • You cannot read face colors from a PLY file.

    • You can read only mesh vertices, vertex colors, and mesh triangular faces from the FBX file format.

    • You can read only mesh vertices and mesh triangular faces from the OBJ, GLTF, GLB, OFF, DAE, STEP, STP, IGES, or IGS file formats.

    Version History

    Introduced in R2022b

    expand all