Decomposition
decompose functions
The decompose functions allow you to grab certain data from an AbstractGeometry like a mesh or primitive and convert it to a requested type, if possible. They can also be used to convert an array of e.g. faces into a different face type directly. The default decomposition implemented by GeoemtryBasics are:
decompose(::Type{<: Point}, source)which collects data fromsourceusingcoordinates(source)and converts it to the given point type.decompose_normals([::Type{<: Vec},] source) = decompose([::Type{Normals{<: Vec}}},] source)which collects data withnormals(source)and converts it to the given Vec type.decompose_uv([::Type{<: Vec},] source) = decompose([::Type{UV{<: Vec}}},] source)which collects data withtexturecoordinates(source)and converts it to the given Vec type. This function also exists withUVWtexture coordinates.decompose(::Type{<: AbstractFace}, source)which collects data withfaces(source)and converts it to the given face type.
Extending decompose
For decompose to work there needs to be a conversion from some element type to some target type. GeometryBasics relies on GeometryBasics.convert_simplex(TargetType, value) for this. If you want to add new types to decompose, e.g. a new face type, you will need to add a method to that function.
Primitive decomposition
GeometryBasics defines an interface to decompose geometry primitives into vertex attributes and faces. The interface includes four functions:
coordinates(primitive[, nvertices])which produces the positions associated with the primitivefaces(primitive[, nvertices])which produces the faces which connect the vertex positions to a meshnormals(primitive[, nvertices])which optionally provide normal vectors of the primitivetexturecoordinates(primitive[, nvertices])which optional provide texture coordinates (uv/uvw) of the primitive