diff --git a/plugins/PLYReader/plugin.json b/plugins/PLYReader/plugin.json deleted file mode 100644 index b295b08780..0000000000 --- a/plugins/PLYReader/plugin.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "PLY Reader", - "author": "Ultimaker B.V.", - "version": "1.0.0", - "description": "Provides support for reading PLY files.", - "api": "6.0.0" -} diff --git a/plugins/PLYReader/PLYReader.py b/plugins/TrimeshReader/TrimeshReader.py similarity index 68% rename from plugins/PLYReader/PLYReader.py rename to plugins/TrimeshReader/TrimeshReader.py index 6f3abfd59d..f59bc70362 100644 --- a/plugins/PLYReader/PLYReader.py +++ b/plugins/TrimeshReader/TrimeshReader.py @@ -5,19 +5,19 @@ import numpy # To create the mesh data. import os.path # To create the mesh name for the resulting mesh. -import trimesh # To load the PLY files into a Trimesh. +import trimesh # To load the files into a Trimesh. -from UM.Mesh.MeshData import MeshData, calculateNormalsFromIndexedVertices -from UM.Mesh.MeshReader import MeshReader -from UM.MimeTypeDatabase import MimeTypeDatabase, MimeType +from UM.Mesh.MeshData import MeshData, calculateNormalsFromIndexedVertices # To construct meshes from the Trimesh data. +from UM.Mesh.MeshReader import MeshReader # The plug-in type we're extending. +from UM.MimeTypeDatabase import MimeTypeDatabase, MimeType # To add file types that we can open. from cura.CuraApplication import CuraApplication -from cura.Scene.BuildPlateDecorator import BuildPlateDecorator -from cura.Scene.CuraSceneNode import CuraSceneNode -from cura.Scene.SliceableObjectDecorator import SliceableObjectDecorator +from cura.Scene.BuildPlateDecorator import BuildPlateDecorator # Added to the resulting scene node. +from cura.Scene.CuraSceneNode import CuraSceneNode # To create a node in the scene after reading the file. +from cura.Scene.SliceableObjectDecorator import SliceableObjectDecorator # Added to the resulting scene node. -## Class that leverages Trimesh to read PLY files (Stanford Triangle Format). -class PLYReader(MeshReader): +## Class that leverages Trimesh to import files. +class Trimesh(MeshReader): def __init__(self) -> None: super().__init__() @@ -30,10 +30,10 @@ class PLYReader(MeshReader): ) ) - ## Reads the PLY file. - # \param file_name The file path of the PLY file. This is assumed to be a - # PLY file; it's not checked again. - # \return A scene node that contains the PLY file's contents. + ## Reads a file using Trimesh. + # \param file_name The file path. This is assumed to be one of the file + # types that Trimesh can read. It will not be checked again. + # \return A scene node that contains the file's contents. def _read(self, file_name: str) -> CuraSceneNode: mesh = trimesh.load(file_name) mesh.merge_vertices() @@ -50,6 +50,11 @@ class PLYReader(MeshReader): new_node.addDecorator(SliceableObjectDecorator()) return new_node + ## Converts a Trimesh to Uranium's MeshData. + # \param tri_node A Trimesh containing the contents of a file that was + # just read. + # \return Mesh data from the Trimesh in a way that Uranium can understand + # it. def _toMeshData(self, tri_node: trimesh.base.Trimesh) -> MeshData: tri_faces = tri_node.faces tri_vertices = tri_node.vertices diff --git a/plugins/PLYReader/__init__.py b/plugins/TrimeshReader/__init__.py similarity index 82% rename from plugins/PLYReader/__init__.py rename to plugins/TrimeshReader/__init__.py index 05a6c8004d..f24448f15e 100644 --- a/plugins/PLYReader/__init__.py +++ b/plugins/TrimeshReader/__init__.py @@ -1,7 +1,7 @@ # Copyright (c) 2019 Ultimaker # Cura is released under the terms of the LGPLv3 or higher. -from . import PLYReader +from . import TrimeshReader from UM.i18n import i18nCatalog i18n_catalog = i18nCatalog("uranium") @@ -18,4 +18,4 @@ def getMetaData(): } def register(app): - return {"mesh_reader": PLYReader.PLYReader()} + return {"mesh_reader": TrimeshReader.TrimeshReader()} diff --git a/plugins/TrimeshReader/plugin.json b/plugins/TrimeshReader/plugin.json new file mode 100644 index 0000000000..61c66aa5e8 --- /dev/null +++ b/plugins/TrimeshReader/plugin.json @@ -0,0 +1,7 @@ +{ + "name": "Trimesh Reader", + "author": "Ultimaker B.V.", + "version": "1.0.0", + "description": "Provides support for reading model files.", + "api": "6.0.0" +}