Load mesh from a file. Args: filename: Input filename. File format is auto detected based on extension. drop_zero_dim (bool): If true, convert flat 3D mesh into 2D mesh. Returns: A :py:class:`Mesh` object representing the loaded mesh.
(filename, extension_hint=None, drop_zero_dim=False)
| 7 | from .save_svg import save_svg |
| 8 | |
| 9 | def load_mesh(filename, extension_hint=None, drop_zero_dim=False): |
| 10 | """ Load mesh from a file. |
| 11 | |
| 12 | Args: |
| 13 | filename: Input filename. File format is auto detected based on |
| 14 | extension. |
| 15 | drop_zero_dim (bool): If true, convert flat 3D mesh into 2D mesh. |
| 16 | |
| 17 | Returns: |
| 18 | A :py:class:`Mesh` object representing the loaded mesh. |
| 19 | """ |
| 20 | |
| 21 | ext = os.path.splitext(filename)[1] if extension_hint is None else extension_hint |
| 22 | |
| 23 | if ext == ".geogram": |
| 24 | return Mesh(PyMesh.load_geogram_mesh(filename)) |
| 25 | if not os.path.exists(filename): |
| 26 | raise IOError("File not found: {}".format(filename)) |
| 27 | factory = PyMesh.MeshFactory() |
| 28 | if extension_hint is None: |
| 29 | factory.load_file(filename) |
| 30 | else: |
| 31 | factory.load_file_with_hint(filename, extension_hint) |
| 32 | if drop_zero_dim: |
| 33 | factory.drop_zero_dim() |
| 34 | return Mesh(factory.create()) |
| 35 | |
| 36 | def deduce_face_type(faces, voxels): |
| 37 | if faces is None or faces.ndim == 1 or len(faces) == 0: |