TRI0: TRI0 model, structural triangulations

View source: R/TRI0-model.R

TRI0R Documentation

TRI0 model, structural triangulations

Description

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.

Usage

TRI0(x, ...)

## Default S3 method:
TRI0(x, ...)

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

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

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

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

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

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

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

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

Arguments

x

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

...

currently unused

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.

Value

TRI0 model with tables 'object', 'vertex'

See Also

TRI

Examples

tri <- TRI0(minimal_mesh)
print(tri)
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")

mdsumner/sc documentation built on Jan. 16, 2024, 2:03 a.m.