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.ply(tempfile(fileext=".ply"), mesh$vertices, mesh$faces);
# save a version with RGBA vertex colors
vertex_colors = matrix(rep(82L, 5*4), ncol=4);
write.fs.surface.ply(tempfile(fileext=".ply"), mesh$vertices,
mesh$faces, vertex_colors=vertex_colors);
}
Run the code above in your browser using DataLab