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 size3 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 size3 x max(V1,V2) x 2
and extra values are filled with0
.
List of the TriMesh constructors and all TriMesh functions.
Flux3D.TriMesh
Flux3D.GBMesh
Flux3D.compute_faces_areas_list
Flux3D.compute_faces_areas_packed
Flux3D.compute_faces_areas_padded
Flux3D.compute_faces_normals_list
Flux3D.compute_faces_normals_packed
Flux3D.compute_faces_normals_padded
Flux3D.compute_verts_normals_list
Flux3D.compute_verts_normals_packed
Flux3D.compute_verts_normals_padded
Flux3D.gbmeshes
Flux3D.get_edges_packed
Flux3D.get_edges_to_key
Flux3D.get_faces_list
Flux3D.get_faces_packed
Flux3D.get_faces_padded
Flux3D.get_faces_to_edges_packed
Flux3D.get_laplacian_packed
Flux3D.get_laplacian_sparse
Flux3D.get_verts_list
Flux3D.get_verts_packed
Flux3D.get_verts_padded
Flux3D.load_trimesh
Flux3D.save_trimesh
TriMesh Constructors
Flux3D.TriMesh
— TypeTriMesh
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)
Loading and Saving from file
Flux3D.load_trimesh
— Functionload_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
.
Flux3D.save_trimesh
— Functionsave_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
.
Support for GeometryBasics.jl
TriMesh structure can be converted to and from GeometryBasics.jl Structure.
Flux3D.GBMesh
— FunctionGBMesh(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
Flux3D.gbmeshes
— FunctionVertices and Faces
Flux3D.get_verts_list
— Functionget_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)
Flux3D.get_verts_packed
— Functionget_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)
Flux3D.get_verts_padded
— Functionget_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)
Flux3D.get_faces_list
— Functionget_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)
Flux3D.get_faces_packed
— Functionget_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)
Flux3D.get_faces_padded
— Functionget_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)
Edges, Laplacian Matrix and other adjacency info
Flux3D.get_edges_packed
— Functionget_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)
Flux3D.get_edges_to_key
— Functionget_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)
Flux3D.get_faces_to_edges_packed
— Functionget_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)
Flux3D.get_laplacian_packed
— Functionget_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)
Flux3D.get_laplacian_sparse
— Functionget_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)
Normals for verts/faces and faces areas
Flux3D.compute_verts_normals_list
— Functioncompute_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)
Flux3D.compute_verts_normals_packed
— Functioncompute_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)
Flux3D.compute_verts_normals_padded
— Functioncompute_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)
Flux3D.compute_faces_normals_list
— Functioncompute_faces_normals_list(m::TriMesh)
Computes Unit normal of faces of TriMesh m
in list format.
refresh
is an optional keyword argument to recompute this format for TriMesh m
.
See also: compute_faces_normals_padded
, compute_faces_normals_packed
Examples:
julia> m = load_trimesh("teapot.obj")
julia> compute_faces_normals_list(m)
Flux3D.compute_faces_normals_packed
— Functioncompute_faces_normals_packed(m::TriMesh)
Computes Unit normal of faces of TriMesh m
in packed format.
refresh
is an optional keyword argument to recompute this format for TriMesh m
.
See also: compute_faces_normals_padded
, compute_faces_normals_list
Examples:
julia> m = load_trimesh("teapot.obj")
julia> compute_faces_normals_packed(m)
Flux3D.compute_faces_normals_padded
— Functioncompute_faces_normals_padded(m::TriMesh)
Computes Unit normal of faces of TriMesh m
in padded format.
refresh
is an optional keyword argument to recompute this format for TriMesh m
.
See also: compute_faces_normals_packed
, compute_faces_normals_list
Examples:
julia> m = load_trimesh("teapot.obj")
julia> compute_faces_normals_padded(m)
Flux3D.compute_faces_areas_list
— Functioncompute_faces_areas_list(m::TriMesh)
Computes area of faces of TriMesh m
in list format.
refresh
is an optional keyword argument to recompute this format for TriMesh m
.
See also: compute_faces_areas_padded
, compute_faces_areas_packed
Examples:
julia> m = load_trimesh("teapot.obj")
julia> compute_faces_areas_list(m)
Flux3D.compute_faces_areas_packed
— Functioncompute_faces_areas_packed(m::TriMesh)
Computes area of faces of TriMesh m
in packed format.
refresh
is an optional keyword argument to recompute this format for TriMesh m
.
See also: compute_faces_areas_padded
, compute_faces_areas_list
Examples:
julia> m = load_trimesh("teapot.obj")
julia> compute_faces_areas_packed(m)
Flux3D.compute_faces_areas_padded
— Functioncompute_faces_areas_padded(m::TriMesh)
Computes area of faces of TriMesh m
in padded format.
refresh
is an optional keyword argument to recompute this format for TriMesh m
.
See also: compute_faces_areas_packed
, compute_faces_areas_list
Examples:
julia> m = load_trimesh("teapot.obj")
julia> compute_faces_areas_padded(m)