TriMesh Structure

Heterogenous Batching

Since triangle mesh is heterogeneous in nature, TriMesh follows heterogeneous batching, which include three different representations. Assuming, m = TriMesh([v1, v2], [f1, f2]) where size of v1 is 3 x V1 and v2 is 3 x V2.

  • List - list of arrays in the batch. Like, get_verts_list(m) returns list of arrays of verts in the batch, [v1, v2].
  • Packed - Packed representation concatenates the list of arrays in the batch into single packed array. Like, get_verts_packed(m) returns an array of size 3 x (V1+V2).
  • Padded - Padded representation stack up the list of arrays after padding extra values. Like, get_verts_padded(m) returns an array of size 3 x max(V1,V2) x 2 and extra values are filled with 0.

List of the TriMesh constructors and all TriMesh functions.


TriMesh Constructors

Flux3D.TriMeshType
TriMesh

Initialize Triangle Mesh representation.

Fields:

  • N - Batch size of TriMesh.

  • V - Maximum vertices per mesh in TriMesh.

  • F - Maximum faces per mesh in TriMesh.

  • equalised - Bool, indicates all mesh have same verts and faces size.

  • valid -

  • offset - Offset indicating number to be added to migrate to 0-indexed system.

  • _verts_len - Number of vertices in each mesh of TriMesh.

  • _verts_list - Vertices in list format.

  • _verts_packed - Vertices in packed format.

  • _verts_padded - Vertices in padded format.

  • _faces_len - Number of faces in each mesh of TriMesh.

  • _faces_list - Vertices in list format.

  • _faces_packed - Vertices in packed format.

  • _faces_padded - Vertices in padded format.

  • _edges_packed - Edges in packed format (according to packed vertices).

  • _faces_to_edges_packed - Faces formed by edges in packed format (according to packed edges).

  • _laplacian_packed - Laplacian sparce matrix in packed format.

  • _edges_to_key - Dict mapping edges tuple to unique key.

Available Contructor:

  • TriMesh(verts_list, faces_list; offset::Number = -1)
  • TriMesh(m::Vector{<:GeometryBasics.Mesh})
  • TriMesh(m::GeometryBasics.Mesh)
  • TriMesh(m::TriMesh)
source

Loading and Saving from file

Flux3D.load_trimeshFunction
load_trimesh(fn::String...)

Load TriMesh from file(s). It will load TriMesh with multiple meshes, if multiple files are given.

Supported formats are obj, stl, ply, off and 2DM.

source
Flux3D.save_trimeshFunction
save_trimesh(fn::String, mesh::TriMesh, index::Int = 1)
save_trimesh(fn::String, mesh::GeometryBasics.Mesh)

Save mesh in given fn. index is an optional argument specifing the index of mesh, incase of multiple meshes in TriMesh mesh.

Supported formats are obj, stl, ply, off and 2DM.

source

Support for GeometryBasics.jl

TriMesh structure can be converted to and from GeometryBasics.jl Structure.

Flux3D.GBMeshFunction
GBMesh(m::TriMesh; index::Int = 1)
GBMesh(verts::AbstractArray{T,2}, faces::AbstractArray{R,2}) where {T,R}

Initialize GeometryBasics.Mesh from triangle mesh in TriMesh m at index.

See also: gbmeshes

source

Vertices and Faces

Flux3D.get_verts_listFunction
get_verts_list(m::TriMesh; refresh::Bool = false)

Returns vertices of TriMesh m in list format.

refresh is an optional keyword argument to recompute this format for TriMesh m.

See also: get_verts_padded, get_verts_packed

Examples:

julia> m = load_trimesh("teapot.obj")
julia> get_verts_list(m)
source
Flux3D.get_verts_packedFunction
get_verts_packed(m::TriMesh; refresh::Bool = false)

Returns vertices of TriMesh m in packed format.

refresh is an optional keyword argument to recompute this format for TriMesh m.

See also: get_verts_padded, get_verts_list

Examples:

julia> m = load_trimesh("teapot.obj")
julia> get_verts_packed(m)
source
Flux3D.get_verts_paddedFunction
get_verts_padded(m::TriMesh; refresh::Bool = false)

Returns vertices of TriMesh m in padded format.

refresh is an optional keyword argument to recompute this format for TriMesh m.

See also: get_verts_packed, get_verts_list

Examples:

julia> m = load_trimesh("teapot.obj")
julia> get_verts_padded(m)
source
Flux3D.get_faces_listFunction
get_faces_list(m::TriMesh; refresh::Bool = false)

Returns faces of TriMesh m in list format.

refresh is an optional keyword argument to recompute this format for TriMesh m.

See also: get_faces_padded, get_faces_list

Examples:

julia> m = load_trimesh("teapot.obj")
julia> get_faces_list(m)
source
Flux3D.get_faces_packedFunction
get_faces_packed(m::TriMesh; refresh::Bool = false)

Returns faces of TriMesh m in packed format.

refresh is an optional keyword argument to recompute this format for TriMesh m.

See also: get_faces_padded, get_faces_list

Examples:

julia> m = load_trimesh("teapot.obj")
julia> get_faces_packed(m)
source
Flux3D.get_faces_paddedFunction
get_faces_padded(m::TriMesh; refresh::Bool = false)

Returns faces of TriMesh m in padded format.

refresh is an optional keyword argument to recompute this format for TriMesh m.

See also: get_faces_padded, get_faces_list

Examples:

julia> m = load_trimesh("teapot.obj")
julia> get_faces_padded(m)
source

Edges, Laplacian Matrix and other adjacency info

Flux3D.get_edges_packedFunction
get_edges_packed(m::TriMesh; refresh::Bool = false)

Returns edges of TriMesh m in packed format. Edges are according to the indices of corresponding vertices in get_verts_packed(m)

refresh is an optional keyword argument to recompute this format for TriMesh m.

See also: get_verts_packed, get_faces_to_edges_packed

Examples:

julia> m = load_trimesh("teapot.obj")
julia> get_edges_packed(m)
source
Flux3D.get_edges_to_keyFunction
get_edges_to_key(m::TriMesh; refresh::Bool = false)

Returns dict mapping edges (tuple) of TriMesh m to unique key. Edges are according to the indices of corresponding vertices inget_verts_packed(m)

refresh is an optional keyword argument to recompute this format for TriMesh m.

See also: get_verts_packed

Examples:

julia> m = load_trimesh("teapot.obj")
julia> get_edges_to_key(m)
source
Flux3D.get_faces_to_edges_packedFunction
get_faces_to_edges_packed(m::TriMesh; refresh::Bool = false)

Returns faces of TriMesh m in form of edges. Each edge corresponds to the indices of get_edges_packed(m).

refresh is an optional keyword argument to recompute this format for TriMesh m. Assuming face f consists of (v1,v2,v3) vertices, and e1 = {v2,v3}, e2 = {v3,v1}, e3 = {v1,v2}, so face f in form of edges would be (e1,e2,e3).

See also: get_edges_packed

Examples:

julia> m = load_trimesh("teapot.obj")
julia> get_faces_to_edges_packed(m)
source
Flux3D.get_laplacian_packedFunction
get_laplacian_packed(m::TriMesh; refresh::Bool = false)
get_laplacian_sparse(m::TriMesh; refresh::Bool = false)

Returns Laplacian sparce matrix of TriMesh m.

refresh is an optional keyword argument to recompute this format for TriMesh m.

See also: laplacian_loss

Examples:

julia> m = load_trimesh("teapot.obj")
julia> get_laplacian_packed(m)
source
Flux3D.get_laplacian_sparseFunction
get_laplacian_packed(m::TriMesh; refresh::Bool = false)
get_laplacian_sparse(m::TriMesh; refresh::Bool = false)

Returns Laplacian sparce matrix of TriMesh m.

refresh is an optional keyword argument to recompute this format for TriMesh m.

See also: laplacian_loss

Examples:

julia> m = load_trimesh("teapot.obj")
julia> get_laplacian_packed(m)
source

Normals for verts/faces and faces areas

Flux3D.compute_verts_normals_listFunction
compute_verts_normals_list(m::TriMesh)

Computes Unit normal of vertices of TriMesh m in list format.

refresh is an optional keyword argument to recompute this format for TriMesh m. Normal vec of each vertex is weighted sum of normals of adjacent faces, weighted by corresponding faces areas and then normalize to unit vector.

See also: compute_verts_normals_padded, compute_verts_normals_packed

Examples:

julia> m = load_trimesh("teapot.obj")
julia> compute_verts_normals_list(m)
source
Flux3D.compute_verts_normals_packedFunction
compute_verts_normals_packed(m::TriMesh)

Computes Unit normal of vertices of TriMesh m in packed format.

refresh is an optional keyword argument to recompute this format for TriMesh m. Normal vec of each vertex is weighted sum of normals of adjacent faces, weighted by corresponding faces areas and then normalize to unit vector.

See also: compute_verts_normals_padded, compute_verts_normals_list

Examples:

julia> m = load_trimesh("teapot.obj")
julia> compute_verts_normals_packed(m)
source
Flux3D.compute_verts_normals_paddedFunction
compute_verts_normals_padded(m::TriMesh)

Computes Unit normal of vertices of TriMesh m in padded format.

refresh is an optional keyword argument to recompute this format for TriMesh m. Normal vec of each vertex is weighted sum of normals of adjacent faces, weighted by corresponding faces areas and then normalize to unit vector.

See also: compute_verts_normals_packed, compute_verts_normals_list

Examples:

julia> m = load_trimesh("teapot.obj")
julia> compute_verts_normals_padded(m)
source