vispy.geometry.meshdata.
MeshData
Bases: object
object
Class for storing and operating on 3D mesh data.
Vertex coordinates. If faces is not specified, then this will instead be interpreted as (Nf, 3, 3) array of coordinates.
Indices into the vertex array.
[not available yet]
Vertex colors. If faces is not specified, this will be interpreted as (Nf, 3, 4) array of colors.
Face colors.
Vertex values.
Notes
All arguments are optional.
The object may contain:
list of vertex locations
list of edges
list of triangles
colors per vertex, edge, or tri
normals per vertex or tri
This class handles conversion between the standard [list of vertices, list of faces] format (suitable for use with glDrawElements) and ‘indexed’ [list of vertices] format (suitable for use with glDrawArrays). It will automatically compute face normal vectors as well as averaged vertex normal vectors.
The class attempts to be as efficient as possible in caching conversion results and avoiding unnecessary conversions.
get_bounds
Get the mesh bounds
A list of tuples of mesh bounds.
get_edge_colors
get_edges
Edges of the mesh
If indexed is None, return (Nf, 3) array of vertex indices, two per edge in the mesh. If indexed is ‘faces’, then return (Nf, 3, 2) array of vertex indices with 3 edges per face, and two vertices per edge.
The edges.
get_face_colors
Get the face colors
If indexed is None, return (Nf, 4) array of face colors. If indexed==’faces’, then instead return an indexed array (Nf, 3, 4) (note this is just the same array with each color repeated three times).
The colors.
get_face_normals
Get face normals
If None, return an array (Nf, 3) of normal vectors for each face. If ‘faces’, then instead return an indexed array (Nf, 3, 3) (this is just the same array with each vector copied three times).
The normals.
get_faces
Array (Nf, 3) of vertex indices, three per triangular face.
If faces have not been computed for this mesh, returns None.
get_vertex_colors
Get vertex colors
If None, return an array (Nv, 4) of vertex colors. If indexed==’faces’, then instead return an indexed array (Nf, 3, 4).
The vertex colors.
get_vertex_faces
List mapping each vertex index to a list of face indices that use it.
get_vertex_normals
Get vertex normals
If None, return an (N, 3) array of normal vectors with one entry per unique vertex in the mesh. If indexed is ‘faces’, then the array will contain three normal vectors per face (and some vertices may be repeated).
get_vertex_values
If None, return an array (Nv,) of vertex values. If indexed==’faces’, then instead return an indexed array (Nf, 3).
The vertex values.
get_vertices
Get the vertices
If Note, return an array (N,3) of the positions of vertices in the mesh. By default, each unique vertex appears only once. If indexed is ‘faces’, then the array will instead contain three vertices per face in the mesh (and a single vertex may appear more than once in the array).
The vertices.
has_edge_indexed_data
has_face_color
Return True if this data set has face color information
has_face_indexed_data
Return True if this object already has vertex positions indexed by face
has_vertex_color
Return True if this data set has vertex color information
has_vertex_value
Return True if this data set has vertex value information
n_faces
The number of faces in the mesh
n_vertices
The number of vertices in the mesh
reset_normals
restore
Restore the state of a mesh previously saved using save()
The previous state.
save
Serialize this mesh to a string appropriate for disk storage
The state.
set_face_colors
Set the face color array
Array of colors. Must have shape (Nf, 4) (indexed by face), or shape (Nf, 3, 4) (face colors indexed by faces).
Should be ‘faces’ if colors are indexed by faces.
set_faces
Set the faces
(Nf, 3) array of faces. Each row in the array contains three indices into the vertex array, specifying the three corners of a triangular face.
set_vertex_colors
Set the vertex color array
Array of colors. Must have shape (Nv, 4) (indexing by vertex) or shape (Nf, 3, 4) (vertices indexed by face).
set_vertex_values
Set the vertex value array
Array of values. Must have shape (Nv,) (indexing by vertex) or shape (Nf, 3) (vertices indexed by face).
set_vertices
Set the mesh vertices
The array (Nv, 3) of vertex coordinates.
If indexed==’faces’, then the data must have shape (Nf, 3, 3) and is assumed to be already indexed as a list of faces. This will cause any pre-existing normal vectors to be cleared unless reset_normals=False.
If True, reset the normals.