TRI0 creates a constrained triangulation using 'ear-cutting', or 'ear-clipping' of polygons. It is a 'structural' form, a denser storage mode than 'relational' as used by TRI(), we trade some generality for size and speed.

TRI0(x, ...)

# S3 method for default
TRI0(x, ...)

# S3 method for mesh3d
TRI0(x, ...)

# S3 method for TRI0
TRI0(x, ...)

# S3 method for sfc_TIN
TRI0(x, ...)

# S3 method for TRI
TRI0(x, ...)

# S3 method for PATH0
TRI0(x, ...)

# S3 method for PATH
TRI0(x, ...)

# S3 method for sf
TRI0(x, ...)

# S3 method for sfc_GEOMETRYCOLLECTION
TRI0(x, ...)

Arguments

x

object understood by silicate (sf, sp, a silicate model, etc.)

...

currently unused

Value

TRI0 model with tables 'object', 'vertex'

Details

TRI0 is suitable for simple conversion to other mesh forms. See the examples for plotting and (in commented code) conversion to rgl's 'mesh3d'.

'Structural' means that the model does not store relational IDs between tables, the vertex indexing is stored as a nested list of data frames in the 'object' table. Unlike TRI() we cannot arbitrarily rearrange the order or remove content of the underlying tables, without updating the vertex indexes stored for each object.

Ear-cutting is inherently path-based, so this model is only available for path-based structures, like simple features, PATH(), PATH0() and ARC().

There is limited support for simple features GEOMETRYCOLLECTION, in short if the GC is composed purely of POLYGON type with 4 coordinates each this is assumed to be a collection of triangles and is converted directly without any triangulation performed. GEOMETRYCOLLECTION of any other form is not supported.

See also

TRI

Examples

tri <- TRI0(minimal_mesh)
print(tri)
#> class       : TRI0
#> type        : Primitive
#> vertices    : 14 (2-space)
#> primitives  : 14 (2-space)
#> crs         : NA
plot(tri)


# obtain the vertices and indices in raw form

## idx is the triplets of row numbers in tri$vertex
idx <- do.call(rbind, sc_object(tri)$topology_)
idx <- as.matrix(idx[c(".vx0", ".vx1", ".vx2")])

## vert is the vertices x_, y_, ...
vert <- as.matrix(sc_vertex(tri))

## now we can plot with generic tools
plot(vert)
polygon(vert[t(cbind(idx, NA)), ])


## or create other structures like rgl's mesh3d
## (see hypertidy/anglr for in-dev helpers)
## rgl::tmesh3d(t(cbind(vert, 1, 1)), t(idx),
##   material = list(color = c("firebrick", "black", "grey", "blue")),
##   meshColor = "faces")