# Update to read.ply() and associated digitizing functions

October 10, 2013
By

(This article was first published on geomorph, and kindly contributed to R-bloggers)

Dear morphometricians,

 CHANGES IN GEOMORPH VERSION 1.1-4NEW FEATURES    o Enhanced plotting of ply files in read.ply()    o digitsurface(), buildtemplate(), plotspec(), digitfixed(), and digitcurves()* now support ply file inputOTHER CHANGES    o Minor changes to plot window options in plotting functions    o Change to magnification factor usage in plotRefToTartget()
I will highlight the new read.ply() function and how this affects you, the user.
By employing the plotting capabilities of the rgl library, read.ply() now reads in information about color information of the ply file, and plots the vertices with their adjoining faces in an rgl window. The function has a new user option ShowSpecimen(=TRUE as default) that allows the user to view or not the ply file on input. The input file is an object of Mesh3d (and thus Shape3d) class, see rgl for details
myply$vb # the vertex coordinates myply$it # the face information
myply$material # color information of the vertices  Enhancement of ply file plotting in geomorph's function read.ply() and 3D digitizing functions digit.fixed(), buildtemplate(), digitsurface() and plotspec(). Screenshot from rgl window during digit.fixed(). Scallop shell surface mesh made by a NextEngine 3D laser scanner. The geomorph 3D digitizing functions now take advantage of this enhanced plotting capability. In doing so, the digitizing functions are improved because the plotted faces (and color in available) make the mesh easier to see, and more intuitive digitizing (as if you had the specimen in your hand and a microscribe to digitize the landmarks). digit.fixed("myply.ply", 5, pntsize=1) The option pntsize in digit.fixed(), digitsurface(), buildtemplate(), and plotspec() allows the user to change the size of the plotted vertex points, an accessibility improvement to the code. Also, taking advantage of a rgl function bringtotop(), now when the user types Y or N in the console to accept or reject the landmark they digitizied, the focus automatically goes back to the rgl window in anticipation of the next landmark. The changes to read.ply() function also invite easier transitions between our package geomorph and others in R (for example the package Morpho). Because our 3D digitizing functions use Mesh3d and Shape3d objects, the user is not restricted to using ply files and our read.ply function (although this is the only file type we can provide user support), but they can also input 3D mesh files of other formats which have been read in from user own functions or other packages and saved as Mesh3d/Shape3d objects using rgl functions qmesh3d() and tmesh3d(). But don't worry, if you don't have a fancy colored ply file, or a file with faces (only the vertex information), read.ply() will still work for you. And if you input the vertex information on your own, read.ply() will take it gladly, just make sure it is a matrix of number vertices by 3 (x,y,z), so that each vertex coordinates are on a separate row. We invite you to run the example in plotspec() using data(scallopPLY) and view for yourselves the enhanced plotting and digitizing capabilities of geomorph! Other improvements: The 2D digitizing functions curves2d() and digitize2d() have also had a few tweaks to improve functionality and geomorph1.1-4 now contains the code posted here in June. As always, we welcome your input. Please let us know how you are doing using these and other geomorph functions. Emma UPDATE 15:00 cdt Oct 10 2013: If you have a ply file with no color, you easily can assign a color to it in R as follows: myply$material <- "grey" # using color word
myply\$material <- "#FCE6C9" # using RGB code (see here for codes)
Note that I have set the default in read.ply() to grey, but the digitizing functions use the default color for plotting by rgl, which is black, and is not very easy to look at while digitizing!

* Slight error: function digit.curves() has not been altered for ply plotting capabilities, our mistake.