Uranium
Application Framework
Loading...
Searching...
No Matches
UM.Mesh.MeshData.MeshData Class Reference

Public Member Functions

None __init__ (self, vertices=None, normals=None, indices=None, colors=None, uvs=None, file_name=None, center_position=None, zero_position=None, type=MeshType.faces, attributes=None)
 __del__ (self)
"MeshData" set (self, vertices=Reuse, normals=Reuse, indices=Reuse, colors=Reuse, uvs=Reuse, file_name=Reuse, center_position=Reuse, zero_position=Reuse, attributes=Reuse)
 getHash (self)
Vector getCenterPosition (self)
Vector getZeroPosition (self)
 getType (self)
int getFaceCount (self)
numpy.ndarray getVertices (self)
int getVertexCount (self)
 getVertex (self, index)
bool hasNormals (self)
numpy.ndarray getNormals (self)
bool hasIndices (self)
numpy.ndarray getIndices (self)
bool hasColors (self)
numpy.ndarray getColors (self)
bool hasUVCoordinates (self)
Optional[str] getFileName (self)
"MeshData" getTransformed (self, Matrix transformation)
Optional[AxisAlignedBoxgetExtents (self, Optional[Matrix] matrix=None)
Optional[bytes] getVerticesAsByteArray (self)
Optional[bytes] getNormalsAsByteArray (self)
Optional[bytes] getIndicesAsByteArray (self)
Optional[bytes] getColorsAsByteArray (self)
Optional[bytes] getUVCoordinatesAsByteArray (self)
Optional[scipy.spatial.ConvexHull] getConvexHull (self)
Optional[numpy.ndarray] getConvexHullVertices (self)
Optional[numpy.ndarray] getConvexHullTransformedVertices (self, Matrix transformation)
Tuple[numpy.ndarray, numpy.ndarray] getFacePlane (self, int face_id)
Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray] getFaceNodes (self, int face_id)
bool hasAttribute (self, str key)
 getAttribute (self, str key)
List[str] attributeNames (self)
None invertNormals (self)
str toString (self)

Protected Member Functions

None _computeConvexHull (self)

Protected Attributes

 _application = None
 _vertices = NumPyUtil.immutableNDArray(vertices)
 _normals = NumPyUtil.immutableNDArray(normals)
 _indices = NumPyUtil.immutableNDArray(indices)
 _colors = NumPyUtil.immutableNDArray(colors)
 _uvs = NumPyUtil.immutableNDArray(uvs)
int _vertex_count = len(self._vertices) if self._vertices is not None else 0
int _face_count = len(self._indices) if self._indices is not None else 0
 _type = type
 _file_name = file_name
 _center_position = center_position
 _zero_position = zero_position
 _convex_hull = None
 _convex_hull_vertices = None
 _convex_hull_lock = threading.Lock()
dict _attributes = {}
 _indices_byte_array = None

Detailed Description

Class to hold a list of verts and possibly how (and if) they are connected.

This class stores three numpy arrays that contain the data for a mesh. Vertices
are stored as a two-dimensional array of floats with the rows being individual
vertices and the three columns being the X, Y and Z components of the vertices.
Normals are stored in the same manner and kept in sync with the vertices. Indices
are stored as a two-dimensional array of integers with the rows being the individual
faces and the three columns being the indices that refer to the individual vertices.

attributes: a dict with {"value", "opengl_type", "opengl_name"} type in vector2f, vector3f, uniforms, ...

Constructor & Destructor Documentation

◆ __del__()

UM.Mesh.MeshData.MeshData.__del__ ( self)
Triggered when this file is deleted.

The file will then no longer be watched for changes.

Member Function Documentation

◆ _computeConvexHull()

None UM.Mesh.MeshData.MeshData._computeConvexHull ( self)
protected
Convex hull handling

◆ attributeNames()

List[str] UM.Mesh.MeshData.MeshData.attributeNames ( self)
Return attribute names in alphabetical order

The sorting assures that the order is always the same.

◆ getAttribute()

UM.Mesh.MeshData.MeshData.getAttribute ( self,
str key )
the return value is a dict with at least keys opengl_name, opengl_type, value

◆ getConvexHull()

Optional[scipy.spatial.ConvexHull] UM.Mesh.MeshData.MeshData.getConvexHull ( self)
Gets the Convex Hull of this mesh

:return: :type{scipy.spatial.ConvexHull}

◆ getConvexHullTransformedVertices()

Optional[numpy.ndarray] UM.Mesh.MeshData.MeshData.getConvexHullTransformedVertices ( self,
Matrix transformation )
Gets transformed convex hull points

:return: :type{numpy.ndarray} the vertices which describe the convex hull

◆ getConvexHullVertices()

Optional[numpy.ndarray] UM.Mesh.MeshData.MeshData.getConvexHullVertices ( self)
Gets the convex hull points

:return: :type{numpy.ndarray} the vertices which describe the convex hull

◆ getExtents()

Optional[AxisAlignedBox] UM.Mesh.MeshData.MeshData.getExtents ( self,
Optional[Matrix] matrix = None )
Get the extents of this mesh.

:param matrix: The transformation matrix from model to world coordinates.

◆ getFaceNodes()

Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray] UM.Mesh.MeshData.MeshData.getFaceNodes ( self,
int face_id )
Gets the node vectors of the supplied face.

:param face_id: :type{int} The index of the face (not the flattened indices).
:return: :type{Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]} Tuple of all three local vectors. 

◆ getFacePlane()

Tuple[numpy.ndarray, numpy.ndarray] UM.Mesh.MeshData.MeshData.getFacePlane ( self,
int face_id )
Gets the plane the supplied face lies in. The resultant plane is specified by a point and a normal.

:param face_id: :type{int} The index of the face (not the flattened indices).
:return: :type{Tuple[numpy.ndarray, numpy.ndarray]} A plane, the 1st vector is the center, the 2nd the normal.

◆ getIndices()

numpy.ndarray UM.Mesh.MeshData.MeshData.getIndices ( self)
Get the array of indices

:return: :type{numpy.ndarray}

◆ getIndicesAsByteArray()

Optional[bytes] UM.Mesh.MeshData.MeshData.getIndicesAsByteArray ( self)
Get all indices as a bytearray

:return: A bytearray object with 3 ints per face.

◆ getNormals()

numpy.ndarray UM.Mesh.MeshData.MeshData.getNormals ( self)
Return the list of vertex normals.

◆ getNormalsAsByteArray()

Optional[bytes] UM.Mesh.MeshData.MeshData.getNormalsAsByteArray ( self)
Get all normals of this mesh as a bytearray

:return: A bytearray object with 3 floats per normal.

◆ getTransformed()

"MeshData" UM.Mesh.MeshData.MeshData.getTransformed ( self,
Matrix transformation )
Transform the meshdata, center and zero position by given Matrix

:param transformation: 4x4 homogeneous transformation matrix

◆ getVertex()

UM.Mesh.MeshData.MeshData.getVertex ( self,
index )
Get a vertex by index

◆ getVertexCount()

int UM.Mesh.MeshData.MeshData.getVertexCount ( self)
Get the number of vertices

◆ getVertices()

numpy.ndarray UM.Mesh.MeshData.MeshData.getVertices ( self)
Get the array of vertices

◆ getVerticesAsByteArray()

Optional[bytes] UM.Mesh.MeshData.MeshData.getVerticesAsByteArray ( self)
Get all vertices of this mesh as a bytearray

:return: A bytearray object with 3 floats per vertex.

◆ hasIndices()

bool UM.Mesh.MeshData.MeshData.hasIndices ( self)
Return whether this mesh has indices.

◆ hasNormals()

bool UM.Mesh.MeshData.MeshData.hasNormals ( self)
Return whether this mesh has vertex normals.

◆ set()

"MeshData" UM.Mesh.MeshData.MeshData.set ( self,
vertices = Reuse,
normals = Reuse,
indices = Reuse,
colors = Reuse,
uvs = Reuse,
file_name = Reuse,
center_position = Reuse,
zero_position = Reuse,
attributes = Reuse )
Create a new MeshData with specified changes

:return: :type{MeshData}

The documentation for this class was generated from the following file:
  • UM/Mesh/MeshData.py