Utils

IO

Py3DViewer.utils.IO.read_mesh(filename)[source]

Imports the data from the given .mesh file

Parameters:filename (string) – The name of the .mesh file
Returns:The mesh vertices, the mesh simplices and the mesh labels
Return type:(Array, Array, Array)
Py3DViewer.utils.IO.read_mtl(filename)[source]
Py3DViewer.utils.IO.read_obj(filename)[source]

Imports the data from the given .obj file

Parameters:filename (string) – The name of the .obj file
Returns:The mesh vertices, the mesh simplices and the mesh labels
Return type:(Array, Array, Array)
Py3DViewer.utils.IO.read_off(filename)[source]
Py3DViewer.utils.IO.read_skeleton(filename)[source]

Imports the data from the given .skel file

Parameters:filename (string) – The name of the .skel file
Returns:The skeleton joints, the joints radius and the skeleton bones
Return type:(Array, Array, Array)
Py3DViewer.utils.IO.save_mesh(mesh, filename)[source]

Writes the data from the given mesh object to a .mesh file

Parameters :

mesh (Tetmesh / Hexmesh): The mesh to serialize to the file filename (string): The name of the .mesh file
Py3DViewer.utils.IO.save_obj(mesh, filename)[source]

Writes the data from the given mesh object to a .obj file

Parameters :

mesh (Trimesh / Quadmesh): The mesh to serialize to the file filename (string): the name of the .obj file
Py3DViewer.utils.IO.save_off(mesh, filename)[source]

Metrics

Py3DViewer.utils.metrics.hex_scaled_jacobian(vertices, hexes)[source]

Compute the scaled jacobian of the given hexahedra.

Parameters:
  • vertices (Array (Nx3) type=float) – The list of vertices of the hexahedra
  • hexes (Array (Nx8) type=int) – The list of hexahedra
Returns:

The first element is a tuple representing the range where the metric is defined and the second element is the array of the scaled jacobian of the given hexahedra

Return type:

((float, float), Array)

Py3DViewer.utils.metrics.hex_volume(vertices, hexes)[source]

Compute the volume of the given tetrahedra.

Parameters:
  • vertices (Array (Nx3) type=float) – The list of vertices of the hexahedra
  • hexes (Array (Nx8) type=int) – The list of hexahedra
Returns:

The first element is a tuple representing the range where the metric is defined and the second element is the array of the volume of the given hexahedra

Return type:

((float, float), Array)

Py3DViewer.utils.metrics.quad_area(vertices, quads)[source]

Compute the area of the given quadrilaterals.

Parameters:
  • vertices (Array (Nx3) type=float) – The list of vertices of the quadrilaterals
  • quads (Array (Nx4) type=int) – The list of quadrilaterals
Returns:

The first element is a tuple representing the range where the metric is defined and the second element is the array of the area of the given quadrilaterals

Return type:

((float, float), Array)

Py3DViewer.utils.metrics.quad_aspect_ratio(vertices, quads)[source]

Compute the aspect ratio of the given quadrilaterals.

Parameters:
  • vertices (Array (Nx3) type=float) – The list of vertices of the quadrilaterals
  • quads (Array (Nx4) type=int) – The list of quadrilaterals
Returns:

The first element is a tuple representing the range where the metric is defined and the second element is the array of the aspect ratio of the given quadrilaterals

Return type:

((float, float), Array)

Py3DViewer.utils.metrics.tet_scaled_jacobian(vertices, tets)[source]

Compute the scaled jacobian of the given tetrahedra.

Parameters:
  • vertices (Array (Nx3) type=float) – The list of vertices of the tetrahedra
  • tets (Array (Nx4) type=int) – The list of tetrahedra
Returns:

The first element is a tuple representing the range where the metric is defined and the second element is the array of the scaled jacobian of the given tetrahedra

Return type:

((float, float), Array)

Py3DViewer.utils.metrics.tet_volume(vertices, tets)[source]

Compute the volume of the given tetrahedra.

Parameters:
  • vertices (Array (Nx3) type=float) – The list of vertices of the tetrahedra
  • tets (Array (Nx4) type=int) – The list of tetrahedra
Returns:

The first element is a tuple representing the range where the metric is defined and the second element is the array of the volume of the given tetrahedra

Return type:

((float, float), Array)

Py3DViewer.utils.metrics.triangle_area(vertices, triangles)[source]

Compute the area of the given triangles.

Parameters:
  • vertices (Array (Nx3) type=float) – The list of vertices of the triangles
  • triangles (Array (Nx3) type=int) – The list of triangles
Returns:

The first element is a tuple representing the range where the metric is defined and the second element is the array of the area of the given triangles

Return type:

((float, float), Array)

Py3DViewer.utils.metrics.triangle_aspect_ratio(vertices, triangles)[source]

Compute the aspect ratio of the given triangles.

Parameters:
  • vertices (Array (Nx3) type=float) – The list of vertices of the triangles
  • triangles (Array (Nx3) type=int) – The list of triangles
Returns:

The first element is a tuple representing the range where the metric is defined and the second element is the array of the aspect ration of the given triangles

Return type:

((float, float), Array)