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

Description Usage Arguments Value Note See Also Examples

View source: R/write_fs_surface.R

Description

The Object File Format is a simply ASCII format for storing meshes.

Usage

1
write.fs.surface.off(filepath, vertex_coords, faces)

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.

Value

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

Note

Do not confuse the OFF format (.off) with the Wavefront object file format (.obj), they are not identical.

See Also

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

Examples

1
2
3
4
5
6
7
    # 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);

freesurferformats documentation built on May 25, 2021, 5:10 p.m.