The R package `molaR`

provides functions that allow the user to quantitatively measure and graphically represent dental surface topography. The following is a demonstration of the primary functions in `molaR`

, as well as some recommended best practices.

`molaR`

analyzes three-dimensional embedded triangular mesh files (*.ply files). These files can be imported into R with the function `vcgPlyRead()`

from the package `Rvcg`

, which can also clean meshes for users. Two sample mesh data files are provided with the `molaR`

package for function demonstration and for users to experiment with: â€˜Toothâ€™ is a scanned M_{1} of *Chlorocebus sabaeus* (a vervet monkey: USNM 112176). â€˜Hillsâ€™ is an undulating plane produced with the formula: `z = 3cos(x/2) + 3sin(y/2)`

.

```
## List of 4
## $ vb : num [1:4, 1:5054] 0.168 1.904 3.218 1 0.198 ...
## $ it : num [1:3, 1:9999] 1 6 5 9 8 1 8 6 1 4 ...
## $ normals : num [1:4, 1:5054] -0.946 -0.269 0.181 1 -0.843 ...
## $ material: list()
## - attr(*, "class")= chr "mesh3d"
```

This vignette was composed using `rmarkdown`

within RStudio ver. 1.2.5033. It contains WebGL figures that were produced with `rglwidget()`

from the `rgl`

package. To properly view WebGL figures, your browser must be running Javascript and WebGL. Visit https://get.webgl.org for further information. 3D plots in this vignette can be rotated using the left mouse button and zoomed with the mouse wheel.

Dirichlet normal energy can be calculated on a surface with the `DNE()`

function. Face energy density values (i.e.Â the measures of localized curvature) can then be rendered onto a three dimensional surface plot using `DNE3d()`

. `DNE()`

has 2 important arguments for users:

`outliers`

The first argument, `outliers`

, sets the percentage range of outlier faces to be excluded from the DNE summation. Default for outlier exclusion is the top one tenth of one percent (0.001). Some surfaces will require a larger outlier exclusion value, to account for irregularities on the surface.

Typically, outlier faces are associated with dimples, cracks, spikes, or other imperfections on the mesh which are not representative of the overall curvature of the surface. These imperfections can arise due to the molding, casting, scanning, or downstream digital processing of teeth, but may also be â€˜realâ€™ surface features. In the case of these imperfections arising from the original specimen, users should exercise their best judgment when incorporating these features into their analyses. Artifacts arising from the production of the surfaces should ideally be eliminated prior to importation of the surface into R.

Outlier exclusion is very important for DNE calculation because DNE is a geometrically-based summation. As a curve tightens on a surface, the localized calculation of DNE increases exponentiallyâ€”not linearly. In some cases, outlier faces will have localized DNE values larger than the rest of the surface combined. Including outliers in the DNE summation is therefore often unrepresentative of the gestalt surface curvature.

`BoundaryDiscard`

The second argument, `BoundaryDiscard`

, sets the criteria for excluding surface faces on the boundary of the mesh. Excluding faces on the boundary of the mesh is important because often these faces have highly irregular and inconsistent vertex normalsâ€”due to the lack of an adjacent face with which to calibrate the orientation of the vertex normal. Because the orientations of the vertex normals are included in the DNE calculation, it is important that they be accurate, however this is often not the case with vertices on the mesh boundary.

There are three options for `BoundaryDiscard`

: â€˜Vertexâ€™ (default) will exclude faces with at least 1 vertex on the boundary from the DNE summation. â€˜Legâ€™ will exclude faces which have a leg (i.e., 2 vertices) on the boundary; this setting was formerly the default and many previous publications have used this boundary exclusion criterion. However, recent studies have shown that â€˜Vertexâ€™ more reliably eliminates problematic faces. â€˜Noneâ€™ will not discard any boundary faces, this option should be used when working on a closed surface (i.e., a mesh with no boundary).

`## Total Surface DNE = 183.9593`

`DNE3d()`

The energy densities calculated across the surface can be plotted using the `DNE3d()`

function. Due to the skewed distribution of exponentially-increasing energy densities, with relatively few mesh faces typically contributing large values to the total surface DNE, DNE plots by default display log-transformed surface energy, which users can disable with the `logColors`

parameter.