Learn R Programming

freesurferformats (version 0.1.18)

write.fs.surface.off.ply2: Write mesh to file in Object File Format (.off) or PLY2 format.

Description

The two formats are very similar, they only differ in the header lines. This function can write both.

Usage

write.fs.surface.off.ply2(filepath, vertex_coords, faces, format)

Value

string the format that was written. One of "tris" or "quads". Currently only triangular meshes are supported, so always 'tris'.

Arguments

filepath

string. Full path to the output surface file, should end with '.off', but that is not enforced.

vertex_coords

n x 3 matrix of doubles. Each row defined the x,y,z coords for a vertex.

faces

n x 3 matrix of integers. Each row defined the 3 vertex indices that make up the face. WARNING: Vertex indices should be given in R-style, i.e., the index of the first vertex is 1. However, they will be written in FreeSurfer style, i.e., all indices will have 1 substracted, so that the index of the first vertex will be zero.

format

character string, the format to write. One of 'ply2' or 'off'.

See Also

Other mesh export functions: write.fs.surface.obj(), write.fs.surface.off(), write.fs.surface.ply2(), write.fs.surface.ply(), write.fs.surface()

Examples

Run this code
if (FALSE) {
    # Read a surface from a file:
    surface_file = system.file("extdata", "lh.tinysurface",
     package = "freesurferformats", mustWork = TRUE);
    mesh = read.fs.surface(surface_file);

    # Now save it:
    write.fs.surface.off(tempfile(fileext=".off"), mesh$vertices, mesh$faces);
}

Run the code above in your browser using DataLab