mesh_mark_pois: Interactively record points of interest (POIs) on the surface...

View source: R/mesh_mark_pois.R

mesh_mark_poisR Documentation

Interactively record points of interest (POIs) on the surface of a 3D mesh.

Description

[Experimental]

Usage

mesh_mark_pois(
  mesh,
  pois = data.frame(),
  button = "right",
  prev_color = NA,
  color = "red",
  size = 12
)

Arguments

mesh

A triangular mesh object (mesh3d) to be marked.

pois

(Optional) A data frame representing previously marked POIs. It should be the output of a previous run of this or the drop_poi() function.

button

The mouse button used for marking POIs. Defaults to "right". See rgl.select() for details.

prev_color

The color used to display previously marked POIs. Defaults to NA, which results in automatically generated colors along a reversed "Blue-Red 2" palette (see grDevices::hcl.colors() for details), so that the order in which the POIs were marked can be visualized.

color

The color for newly marked POIs. Defaults to "red".

size

The size of the POI markers. Defaults to 12. Adjust as needed for visibility.

Details

This function enables interactive recording of POIs on a 3D mesh. It displays the mesh along with any previously marked POIs and allows users to select new POIs using a mouse-driven interface. POIs are marked by clicking on the mesh surface. The function returns a data frame containing the marked POIs.

This function uses the 'rgl' package to provide an interactive 3D environment for marking POIs. It requires an open RGL window to function properly. If no window is open, it plots the mesh and previously marked POIs, if any.

Users can mark new POIs by clicking on the mesh surface and hitting the ESC button on the keyboard when done (note: the RGL window should not be closed while the function is running). The marked POIs are displayed as colored markers, and their coordinates are stored in the returned data frame.

Value

A data frame containing the marked POIs with columns "x", "y", "z", and "Tag".

See Also

drop_poi() for removing bad POIs; material3d() for details on the prev_color, color, and size parameters.

Examples

## Not run: 
# Example usage:
# Create a dataset with marked POIs
mesh <- mesh_recenter(demoFlake2$mesh)$mesh # Ensure the mesh is centered
pois <- mesh_mark_pois(mesh)

# Drop the last POI and update the 3D scene
pois <- drop_poi(pois)

# Close the 3D scene
rgl::close3d()

# Plot the mesh again, showing previously marked POIs
pois <- mesh_mark_pois(mesh, pois)

# Close the 3D scene
rgl::close3d()

## End(Not run)



cornelmpop/Lithics3D documentation built on Feb. 10, 2024, 11:54 p.m.