Structures¶
Contents
AbstractMesh¶
- class
Py3DViewer.structures.Abstractmesh.AbstractMesh[source]¶This class represents a generic mesh. It must be extended by a specific mesh class. It stores all the information shared among the different kind of supported meshes.
adj_edge2edge¶Return the adjacencies between edge and edge
adj_edge2poly¶Return the adjacencies between edge and poly
adj_edge2vtx¶Return the adjacencies between edge and vertex
adj_poly2edge¶Return the adjacencies between poly and edge
adj_poly2poly¶Return the adjacencies between poly and poly
adj_poly2vtx¶Return the adjacencies between poly and vertex
adj_vtx2edge¶Return the adjacencies between vertex and edge
adj_vtx2poly¶Return the adjacencies between vertex and poly
adj_vtx2vtx¶Return the adjacencies between vertex and vertex
bbox¶Return the axis aligned bounding box of the current mesh.
boundary()[source]¶Compute the boundary of the current mesh. It only returns the faces that are inside the clipping
center¶Return the center of the bounding box as an Array (n, 3).
clipping¶Return the clipping region of the current mesh.
edge_centroids¶Return the centroids of the current mesh edges as an Array (n,3).
edge_id(v0, v1)[source]¶Return the id of an edge given its 2 vertices. If the edge doesn’t exist or there are multiple matches then an array with all the matches is returned.
Parameters:
- v0 (int) – index of the first vertex
- v1 (int) – index of the second vertex
edge_length¶Return the length of the edges of the current mesh as an Array (n,1).
edge_valence¶Return the valence of each edge.
edges¶Return the edges of the current mesh as an Array (n, 2).
edges_sample_at(value)[source]¶Sample the edges at a given value.
Parameters: value (float) – The value used to sample the point. It must be a value in the range (0,1)
euler_characteristic¶Return the Euler characteristic of the current mesh.
filename¶Return the filename of the current mesh.
genus¶Return the genus of the current mesh.
get_metric(property_name, id_element)[source]¶Get a specific metric element from the dictionary of metrics ‘simplex_metrics’.
Parameters:
- property_name (string) – The name of the wanted metric
- id_element (int) – The index of a specific element of the metric
Returns: The specific metric element. The return type depends on the metric
Return type: object
mesh_centroid¶Return the centroid of the current mesh as an Array (,3).
mesh_is_surface¶Return True if the current mesh is a Trimesh or a Quadmesh.
mesh_is_volumetric¶Return True if the current mesh is a Hexmesh or a Tetmesh.
num_edges¶Return the number of edges of the current mesh.
num_polys¶Return the number of polys of the current mesh.
num_vertices¶Return the number of vertices of the current mesh.
pick_edge(point)[source]¶Return the nearest edge id given a point.
Parameters: point (Array (, 3) type=float) – Coordinates of the point
pick_poly(point)[source]¶Return the nearest poly id given a point.
Parameters: point (Array (, 3) type=float) – Coordinates of the point
pick_vertex(point)[source]¶Return the nearest vertex id given a point.
Parameters: point (Array (, 3) type=float) – Coordinates of the point
poly_centroids¶Return the centroids of the polys of the current mesh as an Array (n,3).
poly_id(verts)[source]¶Return the id of a poly given its vertices. If the poly doesn’t exist or there are multiple matches then an array with all the matches is returned.
Parameters: verts (Array (n, m) type=int) – indices of the vertices composing the poly
polys¶Return the edges of the current mesh as an Array (n, m).
scale¶Return the scale of the current mesh calculated as the distance between the minimum and maximum point of the bounding box.
set_clipping(min_x=None, max_x=None, min_y=None, max_y=None, min_z=None, max_z=None, flip_x=None, flip_y=None, flip_z=None)[source]¶clipping the mesh along x, y and z axes. It doesn’t affect the geometry of the mesh.
Parameters:
- min_x (float) – The minimum value of x
- max_x (float) – The maximum value of x
- min_y (float) – The minimum value of y
- max_y (float) – The maximum value of y
- min_z (float) – The minimum value of z
- max_z (float) – The maximum value of z
show(width=700, height=700, mesh_color=None, reactive=False)[source]¶Show the mesh within the current cell. It is possible to manipulate the mesh through the UI.
Parameters:
- UI (bool) – Show or not show the graphic user interface of the viewer
- width (int) – The width of the canvas
- height (int) – The height of the canvas
Returns: The viewer object
Return type:
transform_reflection(axis)[source]¶Reflect the mesh with respect a given axis or plane. It affects the mesh geometry.
Parameters: axis (string) – Reflection plane. It can be ‘x’, ‘y’, ‘z’ or xy’, ‘xz’, ‘yz’
transform_rotation(angle, axis)[source]¶Rotate the mesh by a given angle for a given axis. It affects the mesh geometry.
Parameters:
- angle (float) – Rotation angle, degrees.
- axis (string) – Rotation axis. It can be ‘x’, ‘y’ or ‘z’ or an array of size 3
transform_scale(t)[source]¶Scale the mesh by a given value for each axis. It affects the mesh geometry.
Parameters: t (Array (3x1) type=float) – Scale value for each axis.
transform_translation(t)[source]¶Translate the mesh by a given value for each axis. It affects the mesh geometry.
Parameters: t (Array (3x1) type=float) – Translation value for each axis.
vert_id(vert, strict=False)[source]¶Return the id of a vertex given its coordinates. If the vertex doesn’t exist or there are multiple matches then an array with all the matches is returned.
Parameters:
- vert (Array (,3) type=float) – The coordinates of the vertex
- strict (bool) – if False there is a tolerance of 1e-5
vert_valence¶Return the valence of each vertex.
TriMesh¶
- class
Py3DViewer.structures.Trimesh.Trimesh(filename=None, vertices=None, polys=None, labels=None, texture=None, mtl=None, smoothness=False)[source]¶This class represents a mesh composed of triangles. It is possible to load the mesh from a file or from raw geometry and topology data.
Parameters:
- filename (string) – The name of the file to load
- vertices (Array (Nx3) type=float) – The list of vertices of the mesh
- polys (Array (Nx3) type=int) – The list of polygons of the mesh
- labels (Array (Nx1) type=int) – The list of labels of the mesh (Optional)
boundary()[source]¶Compute the boundary of the current mesh. It only returns the faces that are inside the clipping
poly_add(new_poly)[source]¶Add a new face to the current mesh. It affects the mesh topology.
Parameters: new_poly (Array (Nx1) type=int) – Poly to add in the form [int, …, int]
poly_remove(poly_id)[source]¶Remove a poly from the current mesh. It affects the mesh topology.
Parameters: poly_id (int) – The index of the face to remove
polys_add(new_polys)[source]¶Add a list of new faces to the current mesh. It affects the mesh topology.
Parameters: new_polys (Array (NxM) type=int) – List of faces to add. Each face is in the form [int, …, int]
polys_remove(poly_ids)[source]¶Remove a list of polys from the current mesh. It affects the mesh topology.
Parameters: poly_ids (Array (Nx1 / 1xN) type=int) – List of polys to remove. Each face is in the form [int]
save_file(filename)[source]¶Save the current mesh in a file. Currently it supports the .obj extension.
Parameters: filename (string) – The name of the file
QuadMesh¶
- class
Py3DViewer.structures.Quadmesh.Quadmesh(filename=None, vertices=None, polys=None, labels=None, texture=None, mtl=None, smoothness=False)[source]¶This class represents a mesh composed of quadrilaterals. It is possible to load the mesh from a file or from raw geometry and topology data.
Parameters:
- filename (string) – The name of the file to load
- vertices (Array (Nx3) type=float) – The list of vertices of the mesh
- polys (Array (Nx4) type=int) – The list of faces of the mesh
- labels (Array (Nx1) type=int) – The list of labels of the mesh (Optional)
boundary()[source]¶Compute the boundary of the current mesh. It only returns the faces that are inside the clipping
poly_add(new_poly)[source]¶Add a new face to the current mesh. It affects the mesh topology.
Parameters: new_poly (Array (Nx1) type=int) – Poly to add in the form [int, …, int]
poly_remove(poly_id)[source]¶Remove a poly from the current mesh. It affects the mesh topology.
Parameters: poly_id (int) – The index of the face to remove
polys_add(new_polys)[source]¶Add a list of new faces to the current mesh. It affects the mesh topology.
Parameters: new_polys (Array (NxM) type=int) – List of faces to add. Each face is in the form [int, …, int]
polys_remove(poly_ids)[source]¶Remove a list of polys from the current mesh. It affects the mesh topology.
Parameters: poly_ids (Array (Nx1 / 1xN) type=int) – List of polys to remove. Each face is in the form [int]
save_file(filename)[source]¶Save the current mesh in a file. Currently it supports the .obj extension.
Parameters: filename (string) – The name of the file
TetMesh¶
- class
Py3DViewer.structures.Tetmesh.Tetmesh(filename=None, vertices=None, polys=None, labels=None)[source]¶This class represents a volumetric mesh composed of tetrahedra. It is possible to load the mesh from a file (.mesh) or from raw geometry and topology data.
Parameters:
- filename (string) – The name of the file to load
- vertices (Array (Nx3) type=float) – The list of vertices of the mesh
- polys (Array (Nx4) type=int) – The list of tetrahedra of the mesh
- labels (Array (Nx1) type=int) – The list of labels of the mesh (Optional)
boundary()[source]¶Compute the boundary of the current mesh. It only returns the faces that respect the clipping.
poly_add(new_poly)[source]¶Add a new face to the current mesh. It affects the mesh topology.
Parameters: new_poly (Array (Nx1) type=int) – Poly to add in the form [int, …, int]
poly_remove(poly_id)[source]¶Remove a poly from the current mesh. It affects the mesh topology.
Parameters: poly_id (int) – The index of the face to remove
polys_add(new_polys)[source]¶Add a list of new faces to the current mesh. It affects the mesh topology.
Parameters: new_polys (Array (NxM) type=int) – List of faces to add. Each face is in the form [int, …, int]
polys_remove(poly_ids)[source]¶Remove a list of polys from the current mesh. It affects the mesh topology.
Parameters: poly_ids (Array (Nx1 / 1xN) type=int) – List of polys to remove. Each face is in the form [int]
save_file(filename)[source]¶Save the current mesh in a file. Currently it supports the .mesh extension.
Parameters: filename (string) – The name of the file
HexMesh¶
- class
Py3DViewer.structures.Hexmesh.Hexmesh(filename=None, vertices=None, polys=None, labels=None)[source]¶This class represents a volumetric mesh composed of hexahedra. It is possible to load the mesh from a file (.mesh) or from raw geometry and topology data.
Parameters:
- filename (string) – The name of the file to load
- vertices (Array (Nx3) type=float) – The list of vertices of the mesh
- polys (Array (Nx8) type=int) – The list of hexahedra of the mesh
- labels (Array (Nx1) type=int) – The list of labels of the mesh (Optional)
boundary()[source]¶Compute the boundary of the current mesh. It only returns the faces that respect the cut and the flip conditions.
poly_add(new_poly)[source]¶Add a new face to the current mesh. It affects the mesh topology.
Parameters: new_poly (Array (Nx1) type=int) – Poly to add in the form [int, …, int]
poly_remove(poly_id)[source]¶Remove a poly from the current mesh. It affects the mesh topology.
Parameters: poly_id (int) – The index of the face to remove
polys_add(new_polys)[source]¶Add a list of new faces to the current mesh. It affects the mesh topology.
Parameters: new_polys (Array (NxM) type=int) – List of faces to add. Each face is in the form [int, …, int]
polys_remove(poly_ids)[source]¶Remove a list of polys from the current mesh. It affects the mesh topology.
Parameters: poly_ids (Array (Nx1 / 1xN) type=int) – List of polys to remove. Each face is in the form [int]
save_file(filename)[source]¶Save the current mesh in a file. Currently it supports the .mesh extension.
Parameters: filename (string) – The name of the file