Main Content

readSurfaceMesh

Read 3-D surface mesh data from STL or PLY file

    Description

    example

    mesh = readSurfaceMesh(fileName) reads surface mesh data from an STL or a PLY file with the specified filename and returns it as a surfaceMesh object.

    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
    
    

    Dispaly 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
    
    

    Dispaly the surface mesh.

    surfaceMeshShow(mesh)

    Input Arguments

    collapse all

    Filename to read surface mesh data, specified as a character vector or string scalar. You must specify the file extension .stl or .ply with the filename. If the file is not in your working folder you must specify the full file path.

    Data Types: char | string

    Output Arguments

    collapse all

    Surface mesh data from an STL or a PLY file, 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.

    Version History

    Introduced in R2022b