Edition and Manual Creation
Alongside loading and saving various file formats, mouette
allows to create datastructures from scratch. This can be done using the RawMeshData
class. This class possesses all possible data containers available in mouette but no connectivity or functionnality: it is purely a storage class. The user can append its data to the corresponding containers:
data = M.mesh.RawMeshData()
# use += instead of append to add several elements
data.vertices += [[0,0,0],[1,2,3],[1,-1,0],[0,1,-2]]
data.edges.append((0,2))
data.faces.append((0,1,2))
data.faces.append((0,1,3))
When all operations are done, the RawMeshData
object can be passed as an argument to the constructor of a PointCloud
, Polyline
, SurfaceMesh
or VolumeMesh
object. This will sanitize the data under the hood and generate eventual corner data:
# Create the SurfaceMesh object.
# This sanitizes the data under the hood and generates edges and face corners
surface = M.mesh.SurfaceMesh(data)
Warning
Do not work directly append elements to containers of a SurfaceMesh
or VolumeMesh
, as this can create connectivity issues. PointCloud
and Polyline
are usually safe but using RawMeshData
in all cases is the recommanded approach.
RawMeshData
A base container class to store all the data relative to a mesh. Serves an intermediate between io parsers or manual inputs and instantiated (and typed) mesh classes.
dimensionality: int
property
Dimensionality of the manifold represented by the data.
-
If only vertices -> 0
-
If vertices and edges (embedded graph) -> 1
-
If faces (surface manifold) -> 2
-
If cells (volume manifold) -> 3
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
0,1,2 or 3 |
id_cellcorners
property
Shortcut for range(len(self.cell_corners))
id_cells
property
Shortcut for range(len(self.cells))
id_edges
property
Shortcut for range(len(self.edges))
id_facecorners
property
Shortcut for range(len(self.face_corners))
id_faces
property
Shortcut for range(len(self.faces))
id_vertices
property
Shortcut for range(len(self.vertices))
prepare()
Prepares the data to have the correct format. This method is called by the constructors of data structures.
First generates explicitely the set of faces from cells and the set of edges from faces.
This behavior can be controlled via the config.complete_faces_from_cells
and
the config.complete_edges_from_faces
global config variables.
Then, treatments are applied on each DataContainer:
-
On vertices : casts 3D vectors to
mouette.Vec
-
On edges : sorts edge tuples to satisfy edge convention (smallest index first)
-
On faces : nothing
-
On face corners : generates the face_corners container if empty
-
On cells : nothing
-
On cell corners : generates the cell_corners container if empty