Learn R Programming

meshsimp (version 0.1.1)

import.mesh.2.5D: Instantiate a mesh.2.5D object from file.

Description

This function reads a surface mesh from file, and returns an object of class mesh.2.5D holding the list of nodes and triangles in the mesh. The parsing of the file is carried out at the C++ level for the sake of efficiency.

Usage

import.mesh.2.5D(file)

Arguments

file

Absolute or relative path to the input mesh; the following file formats are supported:

  • AVS UCD ASCII (extension .inp);

  • text files (extension .txt);

  • Legacy VTK (extension .vtk).

Text files are assumed to be structured as the AVS UCD ASCII files (.inp extension).

Value

An object of class mesh.2.5D, provided with the following attributes:

  • nnodes: number of nodes in the mesh;

  • nodes: nnodes-by-3 matrix collecting the coordinates of each vertex;

  • ntriangles: number of triangles in the mesh;

  • triangles: a ntriangles-by-3 (when order = 1) or ntriangles-by-6 (when order = 2) matrix. It specifies the triangles giving the row indices in nodes of the triangles vertices and (when order = 2) also of the triangles edges midpoints;

  • order: either '1' or '2'. It specifies whether each mesh triangle should be represented by \(3\) nodes (the triangle vertices) or by \(6\) nodes (the triangle vertices and midpoints of the triangle edges). These are respectively used for linear (order = 1) and quadratic (order = 2) Finite Elements. Default is order = 1.

See Also

simplify.mesh.2.5D, plot.mesh.2.5D

Examples

Run this code
## Import the mesh of a pawn
fpath <- system.file("extdata", "pawn_250.inp", package="meshsimp")
mesh <- import.mesh.2.5D(fpath)
## Simplify the mesh down to 200 nodes; assume the components of the
## edge cost functions are equally weighted and that the data locations
## coincide with the vertices of the mesh
out1 <- simplify.mesh.2.5D(mesh, 200)
## Resume the simplification procedure, reducing the mesh down to 150 nodes
out2 <- simplify.mesh.2.5D(out1$mesh, 150, out1$locations)

Run the code above in your browser using DataLab