From 9b5dc2991bc8bb86435653ad14d4ce462fea89b8 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 20 Jun 2024 18:27:07 -0400 Subject: [PATCH 01/58] Import version for clearer file writing --- coxeter/shapes/polyhedron.py | 1 + 1 file changed, 1 insertion(+) diff --git a/coxeter/shapes/polyhedron.py b/coxeter/shapes/polyhedron.py index 6e817aad..94b2cb8b 100644 --- a/coxeter/shapes/polyhedron.py +++ b/coxeter/shapes/polyhedron.py @@ -10,6 +10,7 @@ import rowan from scipy.sparse.csgraph import connected_components +from .... import __version__ from ..extern.polytri import polytri from .base_classes import Shape3D from .convex_polygon import ConvexPolygon, _is_convex From 741cf5eba61ac677199750148da38360f22d58e5 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 20 Jun 2024 18:27:44 -0400 Subject: [PATCH 02/58] Add OBJ export method --- coxeter/shapes/polyhedron.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/coxeter/shapes/polyhedron.py b/coxeter/shapes/polyhedron.py index 94b2cb8b..2c666259 100644 --- a/coxeter/shapes/polyhedron.py +++ b/coxeter/shapes/polyhedron.py @@ -1021,3 +1021,31 @@ def to_hoomd(self): self.centroid = old_centroid return hoomd_dict + + def to_obj(self, filename): + """Save Polyhedron to a wavefront OBJ file. + + Args: + filename (str, pathlib.Path, or os.PathLike): + The name or path of the output file, including the extension. + + Note: + In OBJ files, vertices in face definitions are indexed from one. + + Raises + ------ + OSError: If open() encounters a problem. + """ + with open(filename, "w") as file: + file.write(f"# wavefront obj file written by Coxeter " + f"version {__version__}\n" + f"# {self.__class__.__name__}\n\n") + + for v in self.vertices: + file.write(f"v {' '.join([str(i) for i in v])}\n") + + file.write("\n") + + for f in self.faces: + file.write(f"f {' '.join([str(i+1) for i in f])}\n") + From d690f4b9940ee5f1a53b0aeb9b70777570298cdf Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 20 Jun 2024 18:27:59 -0400 Subject: [PATCH 03/58] Add OFF export method --- coxeter/shapes/polyhedron.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/coxeter/shapes/polyhedron.py b/coxeter/shapes/polyhedron.py index 2c666259..54e5b11a 100644 --- a/coxeter/shapes/polyhedron.py +++ b/coxeter/shapes/polyhedron.py @@ -1049,3 +1049,28 @@ def to_obj(self, filename): for f in self.faces: file.write(f"f {' '.join([str(i+1) for i in f])}\n") + def to_off(self, filename): + """Save Polyhedron to an Object File Format (OFF) file. + + Args: + filename (str, pathlib.Path, or os.PathLike): + The name or path of the output file, including the extension. + + Raises + ------ + OSError: If open() encounters a problem. + """ + with open(filename, "w") as file: + file.write(f"OFF\n# OFF file written by Coxeter " + f"version {__version__}\n" + f"# {self.__class__.__name__}\n") + + file.write(f"{len(self.vertices)} f{len(self.faces)} " + f"{len(self.edges)}\n") + + for v in self.vertices: + file.write(f"{' '.join([str(i) for i in v])}\n") + + for f in self.faces: + file.write(f"{len(f)} {' '.join([str(i) for i in f])}\n") + From b422c92970ca806fc72d4608664a004f639306e8 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 20 Jun 2024 18:28:21 -0400 Subject: [PATCH 04/58] Add STL export method --- coxeter/shapes/polyhedron.py | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/coxeter/shapes/polyhedron.py b/coxeter/shapes/polyhedron.py index 54e5b11a..337af9ae 100644 --- a/coxeter/shapes/polyhedron.py +++ b/coxeter/shapes/polyhedron.py @@ -1074,3 +1074,44 @@ def to_off(self, filename): for f in self.faces: file.write(f"{len(f)} {' '.join([str(i) for i in f])}\n") + def to_stl(self, filename): + """Save Polyhedron to a stereolithography (STL) file. + + Args: + filename (str, pathlib.Path, or os.PathLike): + The name or path of the output file, including the extension. + + Note: + The output file is ASCII-encoded. + + Raises + ------ + OSError: If open() encounters a problem. + """ + with open(filename, "w") as file: + # Shift vertices so all coordinates are positive + mins = np.amin(a=self.vertices, axis=0) + for i, m in enumerate(mins): + if m < 0: + self.centroid[i] -= m + + # Write data + vs = self.vertices + file.write(f"solid {self.__class__.__name__}\n") + + for f in self.faces: + # Decompose face into triangles + # ref: https://stackoverflow.com/a/66586936/15426433 + triangles = [[vs[f[0]], vs[b], vs[c]] for b, c in zip(f[1:], f[2:])] + + for t in triangles: + n = np.cross(t[1]-t[0], t[2]-t[1]) # order? + + file.write(f"facet normal {n[0]} {n[1]} {n[2]}\n" + f"\touter loop\n") + for point in t: + file.write(f"\t\tvertex {point[0]} {point[1]} {point[2]}\n") + + file.write("\tendloop\nendfacet\n") + + file.write(f"endsolid {self.__class__.__name__}") From e63ff8d7dee9cff87457a6ae88cb54ef0a74c58f Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 20 Jun 2024 18:28:36 -0400 Subject: [PATCH 05/58] Add PLY export method --- coxeter/shapes/polyhedron.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/coxeter/shapes/polyhedron.py b/coxeter/shapes/polyhedron.py index 337af9ae..93dfc0c5 100644 --- a/coxeter/shapes/polyhedron.py +++ b/coxeter/shapes/polyhedron.py @@ -1115,3 +1115,35 @@ def to_stl(self, filename): file.write("\tendloop\nendfacet\n") file.write(f"endsolid {self.__class__.__name__}") + + def to_ply(self, filename): + """Save Polyhedron to a Polygon File Format (PLY) file. + + Args: + filename (str, pathlib.Path, or os.PathLike): + The name or path of the output file, including the extension. + + Note: + The output file is ASCII-encoded. + + Raises + ------ + OSError: If open() encounters a problem. + """ + with open(filename, "w") as file: + file.write(f"ply\nformat ascii 1.0\n" + f"comment PLY file written by Coxeter " + f"version {__version__}\n" + f"comment {self.__class__.__name__}\n" + f"element vertex {len(self.vertices)}\n" + f"property float x\nproperty float y\nproperty float z\n" + f"element face {len(self.faces)}\n" + f"property list uchar uint vertex_indices\n" + f"end_header\n") + + for v in self.vertices: + file.write(f"{' '.join([str(i) for i in v])}\n") + + for f in self.faces: + file.write(f"{len(f)} {' '.join([str(int(i)) for i in f])}\n") + From 08ce8b59b078f596348d01ac491634cafcc71bb3 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 20 Jun 2024 18:28:50 -0400 Subject: [PATCH 06/58] Add X3D export method --- coxeter/shapes/polyhedron.py | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/coxeter/shapes/polyhedron.py b/coxeter/shapes/polyhedron.py index 93dfc0c5..5b3d60dc 100644 --- a/coxeter/shapes/polyhedron.py +++ b/coxeter/shapes/polyhedron.py @@ -1147,3 +1147,54 @@ def to_ply(self, filename): for f in self.faces: file.write(f"{len(f)} {' '.join([str(int(i)) for i in f])}\n") + def to_x3d(self, filename): + """Save Polyhedron to an Extensible 3D (X3D) file. + + Args: + filename (str, pathlib.Path, or os.PathLike): + The name or path of the output file, including the extension. + + Raises + ------ + OSError: If open() encounters a problem. + """ + # TODO: translate self so that its centroid is at the origin + + # Parent elements + root = ET.Element( + "x3d", + attrib={"profile": "Interchange", + "version": "4.0", + "xmlns:xsd": "http://www.w3.org/2001/XMLSchema-instance", + "xsd:noNamespaceSchemaLocation": "http://www.web3d.org/specifications/x3d-4.0.xsd"}) + x3d_scene = ET.SubElement(root, "Scene") + x3d_self = ET.SubElement(x3d_scene, "self", + attrib={"DEF": f"{self.__class__.__name__}"}) + + x3d_appearance = ET.SubElement(x3d_self, "Appearance") + x3d_material = ET.SubElement(x3d_appearance, "Material", + attrib={"diffuseColor": "#6495ED"}) + + # Geometry data + coordinate_indices = list(range(sum([len(f) for f in self.faces]))) + prev_index = 0 + for f in self.faces: + coordinate_indices.insert(len(f) + prev_index, -1) + prev_index += len(f) + 1 + + coordinate_points = [ + v for f in self.faces for i in f for v in self.vertices[i] + ] + + x3d_indexedfaceset = ET.SubElement( + x3d_self, + "IndexedFaceSet", + attrib={"coordIndex": " ".join([str(i) for i in coordinate_indices])}) + x3d_coordinate = ET.SubElement( + x3d_indexedfaceset, + "Coordinate", + attrib={"point": " ".join([str(i) for i in coordinate_points])}) + + # Write to file + ET.ElementTree(root).write(filename, encoding="UTF-8") + From fe8bc7ea2fa3804e0afbe30a3f0559c460df8b09 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 20 Jun 2024 18:29:04 -0400 Subject: [PATCH 07/58] Add VTK export method --- coxeter/shapes/polyhedron.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/coxeter/shapes/polyhedron.py b/coxeter/shapes/polyhedron.py index 5b3d60dc..1d086d53 100644 --- a/coxeter/shapes/polyhedron.py +++ b/coxeter/shapes/polyhedron.py @@ -1198,3 +1198,38 @@ def to_x3d(self, filename): # Write to file ET.ElementTree(root).write(filename, encoding="UTF-8") + + def to_vtk(self, filename): + """Save Polyhedron to a legacy VTK file. + + Args: + filename (str, pathlib.Path, or os.PathLike): + The name or path of the output file, including the extension. + + Raises + ------ + OSError: If open() encounters a problem. + """ + content = "" + # Title and Header + content += (f"# vtk DataFile Version 3.0\n" + f"{self.__class__.__name__} created by " + f"Coxeter version {__version__}\n" + f"ASCII\n") + + # Geometry + content += (f"DATASET POLYDATA\n" + f"POINTS {len(self.vertices)} float\n") + for v in self.vertices: + content += f"{v[0]} {v[1]} {v[2]}\n" + + num_points = len(self.faces) + num_connections = sum([len(f) for f in self.faces]) + content += f"POLYGONS {num_points} {num_points + num_connections}\n" + for f in self.faces: + content += f"{len(f)} {' '.join([str(i) for i in f])}\n" + + # Write file + with open(filename, "wb") as file: + file.write(content.encode("ascii")) + From 642f867e1e4a281bfc8b022e296fc6119d5c50d0 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 20 Jun 2024 18:29:19 -0400 Subject: [PATCH 08/58] Add HTML export method --- coxeter/shapes/polyhedron.py | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/coxeter/shapes/polyhedron.py b/coxeter/shapes/polyhedron.py index 1d086d53..e226b76e 100644 --- a/coxeter/shapes/polyhedron.py +++ b/coxeter/shapes/polyhedron.py @@ -1233,3 +1233,47 @@ def to_vtk(self, filename): with open(filename, "wb") as file: file.write(content.encode("ascii")) + def to_html(self, filename): + """Save Polyhedron to an HTML file. + + This method calls self.to_x3d to create a temporary X3D file, then + parses that X3D file and creates an HTML file in its place. + + Args: + filename (str, pathlib.Path, or os.PathLike): + The name or path of the output file, including the extension. + + Raises + ------ + OSError: If open() encounters a problem. + """ + # Create, parse, and remove x3d file + self.to_x3d(self, filename) + x3d = ET.parse(filename) + os.remove(filename) + + # HTML Head + html = ET.Element("html") + head = ET.SubElement(html, "head") + script = ET.SubElement( + head, + "script", + attrib={"type": "text/javascript", + "src": "http://x3dom.org/release/x3dom.js"} + ) + script.text = " " # ensures the tag is not self-closing + link = ET.SubElement( + head, + "link", + attrib={"rel": "stylesheet", + "type": "text/css", + "href": "http://x3dom.org/release/x3dom.css"} + ) + + # HTML body + body = ET.SubElement(html, "body") + body.append(x3d.getroot()) + + # Write file + ET.ElementTree(html).write(filename, encoding="UTF-8") + \ No newline at end of file From 8c0ceb7e0ab633378121d89de8cae08b175956a5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 20 Jun 2024 22:39:20 +0000 Subject: [PATCH 09/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- coxeter/shapes/polyhedron.py | 154 +++++++++++++++++++---------------- 1 file changed, 84 insertions(+), 70 deletions(-) diff --git a/coxeter/shapes/polyhedron.py b/coxeter/shapes/polyhedron.py index e226b76e..8f385163 100644 --- a/coxeter/shapes/polyhedron.py +++ b/coxeter/shapes/polyhedron.py @@ -1024,7 +1024,7 @@ def to_hoomd(self): def to_obj(self, filename): """Save Polyhedron to a wavefront OBJ file. - + Args: filename (str, pathlib.Path, or os.PathLike): The name or path of the output file, including the extension. @@ -1037,10 +1037,12 @@ def to_obj(self, filename): OSError: If open() encounters a problem. """ with open(filename, "w") as file: - file.write(f"# wavefront obj file written by Coxeter " - f"version {__version__}\n" - f"# {self.__class__.__name__}\n\n") - + file.write( + f"# wavefront obj file written by Coxeter " + f"version {__version__}\n" + f"# {self.__class__.__name__}\n\n" + ) + for v in self.vertices: file.write(f"v {' '.join([str(i) for i in v])}\n") @@ -1051,7 +1053,7 @@ def to_obj(self, filename): def to_off(self, filename): """Save Polyhedron to an Object File Format (OFF) file. - + Args: filename (str, pathlib.Path, or os.PathLike): The name or path of the output file, including the extension. @@ -1061,12 +1063,15 @@ def to_off(self, filename): OSError: If open() encounters a problem. """ with open(filename, "w") as file: - file.write(f"OFF\n# OFF file written by Coxeter " - f"version {__version__}\n" - f"# {self.__class__.__name__}\n") + file.write( + f"OFF\n# OFF file written by Coxeter " + f"version {__version__}\n" + f"# {self.__class__.__name__}\n" + ) - file.write(f"{len(self.vertices)} f{len(self.faces)} " - f"{len(self.edges)}\n") + file.write( + f"{len(self.vertices)} f{len(self.faces)} " f"{len(self.edges)}\n" + ) for v in self.vertices: file.write(f"{' '.join([str(i) for i in v])}\n") @@ -1076,7 +1081,7 @@ def to_off(self, filename): def to_stl(self, filename): """Save Polyhedron to a stereolithography (STL) file. - + Args: filename (str, pathlib.Path, or os.PathLike): The name or path of the output file, including the extension. @@ -1094,7 +1099,7 @@ def to_stl(self, filename): for i, m in enumerate(mins): if m < 0: self.centroid[i] -= m - + # Write data vs = self.vertices file.write(f"solid {self.__class__.__name__}\n") @@ -1103,53 +1108,54 @@ def to_stl(self, filename): # Decompose face into triangles # ref: https://stackoverflow.com/a/66586936/15426433 triangles = [[vs[f[0]], vs[b], vs[c]] for b, c in zip(f[1:], f[2:])] - + for t in triangles: - n = np.cross(t[1]-t[0], t[2]-t[1]) # order? + n = np.cross(t[1] - t[0], t[2] - t[1]) # order? - file.write(f"facet normal {n[0]} {n[1]} {n[2]}\n" - f"\touter loop\n") + file.write(f"facet normal {n[0]} {n[1]} {n[2]}\n" f"\touter loop\n") for point in t: file.write(f"\t\tvertex {point[0]} {point[1]} {point[2]}\n") - + file.write("\tendloop\nendfacet\n") - + file.write(f"endsolid {self.__class__.__name__}") def to_ply(self, filename): """Save Polyhedron to a Polygon File Format (PLY) file. - + Args: filename (str, pathlib.Path, or os.PathLike): The name or path of the output file, including the extension. Note: The output file is ASCII-encoded. - + Raises ------ OSError: If open() encounters a problem. """ with open(filename, "w") as file: - file.write(f"ply\nformat ascii 1.0\n" - f"comment PLY file written by Coxeter " - f"version {__version__}\n" - f"comment {self.__class__.__name__}\n" - f"element vertex {len(self.vertices)}\n" - f"property float x\nproperty float y\nproperty float z\n" - f"element face {len(self.faces)}\n" - f"property list uchar uint vertex_indices\n" - f"end_header\n") - + file.write( + f"ply\nformat ascii 1.0\n" + f"comment PLY file written by Coxeter " + f"version {__version__}\n" + f"comment {self.__class__.__name__}\n" + f"element vertex {len(self.vertices)}\n" + f"property float x\nproperty float y\nproperty float z\n" + f"element face {len(self.faces)}\n" + f"property list uchar uint vertex_indices\n" + f"end_header\n" + ) + for v in self.vertices: file.write(f"{' '.join([str(i) for i in v])}\n") - + for f in self.faces: file.write(f"{len(f)} {' '.join([str(int(i)) for i in f])}\n") def to_x3d(self, filename): """Save Polyhedron to an Extensible 3D (X3D) file. - + Args: filename (str, pathlib.Path, or os.PathLike): The name or path of the output file, including the extension. @@ -1162,18 +1168,23 @@ def to_x3d(self, filename): # Parent elements root = ET.Element( - "x3d", - attrib={"profile": "Interchange", - "version": "4.0", - "xmlns:xsd": "http://www.w3.org/2001/XMLSchema-instance", - "xsd:noNamespaceSchemaLocation": "http://www.web3d.org/specifications/x3d-4.0.xsd"}) + "x3d", + attrib={ + "profile": "Interchange", + "version": "4.0", + "xmlns:xsd": "http://www.w3.org/2001/XMLSchema-instance", + "xsd:noNamespaceSchemaLocation": "http://www.web3d.org/specifications/x3d-4.0.xsd", + }, + ) x3d_scene = ET.SubElement(root, "Scene") - x3d_self = ET.SubElement(x3d_scene, "self", - attrib={"DEF": f"{self.__class__.__name__}"}) + x3d_self = ET.SubElement( + x3d_scene, "self", attrib={"DEF": f"{self.__class__.__name__}"} + ) x3d_appearance = ET.SubElement(x3d_self, "Appearance") - x3d_material = ET.SubElement(x3d_appearance, "Material", - attrib={"diffuseColor": "#6495ED"}) + x3d_material = ET.SubElement( + x3d_appearance, "Material", attrib={"diffuseColor": "#6495ED"} + ) # Geometry data coordinate_indices = list(range(sum([len(f) for f in self.faces]))) @@ -1182,26 +1193,25 @@ def to_x3d(self, filename): coordinate_indices.insert(len(f) + prev_index, -1) prev_index += len(f) + 1 - coordinate_points = [ - v for f in self.faces for i in f for v in self.vertices[i] - ] + coordinate_points = [v for f in self.faces for i in f for v in self.vertices[i]] x3d_indexedfaceset = ET.SubElement( - x3d_self, + x3d_self, "IndexedFaceSet", - attrib={"coordIndex": " ".join([str(i) for i in coordinate_indices])}) + attrib={"coordIndex": " ".join([str(i) for i in coordinate_indices])}, + ) x3d_coordinate = ET.SubElement( - x3d_indexedfaceset, + x3d_indexedfaceset, "Coordinate", - attrib={"point": " ".join([str(i) for i in coordinate_points])}) + attrib={"point": " ".join([str(i) for i in coordinate_points])}, + ) # Write to file ET.ElementTree(root).write(filename, encoding="UTF-8") - def to_vtk(self, filename): """Save Polyhedron to a legacy VTK file. - + Args: filename (str, pathlib.Path, or os.PathLike): The name or path of the output file, including the extension. @@ -1212,14 +1222,15 @@ def to_vtk(self, filename): """ content = "" # Title and Header - content += (f"# vtk DataFile Version 3.0\n" - f"{self.__class__.__name__} created by " - f"Coxeter version {__version__}\n" - f"ASCII\n") - + content += ( + f"# vtk DataFile Version 3.0\n" + f"{self.__class__.__name__} created by " + f"Coxeter version {__version__}\n" + f"ASCII\n" + ) + # Geometry - content += (f"DATASET POLYDATA\n" - f"POINTS {len(self.vertices)} float\n") + content += f"DATASET POLYDATA\n" f"POINTS {len(self.vertices)} float\n" for v in self.vertices: content += f"{v[0]} {v[1]} {v[2]}\n" @@ -1235,7 +1246,7 @@ def to_vtk(self, filename): def to_html(self, filename): """Save Polyhedron to an HTML file. - + This method calls self.to_x3d to create a temporary X3D file, then parses that X3D file and creates an HTML file in its place. @@ -1256,18 +1267,22 @@ def to_html(self, filename): html = ET.Element("html") head = ET.SubElement(html, "head") script = ET.SubElement( - head, - "script", - attrib={"type": "text/javascript", - "src": "http://x3dom.org/release/x3dom.js"} + head, + "script", + attrib={ + "type": "text/javascript", + "src": "http://x3dom.org/release/x3dom.js", + }, ) - script.text = " " # ensures the tag is not self-closing + script.text = " " # ensures the tag is not self-closing link = ET.SubElement( - head, - "link", - attrib={"rel": "stylesheet", - "type": "text/css", - "href": "http://x3dom.org/release/x3dom.css"} + head, + "link", + attrib={ + "rel": "stylesheet", + "type": "text/css", + "href": "http://x3dom.org/release/x3dom.css", + }, ) # HTML body @@ -1276,4 +1291,3 @@ def to_html(self, filename): # Write file ET.ElementTree(html).write(filename, encoding="UTF-8") - \ No newline at end of file From dc50cca3ae594e97c79055396b0823de1b8065aa Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Fri, 21 Jun 2024 16:18:51 -0400 Subject: [PATCH 10/58] Move export methods to new file --- coxeter/__init__.py | 1 + coxeter/io.py | 258 +++++++++++++++++++++++++++++++++ coxeter/shapes/polyhedron.py | 271 ----------------------------------- 3 files changed, 259 insertions(+), 271 deletions(-) create mode 100644 coxeter/io.py diff --git a/coxeter/__init__.py b/coxeter/__init__.py index b4d82e49..fbc4e3a1 100644 --- a/coxeter/__init__.py +++ b/coxeter/__init__.py @@ -18,6 +18,7 @@ from . import families, shapes from .shape_getters import from_gsd_type_shapes +from io import * __all__ = ["families", "shapes", "from_gsd_type_shapes"] diff --git a/coxeter/io.py b/coxeter/io.py new file mode 100644 index 00000000..790a62fe --- /dev/null +++ b/coxeter/io.py @@ -0,0 +1,258 @@ +from coxeter import __version__ +import xml.etree.ElementTree as ET +import os +import numpy as np + +def to_obj(shape, filename): + """Save Polyhedron to a wavefront OBJ file. + + Args: + filename (str, pathlib.Path, or os.PathLike): + The name or path of the output file, including the extension. + + Note: + In OBJ files, vertices in face definitions are indexed from one. + + Raises + ------ + OSError: If open() encounters a problem. + """ + with open(filename, "w") as file: + file.write(f"# wavefront obj file written by Coxeter " + f"version {__version__}\n" + f"# {shape.__class__.__name__}\n\n") + + for v in shape.vertices: + file.write(f"v {' '.join([str(i) for i in v])}\n") + + file.write("\n") + + for f in shape.faces: + file.write(f"f {' '.join([str(i+1) for i in f])}\n") + +def to_off(shape, filename): + """Save Polyhedron to an Object File Format (OFF) file. + + Args: + filename (str, pathlib.Path, or os.PathLike): + The name or path of the output file, including the extension. + + Raises + ------ + OSError: If open() encounters a problem. + """ + with open(filename, "w") as file: + file.write(f"OFF\n# OFF file written by Coxeter " + f"version {__version__}\n" + f"# {shape.__class__.__name__}\n") + + file.write(f"{len(shape.vertices)} f{len(shape.faces)} " + f"{len(shape.edges)}\n") + + for v in shape.vertices: + file.write(f"{' '.join([str(i) for i in v])}\n") + + for f in shape.faces: + file.write(f"{len(f)} {' '.join([str(i) for i in f])}\n") + +def to_stl(shape, filename): + """Save Polyhedron to a stereolithography (STL) file. + + Args: + filename (str, pathlib.Path, or os.PathLike): + The name or path of the output file, including the extension. + + Note: + The output file is ASCII-encoded. + + Raises + ------ + OSError: If open() encounters a problem. + """ + with open(filename, "w") as file: + # Shift vertices so all coordinates are positive + mins = np.amin(a=shape.vertices, axis=0) + for i, m in enumerate(mins): + if m < 0: + shape.centroid[i] -= m + + # Write data + vs = shape.vertices + file.write(f"solid {shape.__class__.__name__}\n") + + for f in shape.faces: + # Decompose face into triangles + # ref: https://stackoverflow.com/a/66586936/15426433 + triangles = [[vs[f[0]], vs[b], vs[c]] for b, c in zip(f[1:], f[2:])] + + for t in triangles: + n = np.cross(t[1]-t[0], t[2]-t[1]) # order? + + file.write(f"facet normal {n[0]} {n[1]} {n[2]}\n" + f"\touter loop\n") + for point in t: + file.write(f"\t\tvertex {point[0]} {point[1]} {point[2]}\n") + + file.write("\tendloop\nendfacet\n") + + file.write(f"endsolid {shape.__class__.__name__}") + +def to_ply(shape, filename): + """Save Polyhedron to a Polygon File Format (PLY) file. + + Args: + filename (str, pathlib.Path, or os.PathLike): + The name or path of the output file, including the extension. + + Note: + The output file is ASCII-encoded. + + Raises + ------ + OSError: If open() encounters a problem. + """ + with open(filename, "w") as file: + file.write(f"ply\nformat ascii 1.0\n" + f"comment PLY file written by Coxeter " + f"version {__version__}\n" + f"comment {shape.__class__.__name__}\n" + f"element vertex {len(shape.vertices)}\n" + f"property float x\nproperty float y\nproperty float z\n" + f"element face {len(shape.faces)}\n" + f"property list uchar uint vertex_indices\n" + f"end_header\n") + + for v in shape.vertices: + file.write(f"{' '.join([str(i) for i in v])}\n") + + for f in shape.faces: + file.write(f"{len(f)} {' '.join([str(int(i)) for i in f])}\n") + +def to_x3d(shape, filename): + """Save Polyhedron to an Extensible 3D (X3D) file. + + Args: + filename (str, pathlib.Path, or os.PathLike): + The name or path of the output file, including the extension. + + Raises + ------ + OSError: If open() encounters a problem. + """ + # TODO: translate shape so that its centroid is at the origin + + # Parent elements + root = ET.Element( + "x3d", + attrib={"profile": "Interchange", + "version": "4.0", + "xmlns:xsd": "http://www.w3.org/2001/XMLSchema-instance", + "xsd:noNamespaceSchemaLocation": "http://www.web3d.org/specifications/x3d-4.0.xsd"}) + x3d_scene = ET.SubElement(root, "Scene") + x3d_shape = ET.SubElement(x3d_scene, "shape", + attrib={"DEF": f"{shape.__class__.__name__}"}) + + x3d_appearance = ET.SubElement(x3d_shape, "Appearance") + x3d_material = ET.SubElement(x3d_appearance, "Material", + attrib={"diffuseColor": "#6495ED"}) + + # Geometry data + coordinate_indices = list(range(sum([len(f) for f in shape.faces]))) + prev_index = 0 + for f in shape.faces: + coordinate_indices.insert(len(f) + prev_index, -1) + prev_index += len(f) + 1 + + coordinate_points = [ + v for f in shape.faces for i in f for v in shape.vertices[i] + ] + + x3d_indexedfaceset = ET.SubElement( + x3d_shape, + "IndexedFaceSet", + attrib={"coordIndex": " ".join([str(i) for i in coordinate_indices])}) + x3d_coordinate = ET.SubElement( + x3d_indexedfaceset, + "Coordinate", + attrib={"point": " ".join([str(i) for i in coordinate_points])}) + + # Write to file + ET.ElementTree(root).write(filename, encoding="UTF-8") + +def to_vtk(shape, filename): + """Save Polyhedron to a legacy VTK file. + + Args: + filename (str, pathlib.Path, or os.PathLike): + The name or path of the output file, including the extension. + + Raises + ------ + OSError: If open() encounters a problem. + """ + content = "" + # Title and Header + content += (f"# vtk DataFile Version 3.0\n" + f"{shape.__class__.__name__} created by " + f"Coxeter version {__version__}\n" + f"ASCII\n") + + # Geometry + content += (f"DATASET POLYDATA\n" + f"POINTS {len(shape.vertices)} float\n") + for v in shape.vertices: + content += f"{v[0]} {v[1]} {v[2]}\n" + + num_points = len(shape.faces) + num_connections = sum([len(f) for f in shape.faces]) + content += f"POLYGONS {num_points} {num_points + num_connections}\n" + for f in shape.faces: + content += f"{len(f)} {' '.join([str(i) for i in f])}\n" + + # Write file + with open(filename, "wb") as file: + file.write(content.encode("ascii")) + +def to_html(shape, filename): + """Save Polyhedron to an HTML file. + + This method calls shape.to_x3d to create a temporary X3D file, then + parses that X3D file and creates an HTML file in its place. + + Args: + filename (str, pathlib.Path, or os.PathLike): + The name or path of the output file, including the extension. + + Raises + ------ + OSError: If open() encounters a problem. + """ + # Create, parse, and remove x3d file + to_x3d(shape, filename) + x3d = ET.parse(filename) + os.remove(filename) + + # HTML Head + html = ET.Element("html") + head = ET.SubElement(html, "head") + script = ET.SubElement( + head, + "script", + attrib={"type": "text/javascript", + "src": "http://x3dom.org/release/x3dom.js"} + ) + script.text = " " # ensures the tag is not shape-closing + link = ET.SubElement( + head, + "link", + attrib={"rel": "stylesheet", + "type": "text/css", + "href": "http://x3dom.org/release/x3dom.css"} + ) + + # HTML body + body = ET.SubElement(html, "body") + body.append(x3d.getroot()) + + # Write file + ET.ElementTree(html).write(filename, encoding="UTF-8") diff --git a/coxeter/shapes/polyhedron.py b/coxeter/shapes/polyhedron.py index 8f385163..6e817aad 100644 --- a/coxeter/shapes/polyhedron.py +++ b/coxeter/shapes/polyhedron.py @@ -10,7 +10,6 @@ import rowan from scipy.sparse.csgraph import connected_components -from .... import __version__ from ..extern.polytri import polytri from .base_classes import Shape3D from .convex_polygon import ConvexPolygon, _is_convex @@ -1021,273 +1020,3 @@ def to_hoomd(self): self.centroid = old_centroid return hoomd_dict - - def to_obj(self, filename): - """Save Polyhedron to a wavefront OBJ file. - - Args: - filename (str, pathlib.Path, or os.PathLike): - The name or path of the output file, including the extension. - - Note: - In OBJ files, vertices in face definitions are indexed from one. - - Raises - ------ - OSError: If open() encounters a problem. - """ - with open(filename, "w") as file: - file.write( - f"# wavefront obj file written by Coxeter " - f"version {__version__}\n" - f"# {self.__class__.__name__}\n\n" - ) - - for v in self.vertices: - file.write(f"v {' '.join([str(i) for i in v])}\n") - - file.write("\n") - - for f in self.faces: - file.write(f"f {' '.join([str(i+1) for i in f])}\n") - - def to_off(self, filename): - """Save Polyhedron to an Object File Format (OFF) file. - - Args: - filename (str, pathlib.Path, or os.PathLike): - The name or path of the output file, including the extension. - - Raises - ------ - OSError: If open() encounters a problem. - """ - with open(filename, "w") as file: - file.write( - f"OFF\n# OFF file written by Coxeter " - f"version {__version__}\n" - f"# {self.__class__.__name__}\n" - ) - - file.write( - f"{len(self.vertices)} f{len(self.faces)} " f"{len(self.edges)}\n" - ) - - for v in self.vertices: - file.write(f"{' '.join([str(i) for i in v])}\n") - - for f in self.faces: - file.write(f"{len(f)} {' '.join([str(i) for i in f])}\n") - - def to_stl(self, filename): - """Save Polyhedron to a stereolithography (STL) file. - - Args: - filename (str, pathlib.Path, or os.PathLike): - The name or path of the output file, including the extension. - - Note: - The output file is ASCII-encoded. - - Raises - ------ - OSError: If open() encounters a problem. - """ - with open(filename, "w") as file: - # Shift vertices so all coordinates are positive - mins = np.amin(a=self.vertices, axis=0) - for i, m in enumerate(mins): - if m < 0: - self.centroid[i] -= m - - # Write data - vs = self.vertices - file.write(f"solid {self.__class__.__name__}\n") - - for f in self.faces: - # Decompose face into triangles - # ref: https://stackoverflow.com/a/66586936/15426433 - triangles = [[vs[f[0]], vs[b], vs[c]] for b, c in zip(f[1:], f[2:])] - - for t in triangles: - n = np.cross(t[1] - t[0], t[2] - t[1]) # order? - - file.write(f"facet normal {n[0]} {n[1]} {n[2]}\n" f"\touter loop\n") - for point in t: - file.write(f"\t\tvertex {point[0]} {point[1]} {point[2]}\n") - - file.write("\tendloop\nendfacet\n") - - file.write(f"endsolid {self.__class__.__name__}") - - def to_ply(self, filename): - """Save Polyhedron to a Polygon File Format (PLY) file. - - Args: - filename (str, pathlib.Path, or os.PathLike): - The name or path of the output file, including the extension. - - Note: - The output file is ASCII-encoded. - - Raises - ------ - OSError: If open() encounters a problem. - """ - with open(filename, "w") as file: - file.write( - f"ply\nformat ascii 1.0\n" - f"comment PLY file written by Coxeter " - f"version {__version__}\n" - f"comment {self.__class__.__name__}\n" - f"element vertex {len(self.vertices)}\n" - f"property float x\nproperty float y\nproperty float z\n" - f"element face {len(self.faces)}\n" - f"property list uchar uint vertex_indices\n" - f"end_header\n" - ) - - for v in self.vertices: - file.write(f"{' '.join([str(i) for i in v])}\n") - - for f in self.faces: - file.write(f"{len(f)} {' '.join([str(int(i)) for i in f])}\n") - - def to_x3d(self, filename): - """Save Polyhedron to an Extensible 3D (X3D) file. - - Args: - filename (str, pathlib.Path, or os.PathLike): - The name or path of the output file, including the extension. - - Raises - ------ - OSError: If open() encounters a problem. - """ - # TODO: translate self so that its centroid is at the origin - - # Parent elements - root = ET.Element( - "x3d", - attrib={ - "profile": "Interchange", - "version": "4.0", - "xmlns:xsd": "http://www.w3.org/2001/XMLSchema-instance", - "xsd:noNamespaceSchemaLocation": "http://www.web3d.org/specifications/x3d-4.0.xsd", - }, - ) - x3d_scene = ET.SubElement(root, "Scene") - x3d_self = ET.SubElement( - x3d_scene, "self", attrib={"DEF": f"{self.__class__.__name__}"} - ) - - x3d_appearance = ET.SubElement(x3d_self, "Appearance") - x3d_material = ET.SubElement( - x3d_appearance, "Material", attrib={"diffuseColor": "#6495ED"} - ) - - # Geometry data - coordinate_indices = list(range(sum([len(f) for f in self.faces]))) - prev_index = 0 - for f in self.faces: - coordinate_indices.insert(len(f) + prev_index, -1) - prev_index += len(f) + 1 - - coordinate_points = [v for f in self.faces for i in f for v in self.vertices[i]] - - x3d_indexedfaceset = ET.SubElement( - x3d_self, - "IndexedFaceSet", - attrib={"coordIndex": " ".join([str(i) for i in coordinate_indices])}, - ) - x3d_coordinate = ET.SubElement( - x3d_indexedfaceset, - "Coordinate", - attrib={"point": " ".join([str(i) for i in coordinate_points])}, - ) - - # Write to file - ET.ElementTree(root).write(filename, encoding="UTF-8") - - def to_vtk(self, filename): - """Save Polyhedron to a legacy VTK file. - - Args: - filename (str, pathlib.Path, or os.PathLike): - The name or path of the output file, including the extension. - - Raises - ------ - OSError: If open() encounters a problem. - """ - content = "" - # Title and Header - content += ( - f"# vtk DataFile Version 3.0\n" - f"{self.__class__.__name__} created by " - f"Coxeter version {__version__}\n" - f"ASCII\n" - ) - - # Geometry - content += f"DATASET POLYDATA\n" f"POINTS {len(self.vertices)} float\n" - for v in self.vertices: - content += f"{v[0]} {v[1]} {v[2]}\n" - - num_points = len(self.faces) - num_connections = sum([len(f) for f in self.faces]) - content += f"POLYGONS {num_points} {num_points + num_connections}\n" - for f in self.faces: - content += f"{len(f)} {' '.join([str(i) for i in f])}\n" - - # Write file - with open(filename, "wb") as file: - file.write(content.encode("ascii")) - - def to_html(self, filename): - """Save Polyhedron to an HTML file. - - This method calls self.to_x3d to create a temporary X3D file, then - parses that X3D file and creates an HTML file in its place. - - Args: - filename (str, pathlib.Path, or os.PathLike): - The name or path of the output file, including the extension. - - Raises - ------ - OSError: If open() encounters a problem. - """ - # Create, parse, and remove x3d file - self.to_x3d(self, filename) - x3d = ET.parse(filename) - os.remove(filename) - - # HTML Head - html = ET.Element("html") - head = ET.SubElement(html, "head") - script = ET.SubElement( - head, - "script", - attrib={ - "type": "text/javascript", - "src": "http://x3dom.org/release/x3dom.js", - }, - ) - script.text = " " # ensures the tag is not self-closing - link = ET.SubElement( - head, - "link", - attrib={ - "rel": "stylesheet", - "type": "text/css", - "href": "http://x3dom.org/release/x3dom.css", - }, - ) - - # HTML body - body = ET.SubElement(html, "body") - body.append(x3d.getroot()) - - # Write file - ET.ElementTree(html).write(filename, encoding="UTF-8") From 366544d6b3a11f111593984910513443885707b2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 21 Jun 2024 20:18:59 +0000 Subject: [PATCH 11/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- coxeter/__init__.py | 3 +- coxeter/io.py | 162 +++++++++++++++++++++++++------------------- 2 files changed, 94 insertions(+), 71 deletions(-) diff --git a/coxeter/__init__.py b/coxeter/__init__.py index fbc4e3a1..18c88338 100644 --- a/coxeter/__init__.py +++ b/coxeter/__init__.py @@ -16,9 +16,10 @@ applications such as inertia tensors. """ +from io import * + from . import families, shapes from .shape_getters import from_gsd_type_shapes -from io import * __all__ = ["families", "shapes", "from_gsd_type_shapes"] diff --git a/coxeter/io.py b/coxeter/io.py index 790a62fe..197756dc 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -1,11 +1,14 @@ -from coxeter import __version__ -import xml.etree.ElementTree as ET import os +import xml.etree.ElementTree as ET + import numpy as np +from coxeter import __version__ + + def to_obj(shape, filename): """Save Polyhedron to a wavefront OBJ file. - + Args: filename (str, pathlib.Path, or os.PathLike): The name or path of the output file, including the extension. @@ -18,10 +21,12 @@ def to_obj(shape, filename): OSError: If open() encounters a problem. """ with open(filename, "w") as file: - file.write(f"# wavefront obj file written by Coxeter " - f"version {__version__}\n" - f"# {shape.__class__.__name__}\n\n") - + file.write( + f"# wavefront obj file written by Coxeter " + f"version {__version__}\n" + f"# {shape.__class__.__name__}\n\n" + ) + for v in shape.vertices: file.write(f"v {' '.join([str(i) for i in v])}\n") @@ -30,9 +35,10 @@ def to_obj(shape, filename): for f in shape.faces: file.write(f"f {' '.join([str(i+1) for i in f])}\n") + def to_off(shape, filename): """Save Polyhedron to an Object File Format (OFF) file. - + Args: filename (str, pathlib.Path, or os.PathLike): The name or path of the output file, including the extension. @@ -42,12 +48,15 @@ def to_off(shape, filename): OSError: If open() encounters a problem. """ with open(filename, "w") as file: - file.write(f"OFF\n# OFF file written by Coxeter " - f"version {__version__}\n" - f"# {shape.__class__.__name__}\n") + file.write( + f"OFF\n# OFF file written by Coxeter " + f"version {__version__}\n" + f"# {shape.__class__.__name__}\n" + ) - file.write(f"{len(shape.vertices)} f{len(shape.faces)} " - f"{len(shape.edges)}\n") + file.write( + f"{len(shape.vertices)} f{len(shape.faces)} " f"{len(shape.edges)}\n" + ) for v in shape.vertices: file.write(f"{' '.join([str(i) for i in v])}\n") @@ -55,9 +64,10 @@ def to_off(shape, filename): for f in shape.faces: file.write(f"{len(f)} {' '.join([str(i) for i in f])}\n") + def to_stl(shape, filename): """Save Polyhedron to a stereolithography (STL) file. - + Args: filename (str, pathlib.Path, or os.PathLike): The name or path of the output file, including the extension. @@ -75,7 +85,7 @@ def to_stl(shape, filename): for i, m in enumerate(mins): if m < 0: shape.centroid[i] -= m - + # Write data vs = shape.vertices file.write(f"solid {shape.__class__.__name__}\n") @@ -84,53 +94,56 @@ def to_stl(shape, filename): # Decompose face into triangles # ref: https://stackoverflow.com/a/66586936/15426433 triangles = [[vs[f[0]], vs[b], vs[c]] for b, c in zip(f[1:], f[2:])] - + for t in triangles: - n = np.cross(t[1]-t[0], t[2]-t[1]) # order? + n = np.cross(t[1] - t[0], t[2] - t[1]) # order? - file.write(f"facet normal {n[0]} {n[1]} {n[2]}\n" - f"\touter loop\n") + file.write(f"facet normal {n[0]} {n[1]} {n[2]}\n" f"\touter loop\n") for point in t: file.write(f"\t\tvertex {point[0]} {point[1]} {point[2]}\n") - + file.write("\tendloop\nendfacet\n") - + file.write(f"endsolid {shape.__class__.__name__}") + def to_ply(shape, filename): """Save Polyhedron to a Polygon File Format (PLY) file. - + Args: filename (str, pathlib.Path, or os.PathLike): The name or path of the output file, including the extension. Note: The output file is ASCII-encoded. - + Raises ------ OSError: If open() encounters a problem. """ with open(filename, "w") as file: - file.write(f"ply\nformat ascii 1.0\n" - f"comment PLY file written by Coxeter " - f"version {__version__}\n" - f"comment {shape.__class__.__name__}\n" - f"element vertex {len(shape.vertices)}\n" - f"property float x\nproperty float y\nproperty float z\n" - f"element face {len(shape.faces)}\n" - f"property list uchar uint vertex_indices\n" - f"end_header\n") - + file.write( + f"ply\nformat ascii 1.0\n" + f"comment PLY file written by Coxeter " + f"version {__version__}\n" + f"comment {shape.__class__.__name__}\n" + f"element vertex {len(shape.vertices)}\n" + f"property float x\nproperty float y\nproperty float z\n" + f"element face {len(shape.faces)}\n" + f"property list uchar uint vertex_indices\n" + f"end_header\n" + ) + for v in shape.vertices: file.write(f"{' '.join([str(i) for i in v])}\n") - + for f in shape.faces: file.write(f"{len(f)} {' '.join([str(int(i)) for i in f])}\n") + def to_x3d(shape, filename): """Save Polyhedron to an Extensible 3D (X3D) file. - + Args: filename (str, pathlib.Path, or os.PathLike): The name or path of the output file, including the extension. @@ -143,18 +156,23 @@ def to_x3d(shape, filename): # Parent elements root = ET.Element( - "x3d", - attrib={"profile": "Interchange", - "version": "4.0", - "xmlns:xsd": "http://www.w3.org/2001/XMLSchema-instance", - "xsd:noNamespaceSchemaLocation": "http://www.web3d.org/specifications/x3d-4.0.xsd"}) + "x3d", + attrib={ + "profile": "Interchange", + "version": "4.0", + "xmlns:xsd": "http://www.w3.org/2001/XMLSchema-instance", + "xsd:noNamespaceSchemaLocation": "http://www.web3d.org/specifications/x3d-4.0.xsd", + }, + ) x3d_scene = ET.SubElement(root, "Scene") - x3d_shape = ET.SubElement(x3d_scene, "shape", - attrib={"DEF": f"{shape.__class__.__name__}"}) + x3d_shape = ET.SubElement( + x3d_scene, "shape", attrib={"DEF": f"{shape.__class__.__name__}"} + ) x3d_appearance = ET.SubElement(x3d_shape, "Appearance") - x3d_material = ET.SubElement(x3d_appearance, "Material", - attrib={"diffuseColor": "#6495ED"}) + x3d_material = ET.SubElement( + x3d_appearance, "Material", attrib={"diffuseColor": "#6495ED"} + ) # Geometry data coordinate_indices = list(range(sum([len(f) for f in shape.faces]))) @@ -163,25 +181,26 @@ def to_x3d(shape, filename): coordinate_indices.insert(len(f) + prev_index, -1) prev_index += len(f) + 1 - coordinate_points = [ - v for f in shape.faces for i in f for v in shape.vertices[i] - ] + coordinate_points = [v for f in shape.faces for i in f for v in shape.vertices[i]] x3d_indexedfaceset = ET.SubElement( - x3d_shape, + x3d_shape, "IndexedFaceSet", - attrib={"coordIndex": " ".join([str(i) for i in coordinate_indices])}) + attrib={"coordIndex": " ".join([str(i) for i in coordinate_indices])}, + ) x3d_coordinate = ET.SubElement( - x3d_indexedfaceset, + x3d_indexedfaceset, "Coordinate", - attrib={"point": " ".join([str(i) for i in coordinate_points])}) + attrib={"point": " ".join([str(i) for i in coordinate_points])}, + ) # Write to file ET.ElementTree(root).write(filename, encoding="UTF-8") + def to_vtk(shape, filename): """Save Polyhedron to a legacy VTK file. - + Args: filename (str, pathlib.Path, or os.PathLike): The name or path of the output file, including the extension. @@ -192,14 +211,15 @@ def to_vtk(shape, filename): """ content = "" # Title and Header - content += (f"# vtk DataFile Version 3.0\n" - f"{shape.__class__.__name__} created by " - f"Coxeter version {__version__}\n" - f"ASCII\n") - + content += ( + f"# vtk DataFile Version 3.0\n" + f"{shape.__class__.__name__} created by " + f"Coxeter version {__version__}\n" + f"ASCII\n" + ) + # Geometry - content += (f"DATASET POLYDATA\n" - f"POINTS {len(shape.vertices)} float\n") + content += f"DATASET POLYDATA\n" f"POINTS {len(shape.vertices)} float\n" for v in shape.vertices: content += f"{v[0]} {v[1]} {v[2]}\n" @@ -213,9 +233,10 @@ def to_vtk(shape, filename): with open(filename, "wb") as file: file.write(content.encode("ascii")) + def to_html(shape, filename): """Save Polyhedron to an HTML file. - + This method calls shape.to_x3d to create a temporary X3D file, then parses that X3D file and creates an HTML file in its place. @@ -236,18 +257,19 @@ def to_html(shape, filename): html = ET.Element("html") head = ET.SubElement(html, "head") script = ET.SubElement( - head, - "script", - attrib={"type": "text/javascript", - "src": "http://x3dom.org/release/x3dom.js"} + head, + "script", + attrib={"type": "text/javascript", "src": "http://x3dom.org/release/x3dom.js"}, ) - script.text = " " # ensures the tag is not shape-closing + script.text = " " # ensures the tag is not shape-closing link = ET.SubElement( - head, - "link", - attrib={"rel": "stylesheet", - "type": "text/css", - "href": "http://x3dom.org/release/x3dom.css"} + head, + "link", + attrib={ + "rel": "stylesheet", + "type": "text/css", + "href": "http://x3dom.org/release/x3dom.css", + }, ) # HTML body From 8877438a429c78cf5c2de6d5d40d2947c90d30bd Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Fri, 21 Jun 2024 16:28:31 -0400 Subject: [PATCH 12/58] Revise docstrings --- coxeter/io.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/coxeter/io.py b/coxeter/io.py index 197756dc..cfec8d51 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -7,7 +7,7 @@ def to_obj(shape, filename): - """Save Polyhedron to a wavefront OBJ file. + """Save shape to a wavefront OBJ file. Args: filename (str, pathlib.Path, or os.PathLike): @@ -37,7 +37,7 @@ def to_obj(shape, filename): def to_off(shape, filename): - """Save Polyhedron to an Object File Format (OFF) file. + """Save shape to an Object File Format (OFF) file. Args: filename (str, pathlib.Path, or os.PathLike): @@ -66,7 +66,7 @@ def to_off(shape, filename): def to_stl(shape, filename): - """Save Polyhedron to a stereolithography (STL) file. + """Save shape to a stereolithography (STL) file. Args: filename (str, pathlib.Path, or os.PathLike): @@ -108,7 +108,7 @@ def to_stl(shape, filename): def to_ply(shape, filename): - """Save Polyhedron to a Polygon File Format (PLY) file. + """Save shape to a Polygon File Format (PLY) file. Args: filename (str, pathlib.Path, or os.PathLike): @@ -142,7 +142,7 @@ def to_ply(shape, filename): def to_x3d(shape, filename): - """Save Polyhedron to an Extensible 3D (X3D) file. + """Save shape to an Extensible 3D (X3D) file. Args: filename (str, pathlib.Path, or os.PathLike): @@ -199,7 +199,7 @@ def to_x3d(shape, filename): def to_vtk(shape, filename): - """Save Polyhedron to a legacy VTK file. + """Save shape to a legacy VTK file. Args: filename (str, pathlib.Path, or os.PathLike): @@ -235,7 +235,7 @@ def to_vtk(shape, filename): def to_html(shape, filename): - """Save Polyhedron to an HTML file. + """Save shape to an HTML file. This method calls shape.to_x3d to create a temporary X3D file, then parses that X3D file and creates an HTML file in its place. From d86ff7ce18d2c8b0ee0d736cd7e8ad4f59502fe2 Mon Sep 17 00:00:00 2001 From: Jen Bradley <55467578+janbridley@users.noreply.github.com> Date: Thu, 27 Jun 2024 09:48:12 -0400 Subject: [PATCH 13/58] Fix F841 --- coxeter/io.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coxeter/io.py b/coxeter/io.py index cfec8d51..19722326 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -169,8 +169,8 @@ def to_x3d(shape, filename): x3d_scene, "shape", attrib={"DEF": f"{shape.__class__.__name__}"} ) - x3d_appearance = ET.SubElement(x3d_shape, "Appearance") - x3d_material = ET.SubElement( + _ = ET.SubElement(x3d_shape, "Appearance") + _ = ET.SubElement( x3d_appearance, "Material", attrib={"diffuseColor": "#6495ED"} ) From 7d4206c933fc1a8c139bb32b6addd75cf202be73 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 27 Jun 2024 13:48:44 +0000 Subject: [PATCH 14/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- coxeter/io.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/coxeter/io.py b/coxeter/io.py index 19722326..5b47f79b 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -170,9 +170,7 @@ def to_x3d(shape, filename): ) _ = ET.SubElement(x3d_shape, "Appearance") - _ = ET.SubElement( - x3d_appearance, "Material", attrib={"diffuseColor": "#6495ED"} - ) + _ = ET.SubElement(x3d_appearance, "Material", attrib={"diffuseColor": "#6495ED"}) # Geometry data coordinate_indices = list(range(sum([len(f) for f in shape.faces]))) From d9aff11b46cee22d2fc5dcaeb231068032e0fd9d Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 27 Jun 2024 13:47:52 -0400 Subject: [PATCH 15/58] Change acronym import to full name --- coxeter/io.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/coxeter/io.py b/coxeter/io.py index 5b47f79b..227a05d7 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -1,5 +1,5 @@ import os -import xml.etree.ElementTree as ET +from xml.etree import ElementTree import numpy as np @@ -124,8 +124,7 @@ def to_ply(shape, filename): with open(filename, "w") as file: file.write( f"ply\nformat ascii 1.0\n" - f"comment PLY file written by Coxeter " - f"version {__version__}\n" + f"comment PLY file written by Coxeter version {__version__}\n" f"comment {shape.__class__.__name__}\n" f"element vertex {len(shape.vertices)}\n" f"property float x\nproperty float y\nproperty float z\n" @@ -155,7 +154,7 @@ def to_x3d(shape, filename): # TODO: translate shape so that its centroid is at the origin # Parent elements - root = ET.Element( + root = ElementTree.Element( "x3d", attrib={ "profile": "Interchange", @@ -164,13 +163,15 @@ def to_x3d(shape, filename): "xsd:noNamespaceSchemaLocation": "http://www.web3d.org/specifications/x3d-4.0.xsd", }, ) - x3d_scene = ET.SubElement(root, "Scene") - x3d_shape = ET.SubElement( + x3d_scene = ElementTree.SubElement(root, "Scene") + x3d_shape = ElementTree.SubElement( x3d_scene, "shape", attrib={"DEF": f"{shape.__class__.__name__}"} ) - _ = ET.SubElement(x3d_shape, "Appearance") - _ = ET.SubElement(x3d_appearance, "Material", attrib={"diffuseColor": "#6495ED"}) + x3d_appearance = ElementTree.SubElement(x3d_shape, "Appearance") + x3d_material = ElementTree.SubElement( + x3d_appearance, "Material", attrib={"diffuseColor": "#6495ED"} + ) # Geometry data coordinate_indices = list(range(sum([len(f) for f in shape.faces]))) @@ -181,19 +182,19 @@ def to_x3d(shape, filename): coordinate_points = [v for f in shape.faces for i in f for v in shape.vertices[i]] - x3d_indexedfaceset = ET.SubElement( + x3d_indexedfaceset = ElementTree.SubElement( x3d_shape, "IndexedFaceSet", attrib={"coordIndex": " ".join([str(i) for i in coordinate_indices])}, ) - x3d_coordinate = ET.SubElement( + x3d_coordinate = ElementTree.SubElement( x3d_indexedfaceset, "Coordinate", attrib={"point": " ".join([str(i) for i in coordinate_points])}, ) # Write to file - ET.ElementTree(root).write(filename, encoding="UTF-8") + ElementTree.ElementTree(root).write(filename, encoding="UTF-8") def to_vtk(shape, filename): @@ -248,19 +249,19 @@ def to_html(shape, filename): """ # Create, parse, and remove x3d file to_x3d(shape, filename) - x3d = ET.parse(filename) + x3d = ElementTree.parse(filename) os.remove(filename) # HTML Head - html = ET.Element("html") - head = ET.SubElement(html, "head") - script = ET.SubElement( + html = ElementTree.Element("html") + head = ElementTree.SubElement(html, "head") + script = ElementTree.SubElement( head, "script", attrib={"type": "text/javascript", "src": "http://x3dom.org/release/x3dom.js"}, ) script.text = " " # ensures the tag is not shape-closing - link = ET.SubElement( + link = ElementTree.SubElement( head, "link", attrib={ @@ -271,8 +272,8 @@ def to_html(shape, filename): ) # HTML body - body = ET.SubElement(html, "body") + body = ElementTree.SubElement(html, "body") body.append(x3d.getroot()) # Write file - ET.ElementTree(html).write(filename, encoding="UTF-8") + ElementTree.ElementTree(html).write(filename, encoding="UTF-8") From 38537291acd3e4f5ea764c5160837d41a42784ba Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 27 Jun 2024 13:48:09 -0400 Subject: [PATCH 16/58] Fix star import --- coxeter/__init__.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/coxeter/__init__.py b/coxeter/__init__.py index 18c88338..4e738a13 100644 --- a/coxeter/__init__.py +++ b/coxeter/__init__.py @@ -16,11 +16,9 @@ applications such as inertia tensors. """ -from io import * - -from . import families, shapes +from . import families, shapes, io from .shape_getters import from_gsd_type_shapes -__all__ = ["families", "shapes", "from_gsd_type_shapes"] +__all__ = ["families", "shapes", "from_gsd_type_shapes", "io"] __version__ = "0.8.0" From 0ab6a6f1acc4bffaa717fba9e0fd908c719ee2af Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 27 Jun 2024 13:58:30 -0400 Subject: [PATCH 17/58] Fix assignments of unused variables --- coxeter/io.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/coxeter/io.py b/coxeter/io.py index 227a05d7..f017cecc 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -169,7 +169,7 @@ def to_x3d(shape, filename): ) x3d_appearance = ElementTree.SubElement(x3d_shape, "Appearance") - x3d_material = ElementTree.SubElement( + ElementTree.SubElement( x3d_appearance, "Material", attrib={"diffuseColor": "#6495ED"} ) @@ -187,7 +187,7 @@ def to_x3d(shape, filename): "IndexedFaceSet", attrib={"coordIndex": " ".join([str(i) for i in coordinate_indices])}, ) - x3d_coordinate = ElementTree.SubElement( + ElementTree.SubElement( x3d_indexedfaceset, "Coordinate", attrib={"point": " ".join([str(i) for i in coordinate_points])}, @@ -261,7 +261,7 @@ def to_html(shape, filename): attrib={"type": "text/javascript", "src": "http://x3dom.org/release/x3dom.js"}, ) script.text = " " # ensures the tag is not shape-closing - link = ElementTree.SubElement( + ElementTree.SubElement( head, "link", attrib={ From 401703d1baa71784bbf92823dcbb4e03401533bb Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 27 Jun 2024 15:22:32 -0400 Subject: [PATCH 18/58] Add doctype declaration to HTML output --- coxeter/io.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/coxeter/io.py b/coxeter/io.py index f017cecc..84160eec 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -276,4 +276,6 @@ def to_html(shape, filename): body.append(x3d.getroot()) # Write file - ElementTree.ElementTree(html).write(filename, encoding="UTF-8") + with open(filename, "w") as file: + file.write("") + file.write(ElementTree.tostring(html, encoding="unicode")) From a971c24da906d1337c63d4c1e1006fda3c8db566 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 27 Jun 2024 15:22:54 -0400 Subject: [PATCH 19/58] Fix XML and HTML namespacing --- coxeter/io.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coxeter/io.py b/coxeter/io.py index 84160eec..440439d3 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -160,7 +160,7 @@ def to_x3d(shape, filename): "profile": "Interchange", "version": "4.0", "xmlns:xsd": "http://www.w3.org/2001/XMLSchema-instance", - "xsd:noNamespaceSchemaLocation": "http://www.web3d.org/specifications/x3d-4.0.xsd", + "xsd:schemaLocation": "http://www.web3d.org/specifications/x3d-4.0.xsd", }, ) x3d_scene = ElementTree.SubElement(root, "Scene") @@ -253,7 +253,7 @@ def to_html(shape, filename): os.remove(filename) # HTML Head - html = ElementTree.Element("html") + html = ElementTree.Element("html", attrib={"xmlns": "http://www.w3.org/1999/xhtml"}) head = ElementTree.SubElement(html, "head") script = ElementTree.SubElement( head, From 308b7bb1b27712347c3525ec0d5df995d457c928 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 27 Jun 2024 15:29:15 -0400 Subject: [PATCH 20/58] Fix linting issue --- coxeter/io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coxeter/io.py b/coxeter/io.py index 440439d3..675f6b6b 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -253,7 +253,7 @@ def to_html(shape, filename): os.remove(filename) # HTML Head - html = ElementTree.Element("html", attrib={"xmlns": "http://www.w3.org/1999/xhtml"}) + html = ElementTree.Element("html", attrib={"xmlns":"http://www.w3.org/1999/xhtml"}) head = ElementTree.SubElement(html, "head") script = ElementTree.SubElement( head, From 4f6200ead8ce27bc154c57cdc981c6e697966bee Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 27 Jun 2024 15:41:42 -0400 Subject: [PATCH 21/58] Revise variable names for clarity --- coxeter/io.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/coxeter/io.py b/coxeter/io.py index 675f6b6b..01aa131d 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -28,12 +28,12 @@ def to_obj(shape, filename): ) for v in shape.vertices: - file.write(f"v {' '.join([str(i) for i in v])}\n") + file.write(f"v {' '.join([str(coord) for coord in v])}\n") file.write("\n") for f in shape.faces: - file.write(f"f {' '.join([str(i+1) for i in f])}\n") + file.write(f"f {' '.join([str(v_index+1) for v_index in f])}\n") def to_off(shape, filename): @@ -59,10 +59,10 @@ def to_off(shape, filename): ) for v in shape.vertices: - file.write(f"{' '.join([str(i) for i in v])}\n") + file.write(f"{' '.join([str(coord) for coord in v])}\n") for f in shape.faces: - file.write(f"{len(f)} {' '.join([str(i) for i in f])}\n") + file.write(f"{len(f)} {' '.join([str(v_index) for v_index in f])}\n") def to_stl(shape, filename): @@ -134,10 +134,10 @@ def to_ply(shape, filename): ) for v in shape.vertices: - file.write(f"{' '.join([str(i) for i in v])}\n") + file.write(f"{' '.join([str(coord) for coord in v])}\n") for f in shape.faces: - file.write(f"{len(f)} {' '.join([str(int(i)) for i in f])}\n") + file.write(f"{len(f)} {' '.join([str(int(v_index)) for v_index in f])}\n") def to_x3d(shape, filename): @@ -174,23 +174,23 @@ def to_x3d(shape, filename): ) # Geometry data - coordinate_indices = list(range(sum([len(f) for f in shape.faces]))) + point_indices = list(range(sum([len(f) for f in shape.faces]))) prev_index = 0 for f in shape.faces: - coordinate_indices.insert(len(f) + prev_index, -1) + point_indices.insert(len(f) + prev_index, -1) prev_index += len(f) + 1 - coordinate_points = [v for f in shape.faces for i in f for v in shape.vertices[i]] + points = [v for f in shape.faces for v_index in f for v in shape.vertices[v_index]] x3d_indexedfaceset = ElementTree.SubElement( x3d_shape, "IndexedFaceSet", - attrib={"coordIndex": " ".join([str(i) for i in coordinate_indices])}, + attrib={"coordIndex": " ".join([str(c_index) for c_index in point_indices])}, ) ElementTree.SubElement( x3d_indexedfaceset, "Coordinate", - attrib={"point": " ".join([str(i) for i in coordinate_points])}, + attrib={"point": " ".join([str(p) for p in points])}, ) # Write to file @@ -226,7 +226,7 @@ def to_vtk(shape, filename): num_connections = sum([len(f) for f in shape.faces]) content += f"POLYGONS {num_points} {num_points + num_connections}\n" for f in shape.faces: - content += f"{len(f)} {' '.join([str(i) for i in f])}\n" + content += f"{len(f)} {' '.join([str(v_index) for v_index in f])}\n" # Write file with open(filename, "wb") as file: From 4d49bb150f331446e655e438adafe866141c07a0 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 27 Jun 2024 15:48:33 -0400 Subject: [PATCH 22/58] Add module docstring --- coxeter/io.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/coxeter/io.py b/coxeter/io.py index 01aa131d..44419260 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -1,3 +1,15 @@ +# Copyright (c) 2021 The Regents of the University of Michigan +# All rights reserved. +# This software is licensed under the BSD 3-Clause License. +"""Import/Export utilities for shape classes. + +This module contains functions for saving shapes to disk and creating shapes from +local files. Currently, the following formats are supported: +- Import: OBJ, OFF, PLY, VTK +- Export: OBJ, OFF, STL, PLY, VTK, X3D, HTML + +These functions currently only work with `Polyhedron` and its subclasses. +""" import os from xml.etree import ElementTree From 330efb0cd5a0e61f954009b304e7e76a3b9fd5e4 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 27 Jun 2024 16:06:00 -0400 Subject: [PATCH 23/58] Add convenience method to Polyhedron class --- coxeter/shapes/polyhedron.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/coxeter/shapes/polyhedron.py b/coxeter/shapes/polyhedron.py index 6e817aad..015fba2d 100644 --- a/coxeter/shapes/polyhedron.py +++ b/coxeter/shapes/polyhedron.py @@ -22,6 +22,7 @@ _set_3d_axes_equal, translate_inertia_tensor, ) +from .. import io try: import miniball @@ -1020,3 +1021,37 @@ def to_hoomd(self): self.centroid = old_centroid return hoomd_dict + + def save(self, filetype, filename): + """Convenience method that calls the relevant function from the io module. + + Args: + filetype (str): + The file format to export Polyhedron to. Must be one of the following: + OBJ, OFF, STL, PLY, VTK, X3D, HTML. + + filename (str, pathlib.Path, or os.PathLike): + The name or path of the output file, including the extension. + + Raises + ------ + ValueError: If filetype is not one of the required strings. + """ + match filetype: + case "OBJ": + io.to_obj(self, filename) + case "OFF": + io.to_off(self, filename) + case "STL": + io.to_stl(self, filename) + case "PLY": + io.to_ply(self, filename) + case "VTK": + io.to_vtk(self, filename) + case "X3D": + io.to_x3d(self, filename) + case "HTML": + io.to_html(self, filename) + case _: + raise ValueError(f"filetype must be one of the following: OBJ, OFF, " + f"STL, PLY, VTK, X3D, HTML") \ No newline at end of file From f0d97369859301e7d93556f177f8506c5e322c71 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 27 Jun 2024 16:06:46 -0400 Subject: [PATCH 24/58] Revise docstring --- coxeter/io.py | 1 - 1 file changed, 1 deletion(-) diff --git a/coxeter/io.py b/coxeter/io.py index 44419260..4f33c2d6 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -5,7 +5,6 @@ This module contains functions for saving shapes to disk and creating shapes from local files. Currently, the following formats are supported: -- Import: OBJ, OFF, PLY, VTK - Export: OBJ, OFF, STL, PLY, VTK, X3D, HTML These functions currently only work with `Polyhedron` and its subclasses. From 927b2cd467a19a8fc67cb8c170ac4d1a2fc44c9b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 28 Jun 2024 13:57:37 +0000 Subject: [PATCH 25/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- coxeter/__init__.py | 2 +- coxeter/io.py | 3 ++- coxeter/shapes/polyhedron.py | 10 ++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/coxeter/__init__.py b/coxeter/__init__.py index 4e738a13..fa9882b5 100644 --- a/coxeter/__init__.py +++ b/coxeter/__init__.py @@ -16,7 +16,7 @@ applications such as inertia tensors. """ -from . import families, shapes, io +from . import families, io, shapes from .shape_getters import from_gsd_type_shapes __all__ = ["families", "shapes", "from_gsd_type_shapes", "io"] diff --git a/coxeter/io.py b/coxeter/io.py index 4f33c2d6..fdd1efe4 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -9,6 +9,7 @@ These functions currently only work with `Polyhedron` and its subclasses. """ + import os from xml.etree import ElementTree @@ -264,7 +265,7 @@ def to_html(shape, filename): os.remove(filename) # HTML Head - html = ElementTree.Element("html", attrib={"xmlns":"http://www.w3.org/1999/xhtml"}) + html = ElementTree.Element("html", attrib={"xmlns": "http://www.w3.org/1999/xhtml"}) head = ElementTree.SubElement(html, "head") script = ElementTree.SubElement( head, diff --git a/coxeter/shapes/polyhedron.py b/coxeter/shapes/polyhedron.py index 015fba2d..5ac383f2 100644 --- a/coxeter/shapes/polyhedron.py +++ b/coxeter/shapes/polyhedron.py @@ -10,6 +10,7 @@ import rowan from scipy.sparse.csgraph import connected_components +from .. import io from ..extern.polytri import polytri from .base_classes import Shape3D from .convex_polygon import ConvexPolygon, _is_convex @@ -22,7 +23,6 @@ _set_3d_axes_equal, translate_inertia_tensor, ) -from .. import io try: import miniball @@ -1035,7 +1035,7 @@ def save(self, filetype, filename): Raises ------ - ValueError: If filetype is not one of the required strings. + ValueError: If filetype is not one of the required strings. """ match filetype: case "OBJ": @@ -1053,5 +1053,7 @@ def save(self, filetype, filename): case "HTML": io.to_html(self, filename) case _: - raise ValueError(f"filetype must be one of the following: OBJ, OFF, " - f"STL, PLY, VTK, X3D, HTML") \ No newline at end of file + raise ValueError( + "filetype must be one of the following: OBJ, OFF, " + "STL, PLY, VTK, X3D, HTML" + ) From 21137871a935d864d8254967b89ae15dfd13159b Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Fri, 28 Jun 2024 10:47:28 -0400 Subject: [PATCH 26/58] Change match/case to if/elif for backwards compatibility --- coxeter/shapes/polyhedron.py | 37 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/coxeter/shapes/polyhedron.py b/coxeter/shapes/polyhedron.py index 5ac383f2..d5f10335 100644 --- a/coxeter/shapes/polyhedron.py +++ b/coxeter/shapes/polyhedron.py @@ -1037,23 +1037,20 @@ def save(self, filetype, filename): ------ ValueError: If filetype is not one of the required strings. """ - match filetype: - case "OBJ": - io.to_obj(self, filename) - case "OFF": - io.to_off(self, filename) - case "STL": - io.to_stl(self, filename) - case "PLY": - io.to_ply(self, filename) - case "VTK": - io.to_vtk(self, filename) - case "X3D": - io.to_x3d(self, filename) - case "HTML": - io.to_html(self, filename) - case _: - raise ValueError( - "filetype must be one of the following: OBJ, OFF, " - "STL, PLY, VTK, X3D, HTML" - ) + if filetype == "OBJ": + io.to_obj(self, filename) + elif filetype == "OFF": + io.to_off(self, filename) + elif filetype == "STL": + io.to_stl(self, filename) + elif filetype == "PLY": + io.to_ply(self, filename) + elif filetype == "VTK": + io.to_vtk(self, filename) + elif filetype == "X3D": + io.to_x3d(self, filename) + elif filetype == "HTML": + io.to_html(self, filename) + else: + raise ValueError(f"filetype must be one of the following: OBJ, OFF, " + f"STL, PLY, VTK, X3D, HTML") \ No newline at end of file From 92968f46042fadb4ffe3964495a875f0ac870154 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 28 Jun 2024 14:48:43 +0000 Subject: [PATCH 27/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- coxeter/shapes/polyhedron.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/coxeter/shapes/polyhedron.py b/coxeter/shapes/polyhedron.py index d5f10335..effb7524 100644 --- a/coxeter/shapes/polyhedron.py +++ b/coxeter/shapes/polyhedron.py @@ -1052,5 +1052,7 @@ def save(self, filetype, filename): elif filetype == "HTML": io.to_html(self, filename) else: - raise ValueError(f"filetype must be one of the following: OBJ, OFF, " - f"STL, PLY, VTK, X3D, HTML") \ No newline at end of file + raise ValueError( + "filetype must be one of the following: OBJ, OFF, " + "STL, PLY, VTK, X3D, HTML" + ) From d06cc4a531a62240500a7928b06cc4c1d982264c Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Fri, 28 Jun 2024 10:50:13 -0400 Subject: [PATCH 28/58] Revise docstring --- coxeter/shapes/polyhedron.py | 1 + 1 file changed, 1 insertion(+) diff --git a/coxeter/shapes/polyhedron.py b/coxeter/shapes/polyhedron.py index effb7524..b7d327fb 100644 --- a/coxeter/shapes/polyhedron.py +++ b/coxeter/shapes/polyhedron.py @@ -1036,6 +1036,7 @@ def save(self, filetype, filename): Raises ------ ValueError: If filetype is not one of the required strings. + OSError: If open() encounters a problem. """ if filetype == "OBJ": io.to_obj(self, filename) From fa739f5417a327e6bced846f73759ead32725985 Mon Sep 17 00:00:00 2001 From: janbridley Date: Tue, 2 Jul 2024 16:36:27 -0400 Subject: [PATCH 29/58] Fix circular import --- coxeter/io.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/coxeter/io.py b/coxeter/io.py index fdd1efe4..24dd87a4 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -11,11 +11,12 @@ """ import os +from importlib.metadata import version from xml.etree import ElementTree import numpy as np -from coxeter import __version__ +__version__ = version("coxeter") def to_obj(shape, filename): From 52a21e4e34e4152a9faf29c4fb3c75cbd9aab22f Mon Sep 17 00:00:00 2001 From: Jen Bradley <55467578+janbridley@users.noreply.github.com> Date: Tue, 2 Jul 2024 16:38:53 -0400 Subject: [PATCH 30/58] Update copyright in coxeter/io.py Co-authored-by: Joshua A. Anderson --- coxeter/io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coxeter/io.py b/coxeter/io.py index 24dd87a4..9da9413e 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 The Regents of the University of Michigan +# Copyright (c) 2024 The Regents of the University of Michigan # All rights reserved. # This software is licensed under the BSD 3-Clause License. """Import/Export utilities for shape classes. From 7f327de17884d82112241b186a978357117a4668 Mon Sep 17 00:00:00 2001 From: janbridley Date: Tue, 2 Jul 2024 16:46:04 -0400 Subject: [PATCH 31/58] Fix D401 --- coxeter/shapes/polyhedron.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coxeter/shapes/polyhedron.py b/coxeter/shapes/polyhedron.py index b7d327fb..44377727 100644 --- a/coxeter/shapes/polyhedron.py +++ b/coxeter/shapes/polyhedron.py @@ -1023,11 +1023,11 @@ def to_hoomd(self): return hoomd_dict def save(self, filetype, filename): - """Convenience method that calls the relevant function from the io module. + """Save the polyhedron object to a file using methods from ``coxeter.io``. Args: filetype (str): - The file format to export Polyhedron to. Must be one of the following: + The file format to export polyhedron to. Must be one of the following: OBJ, OFF, STL, PLY, VTK, X3D, HTML. filename (str, pathlib.Path, or os.PathLike): From 3e3fd1fa38c635d767aa467a57e6eafeb782092f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 18 Jul 2024 16:20:22 +0000 Subject: [PATCH 32/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- coxeter/io.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/coxeter/io.py b/coxeter/io.py index 9da9413e..714e9a60 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -1,6 +1,6 @@ -# Copyright (c) 2024 The Regents of the University of Michigan -# All rights reserved. -# This software is licensed under the BSD 3-Clause License. +# Copyright (c) 2015-2024 The Regents of the University of Michigan. +# This file is from the coxeter project, released under the BSD 3-Clause License. + """Import/Export utilities for shape classes. This module contains functions for saving shapes to disk and creating shapes from From 1a198908755021219f955a12a84bdde3be3e5440 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 12 Sep 2024 11:36:22 -0400 Subject: [PATCH 33/58] Fix unintended shape mutation --- coxeter/io.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/coxeter/io.py b/coxeter/io.py index 714e9a60..66fabd22 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -13,7 +13,7 @@ import os from importlib.metadata import version from xml.etree import ElementTree - +from copy import deepcopy import numpy as np __version__ = version("coxeter") @@ -93,6 +93,9 @@ def to_stl(shape, filename): OSError: If open() encounters a problem. """ with open(filename, "w") as file: + # Ensure shape is not mutated + shape = deepcopy(shape) + # Shift vertices so all coordinates are positive mins = np.amin(a=shape.vertices, axis=0) for i, m in enumerate(mins): From 999b09d34d85b96a02c008b83e00dd5907113127 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 12 Sep 2024 11:36:43 -0400 Subject: [PATCH 34/58] Limit imports to reduce loading time --- tests/test_io.py | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 tests/test_io.py diff --git a/tests/test_io.py b/tests/test_io.py new file mode 100644 index 00000000..260b3e40 --- /dev/null +++ b/tests/test_io.py @@ -0,0 +1,72 @@ + +# Copyright (c) 2024 The Regents of the University of Michigan +# All rights reserved. +# This software is licensed under the BSD 3-Clause License. +"""Regression tests for the I/O module.""" + +import pytest +import tempfile +from pathlib import Path +import filecmp +from coxeter import io +from coxeter.shapes import Polyhedron, ConvexPolyhedron + +EXPORT_FUNCS_BY_FILE_TYPE = { + "obj": io.to_obj, + "off": io.to_off, + "stl": io.to_stl, + "ply": io.to_ply, + "x3d": io.to_x3d, + "vtk": io.to_vtk, + "html": io.to_html +} + +SHAPES_BY_NAME = { + "polyhedron": Polyhedron( + vertices=[ + [-1, -1, -1], [-1, -1, 1], [-1, 1, -1], [-1, 1, 1], [1, -1, -1], + [1, -1, 1], [1, 1, -1], [1, 1, 1] + ], + faces=[ + [0, 1, 3, 2], [0, 2, 6, 4], [4, 6, 7, 5], [1, 5, 7, 3], + [0, 4, 5, 1], [6, 2, 3, 7] + ] + ), + "convex_polyhedron": ConvexPolyhedron( + vertices=[ + [-1, -1, -1], [-1, -1, 1], [-1, 1, -1], [-1, 1, 1], [1, -1, -1], + [1, -1, 1], [1, 1, -1], [1, 1, 1] + ] + ) +} + +CONTROL_DIR = Path("/home/joseph/GlotzerGroup/coxeter/tests/control") + + +@pytest.mark.parametrize( + "file_type,export_func,shape_name", + [(ft, func, name) + for ft, func in EXPORT_FUNCS_BY_FILE_TYPE.items() + for name in SHAPES_BY_NAME.keys()] +) +def test_regression(file_type, export_func, shape_name): + """Check that export functions yield files identical to the control.""" + control_file_path = CONTROL_DIR / f"{shape_name}.{file_type}" + shape = SHAPES_BY_NAME[shape_name] + + with tempfile.TemporaryDirectory(dir=CONTROL_DIR) as tempdir: + test_file_path = Path(tempdir) / f"test_{shape_name}.{file_type}" + export_func(shape=shape, filename=test_file_path) + + assert filecmp.cmp(control_file_path, test_file_path, shallow=False), \ + f"During regression testing with the shape '{shape_name}' and " \ + f"file type '{file_type}', {control_file_path.name} and " \ + f"{test_file_path.name} were found to be not equivalent." + + +if __name__ == "__main__": + # Generate new control files + for name in SHAPES_BY_NAME.keys(): + for ft, func in EXPORT_FUNCS_BY_FILE_TYPE.items(): + control_file_path = CONTROL_DIR / f"{name}.{ft}" + func(shape=SHAPES_BY_NAME[name], filename=control_file_path) \ No newline at end of file From 94ab8e9977d546f45ac767c8638f47d6dee0faeb Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 12 Sep 2024 11:43:17 -0400 Subject: [PATCH 35/58] Create io control files --- tests/control/convex_polyhedron.html | 1 + tests/control/convex_polyhedron.obj | 18 ++++++ tests/control/convex_polyhedron.off | 18 ++++++ tests/control/convex_polyhedron.ply | 25 ++++++++ tests/control/convex_polyhedron.stl | 86 ++++++++++++++++++++++++++++ tests/control/convex_polyhedron.vtk | 20 +++++++ tests/control/convex_polyhedron.x3d | 1 + tests/control/polyhedron.html | 1 + tests/control/polyhedron.obj | 18 ++++++ tests/control/polyhedron.off | 18 ++++++ tests/control/polyhedron.ply | 25 ++++++++ tests/control/polyhedron.stl | 86 ++++++++++++++++++++++++++++ tests/control/polyhedron.vtk | 20 +++++++ tests/control/polyhedron.x3d | 1 + 14 files changed, 338 insertions(+) create mode 100644 tests/control/convex_polyhedron.html create mode 100644 tests/control/convex_polyhedron.obj create mode 100644 tests/control/convex_polyhedron.off create mode 100644 tests/control/convex_polyhedron.ply create mode 100644 tests/control/convex_polyhedron.stl create mode 100644 tests/control/convex_polyhedron.vtk create mode 100644 tests/control/convex_polyhedron.x3d create mode 100644 tests/control/polyhedron.html create mode 100644 tests/control/polyhedron.obj create mode 100644 tests/control/polyhedron.off create mode 100644 tests/control/polyhedron.ply create mode 100644 tests/control/polyhedron.stl create mode 100644 tests/control/polyhedron.vtk create mode 100644 tests/control/polyhedron.x3d diff --git a/tests/control/convex_polyhedron.html b/tests/control/convex_polyhedron.html new file mode 100644 index 00000000..f27b53d1 --- /dev/null +++ b/tests/control/convex_polyhedron.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/control/convex_polyhedron.obj b/tests/control/convex_polyhedron.obj new file mode 100644 index 00000000..ed5a19cb --- /dev/null +++ b/tests/control/convex_polyhedron.obj @@ -0,0 +1,18 @@ +# wavefront obj file written by Coxeter version 0.7.0 +# ConvexPolyhedron + +v -1.0 -1.0 -1.0 +v -1.0 -1.0 1.0 +v -1.0 1.0 -1.0 +v -1.0 1.0 1.0 +v 1.0 -1.0 -1.0 +v 1.0 -1.0 1.0 +v 1.0 1.0 -1.0 +v 1.0 1.0 1.0 + +f 1 3 7 5 +f 1 5 6 2 +f 5 7 8 6 +f 1 2 4 3 +f 3 4 8 7 +f 2 6 8 4 diff --git a/tests/control/convex_polyhedron.off b/tests/control/convex_polyhedron.off new file mode 100644 index 00000000..48c3bd25 --- /dev/null +++ b/tests/control/convex_polyhedron.off @@ -0,0 +1,18 @@ +OFF +# OFF file written by Coxeter version 0.7.0 +# ConvexPolyhedron +8 f6 12 +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +4 0 2 6 4 +4 0 4 5 1 +4 4 6 7 5 +4 0 1 3 2 +4 2 3 7 6 +4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.ply b/tests/control/convex_polyhedron.ply new file mode 100644 index 00000000..622eb5f5 --- /dev/null +++ b/tests/control/convex_polyhedron.ply @@ -0,0 +1,25 @@ +ply +format ascii 1.0 +comment PLY file written by Coxeter version 0.7.0 +comment ConvexPolyhedron +element vertex 8 +property float x +property float y +property float z +element face 6 +property list uchar uint vertex_indices +end_header +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +4 0 2 6 4 +4 0 4 5 1 +4 4 6 7 5 +4 0 1 3 2 +4 2 3 7 6 +4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.stl b/tests/control/convex_polyhedron.stl new file mode 100644 index 00000000..9d9a416e --- /dev/null +++ b/tests/control/convex_polyhedron.stl @@ -0,0 +1,86 @@ +solid ConvexPolyhedron +facet normal 0.0 0.0 -4.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 1.0 -1.0 + vertex 1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 0.0 -4.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 1.0 -1.0 + vertex 1.0 -1.0 -1.0 + endloop +endfacet +facet normal 0.0 -4.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 -1.0 -1.0 + vertex 1.0 -1.0 1.0 + endloop +endfacet +facet normal 0.0 -4.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 -1.0 1.0 + vertex -1.0 -1.0 1.0 + endloop +endfacet +facet normal 4.0 0.0 0.0 + outer loop + vertex 1.0 -1.0 -1.0 + vertex 1.0 1.0 -1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal 4.0 0.0 -0.0 + outer loop + vertex 1.0 -1.0 -1.0 + vertex 1.0 1.0 1.0 + vertex 1.0 -1.0 1.0 + endloop +endfacet +facet normal -4.0 0.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 -1.0 1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +facet normal -4.0 0.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 1.0 1.0 + vertex -1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 4.0 0.0 + outer loop + vertex -1.0 1.0 -1.0 + vertex -1.0 1.0 1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal -0.0 4.0 0.0 + outer loop + vertex -1.0 1.0 -1.0 + vertex 1.0 1.0 1.0 + vertex 1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 0.0 4.0 + outer loop + vertex -1.0 -1.0 1.0 + vertex 1.0 -1.0 1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal 0.0 -0.0 4.0 + outer loop + vertex -1.0 -1.0 1.0 + vertex 1.0 1.0 1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +endsolid ConvexPolyhedron \ No newline at end of file diff --git a/tests/control/convex_polyhedron.vtk b/tests/control/convex_polyhedron.vtk new file mode 100644 index 00000000..34a23afd --- /dev/null +++ b/tests/control/convex_polyhedron.vtk @@ -0,0 +1,20 @@ +# vtk DataFile Version 3.0 +ConvexPolyhedron created by Coxeter version 0.7.0 +ASCII +DATASET POLYDATA +POINTS 8 float +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +POLYGONS 6 30 +4 0 2 6 4 +4 0 4 5 1 +4 4 6 7 5 +4 0 1 3 2 +4 2 3 7 6 +4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.x3d b/tests/control/convex_polyhedron.x3d new file mode 100644 index 00000000..d673d9e4 --- /dev/null +++ b/tests/control/convex_polyhedron.x3d @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/control/polyhedron.html b/tests/control/polyhedron.html new file mode 100644 index 00000000..3c4d4187 --- /dev/null +++ b/tests/control/polyhedron.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/control/polyhedron.obj b/tests/control/polyhedron.obj new file mode 100644 index 00000000..26f336ce --- /dev/null +++ b/tests/control/polyhedron.obj @@ -0,0 +1,18 @@ +# wavefront obj file written by Coxeter version 0.7.0 +# Polyhedron + +v -1.0 -1.0 -1.0 +v -1.0 -1.0 1.0 +v -1.0 1.0 -1.0 +v -1.0 1.0 1.0 +v 1.0 -1.0 -1.0 +v 1.0 -1.0 1.0 +v 1.0 1.0 -1.0 +v 1.0 1.0 1.0 + +f 1 2 4 3 +f 1 3 7 5 +f 5 7 8 6 +f 2 6 8 4 +f 1 5 6 2 +f 7 3 4 8 diff --git a/tests/control/polyhedron.off b/tests/control/polyhedron.off new file mode 100644 index 00000000..2c948353 --- /dev/null +++ b/tests/control/polyhedron.off @@ -0,0 +1,18 @@ +OFF +# OFF file written by Coxeter version 0.7.0 +# Polyhedron +8 f6 12 +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +4 0 1 3 2 +4 0 2 6 4 +4 4 6 7 5 +4 1 5 7 3 +4 0 4 5 1 +4 6 2 3 7 diff --git a/tests/control/polyhedron.ply b/tests/control/polyhedron.ply new file mode 100644 index 00000000..f5cd5e56 --- /dev/null +++ b/tests/control/polyhedron.ply @@ -0,0 +1,25 @@ +ply +format ascii 1.0 +comment PLY file written by Coxeter version 0.7.0 +comment Polyhedron +element vertex 8 +property float x +property float y +property float z +element face 6 +property list uchar uint vertex_indices +end_header +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +4 0 1 3 2 +4 0 2 6 4 +4 4 6 7 5 +4 1 5 7 3 +4 0 4 5 1 +4 6 2 3 7 diff --git a/tests/control/polyhedron.stl b/tests/control/polyhedron.stl new file mode 100644 index 00000000..36280262 --- /dev/null +++ b/tests/control/polyhedron.stl @@ -0,0 +1,86 @@ +solid Polyhedron +facet normal -4.0 0.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 -1.0 1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +facet normal -4.0 0.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 1.0 1.0 + vertex -1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 0.0 -4.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 1.0 -1.0 + vertex 1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 0.0 -4.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 1.0 -1.0 + vertex 1.0 -1.0 -1.0 + endloop +endfacet +facet normal 4.0 0.0 0.0 + outer loop + vertex 1.0 -1.0 -1.0 + vertex 1.0 1.0 -1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal 4.0 0.0 -0.0 + outer loop + vertex 1.0 -1.0 -1.0 + vertex 1.0 1.0 1.0 + vertex 1.0 -1.0 1.0 + endloop +endfacet +facet normal 0.0 0.0 4.0 + outer loop + vertex -1.0 -1.0 1.0 + vertex 1.0 -1.0 1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal 0.0 -0.0 4.0 + outer loop + vertex -1.0 -1.0 1.0 + vertex 1.0 1.0 1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +facet normal 0.0 -4.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 -1.0 -1.0 + vertex 1.0 -1.0 1.0 + endloop +endfacet +facet normal 0.0 -4.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 -1.0 1.0 + vertex -1.0 -1.0 1.0 + endloop +endfacet +facet normal 0.0 4.0 -0.0 + outer loop + vertex 1.0 1.0 -1.0 + vertex -1.0 1.0 -1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +facet normal 0.0 4.0 -0.0 + outer loop + vertex 1.0 1.0 -1.0 + vertex -1.0 1.0 1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +endsolid Polyhedron \ No newline at end of file diff --git a/tests/control/polyhedron.vtk b/tests/control/polyhedron.vtk new file mode 100644 index 00000000..d2920cbf --- /dev/null +++ b/tests/control/polyhedron.vtk @@ -0,0 +1,20 @@ +# vtk DataFile Version 3.0 +Polyhedron created by Coxeter version 0.7.0 +ASCII +DATASET POLYDATA +POINTS 8 float +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +POLYGONS 6 30 +4 0 1 3 2 +4 0 2 6 4 +4 4 6 7 5 +4 1 5 7 3 +4 0 4 5 1 +4 6 2 3 7 diff --git a/tests/control/polyhedron.x3d b/tests/control/polyhedron.x3d new file mode 100644 index 00000000..727efcb4 --- /dev/null +++ b/tests/control/polyhedron.x3d @@ -0,0 +1 @@ + \ No newline at end of file From bc35493ec734a79e9b8297121d6e86885b54e106 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:43:29 +0000 Subject: [PATCH 36/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- coxeter/io.py | 3 +- tests/control/convex_polyhedron.html | 2 +- tests/control/convex_polyhedron.stl | 2 +- tests/control/convex_polyhedron.x3d | 2 +- tests/control/polyhedron.html | 2 +- tests/control/polyhedron.stl | 2 +- tests/control/polyhedron.x3d | 2 +- tests/test_io.py | 75 ++++++++++++++++++---------- 8 files changed, 57 insertions(+), 33 deletions(-) diff --git a/coxeter/io.py b/coxeter/io.py index 66fabd22..8d72660e 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -11,9 +11,10 @@ """ import os +from copy import deepcopy from importlib.metadata import version from xml.etree import ElementTree -from copy import deepcopy + import numpy as np __version__ = version("coxeter") diff --git a/tests/control/convex_polyhedron.html b/tests/control/convex_polyhedron.html index f27b53d1..4d1a5f26 100644 --- a/tests/control/convex_polyhedron.html +++ b/tests/control/convex_polyhedron.html @@ -1 +1 @@ - \ No newline at end of file + diff --git a/tests/control/convex_polyhedron.stl b/tests/control/convex_polyhedron.stl index 9d9a416e..1c9224ea 100644 --- a/tests/control/convex_polyhedron.stl +++ b/tests/control/convex_polyhedron.stl @@ -83,4 +83,4 @@ facet normal 0.0 -0.0 4.0 vertex -1.0 1.0 1.0 endloop endfacet -endsolid ConvexPolyhedron \ No newline at end of file +endsolid ConvexPolyhedron diff --git a/tests/control/convex_polyhedron.x3d b/tests/control/convex_polyhedron.x3d index d673d9e4..7c4baa7f 100644 --- a/tests/control/convex_polyhedron.x3d +++ b/tests/control/convex_polyhedron.x3d @@ -1 +1 @@ - \ No newline at end of file + diff --git a/tests/control/polyhedron.html b/tests/control/polyhedron.html index 3c4d4187..279bc798 100644 --- a/tests/control/polyhedron.html +++ b/tests/control/polyhedron.html @@ -1 +1 @@ - \ No newline at end of file + diff --git a/tests/control/polyhedron.stl b/tests/control/polyhedron.stl index 36280262..8d7bd97a 100644 --- a/tests/control/polyhedron.stl +++ b/tests/control/polyhedron.stl @@ -83,4 +83,4 @@ facet normal 0.0 4.0 -0.0 vertex 1.0 1.0 1.0 endloop endfacet -endsolid Polyhedron \ No newline at end of file +endsolid Polyhedron diff --git a/tests/control/polyhedron.x3d b/tests/control/polyhedron.x3d index 727efcb4..9510201b 100644 --- a/tests/control/polyhedron.x3d +++ b/tests/control/polyhedron.x3d @@ -1 +1 @@ - \ No newline at end of file + diff --git a/tests/test_io.py b/tests/test_io.py index 260b3e40..31d0ea8a 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1,53 +1,75 @@ +# Copyright (c) 2015-2024 The Regents of the University of Michigan. +# This file is from the coxeter project, released under the BSD 3-Clause License. # Copyright (c) 2024 The Regents of the University of Michigan # All rights reserved. # This software is licensed under the BSD 3-Clause License. """Regression tests for the I/O module.""" -import pytest +import filecmp import tempfile from pathlib import Path -import filecmp + +import pytest + from coxeter import io -from coxeter.shapes import Polyhedron, ConvexPolyhedron +from coxeter.shapes import ConvexPolyhedron, Polyhedron EXPORT_FUNCS_BY_FILE_TYPE = { - "obj": io.to_obj, - "off": io.to_off, - "stl": io.to_stl, - "ply": io.to_ply, - "x3d": io.to_x3d, - "vtk": io.to_vtk, - "html": io.to_html + "obj": io.to_obj, + "off": io.to_off, + "stl": io.to_stl, + "ply": io.to_ply, + "x3d": io.to_x3d, + "vtk": io.to_vtk, + "html": io.to_html, } SHAPES_BY_NAME = { "polyhedron": Polyhedron( vertices=[ - [-1, -1, -1], [-1, -1, 1], [-1, 1, -1], [-1, 1, 1], [1, -1, -1], - [1, -1, 1], [1, 1, -1], [1, 1, 1] + [-1, -1, -1], + [-1, -1, 1], + [-1, 1, -1], + [-1, 1, 1], + [1, -1, -1], + [1, -1, 1], + [1, 1, -1], + [1, 1, 1], ], faces=[ - [0, 1, 3, 2], [0, 2, 6, 4], [4, 6, 7, 5], [1, 5, 7, 3], - [0, 4, 5, 1], [6, 2, 3, 7] - ] + [0, 1, 3, 2], + [0, 2, 6, 4], + [4, 6, 7, 5], + [1, 5, 7, 3], + [0, 4, 5, 1], + [6, 2, 3, 7], + ], ), "convex_polyhedron": ConvexPolyhedron( vertices=[ - [-1, -1, -1], [-1, -1, 1], [-1, 1, -1], [-1, 1, 1], [1, -1, -1], - [1, -1, 1], [1, 1, -1], [1, 1, 1] + [-1, -1, -1], + [-1, -1, 1], + [-1, 1, -1], + [-1, 1, 1], + [1, -1, -1], + [1, -1, 1], + [1, 1, -1], + [1, 1, 1], ] - ) + ), } CONTROL_DIR = Path("/home/joseph/GlotzerGroup/coxeter/tests/control") @pytest.mark.parametrize( - "file_type,export_func,shape_name", - [(ft, func, name) - for ft, func in EXPORT_FUNCS_BY_FILE_TYPE.items() - for name in SHAPES_BY_NAME.keys()] + "file_type,export_func,shape_name", + [ + (ft, func, name) + for ft, func in EXPORT_FUNCS_BY_FILE_TYPE.items() + for name in SHAPES_BY_NAME.keys() + ], ) def test_regression(file_type, export_func, shape_name): """Check that export functions yield files identical to the control.""" @@ -58,10 +80,11 @@ def test_regression(file_type, export_func, shape_name): test_file_path = Path(tempdir) / f"test_{shape_name}.{file_type}" export_func(shape=shape, filename=test_file_path) - assert filecmp.cmp(control_file_path, test_file_path, shallow=False), \ - f"During regression testing with the shape '{shape_name}' and " \ - f"file type '{file_type}', {control_file_path.name} and " \ + assert filecmp.cmp(control_file_path, test_file_path, shallow=False), ( + f"During regression testing with the shape '{shape_name}' and " + f"file type '{file_type}', {control_file_path.name} and " f"{test_file_path.name} were found to be not equivalent." + ) if __name__ == "__main__": @@ -69,4 +92,4 @@ def test_regression(file_type, export_func, shape_name): for name in SHAPES_BY_NAME.keys(): for ft, func in EXPORT_FUNCS_BY_FILE_TYPE.items(): control_file_path = CONTROL_DIR / f"{name}.{ft}" - func(shape=SHAPES_BY_NAME[name], filename=control_file_path) \ No newline at end of file + func(shape=SHAPES_BY_NAME[name], filename=control_file_path) From 46d0859bd36f126dc01162e980090656183f9a78 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 12 Sep 2024 11:57:19 -0400 Subject: [PATCH 37/58] Fix incorrect control directory --- tests/test_io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_io.py b/tests/test_io.py index 31d0ea8a..1f17414f 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -60,7 +60,7 @@ ), } -CONTROL_DIR = Path("/home/joseph/GlotzerGroup/coxeter/tests/control") +CONTROL_DIR = Path("tests/control") @pytest.mark.parametrize( From f4ae897fc21fc396cb20c26e6632348a96ac4844 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 12 Sep 2024 12:07:25 -0400 Subject: [PATCH 38/58] Update control files --- tests/control/convex_polyhedron.html | 2 +- tests/control/convex_polyhedron.stl | 2 +- tests/control/convex_polyhedron.x3d | 2 +- tests/control/polyhedron.html | 2 +- tests/control/polyhedron.stl | 2 +- tests/control/polyhedron.x3d | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/control/convex_polyhedron.html b/tests/control/convex_polyhedron.html index 4d1a5f26..f27b53d1 100644 --- a/tests/control/convex_polyhedron.html +++ b/tests/control/convex_polyhedron.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/tests/control/convex_polyhedron.stl b/tests/control/convex_polyhedron.stl index 1c9224ea..9d9a416e 100644 --- a/tests/control/convex_polyhedron.stl +++ b/tests/control/convex_polyhedron.stl @@ -83,4 +83,4 @@ facet normal 0.0 -0.0 4.0 vertex -1.0 1.0 1.0 endloop endfacet -endsolid ConvexPolyhedron +endsolid ConvexPolyhedron \ No newline at end of file diff --git a/tests/control/convex_polyhedron.x3d b/tests/control/convex_polyhedron.x3d index 7c4baa7f..d673d9e4 100644 --- a/tests/control/convex_polyhedron.x3d +++ b/tests/control/convex_polyhedron.x3d @@ -1 +1 @@ - + \ No newline at end of file diff --git a/tests/control/polyhedron.html b/tests/control/polyhedron.html index 279bc798..3c4d4187 100644 --- a/tests/control/polyhedron.html +++ b/tests/control/polyhedron.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/tests/control/polyhedron.stl b/tests/control/polyhedron.stl index 8d7bd97a..36280262 100644 --- a/tests/control/polyhedron.stl +++ b/tests/control/polyhedron.stl @@ -83,4 +83,4 @@ facet normal 0.0 4.0 -0.0 vertex 1.0 1.0 1.0 endloop endfacet -endsolid Polyhedron +endsolid Polyhedron \ No newline at end of file diff --git a/tests/control/polyhedron.x3d b/tests/control/polyhedron.x3d index 9510201b..727efcb4 100644 --- a/tests/control/polyhedron.x3d +++ b/tests/control/polyhedron.x3d @@ -1 +1 @@ - + \ No newline at end of file From 3c2078a9d9ae32238f41acd8873f89e6ddea17d3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 16:08:02 +0000 Subject: [PATCH 39/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/control/convex_polyhedron.html | 2 +- tests/control/convex_polyhedron.stl | 2 +- tests/control/convex_polyhedron.x3d | 2 +- tests/control/polyhedron.html | 2 +- tests/control/polyhedron.stl | 2 +- tests/control/polyhedron.x3d | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/control/convex_polyhedron.html b/tests/control/convex_polyhedron.html index f27b53d1..4d1a5f26 100644 --- a/tests/control/convex_polyhedron.html +++ b/tests/control/convex_polyhedron.html @@ -1 +1 @@ - \ No newline at end of file + diff --git a/tests/control/convex_polyhedron.stl b/tests/control/convex_polyhedron.stl index 9d9a416e..1c9224ea 100644 --- a/tests/control/convex_polyhedron.stl +++ b/tests/control/convex_polyhedron.stl @@ -83,4 +83,4 @@ facet normal 0.0 -0.0 4.0 vertex -1.0 1.0 1.0 endloop endfacet -endsolid ConvexPolyhedron \ No newline at end of file +endsolid ConvexPolyhedron diff --git a/tests/control/convex_polyhedron.x3d b/tests/control/convex_polyhedron.x3d index d673d9e4..7c4baa7f 100644 --- a/tests/control/convex_polyhedron.x3d +++ b/tests/control/convex_polyhedron.x3d @@ -1 +1 @@ - \ No newline at end of file + diff --git a/tests/control/polyhedron.html b/tests/control/polyhedron.html index 3c4d4187..279bc798 100644 --- a/tests/control/polyhedron.html +++ b/tests/control/polyhedron.html @@ -1 +1 @@ - \ No newline at end of file + diff --git a/tests/control/polyhedron.stl b/tests/control/polyhedron.stl index 36280262..8d7bd97a 100644 --- a/tests/control/polyhedron.stl +++ b/tests/control/polyhedron.stl @@ -83,4 +83,4 @@ facet normal 0.0 4.0 -0.0 vertex 1.0 1.0 1.0 endloop endfacet -endsolid Polyhedron \ No newline at end of file +endsolid Polyhedron diff --git a/tests/control/polyhedron.x3d b/tests/control/polyhedron.x3d index 727efcb4..9510201b 100644 --- a/tests/control/polyhedron.x3d +++ b/tests/control/polyhedron.x3d @@ -1 +1 @@ - \ No newline at end of file + From 4769ec5bdc30e761acd86a23b241b0fe48cf3058 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 12 Sep 2024 13:00:47 -0400 Subject: [PATCH 40/58] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e83b41ab..fe0a677a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,6 +6,7 @@ repos: rev: 'v4.6.0' hooks: - id: end-of-file-fixer + exclude: ^tests/control/ - id: trailing-whitespace exclude: '(?:setup.cfg.*|paper/.*)' - id: debug-statements From 9a19e000674e89f5327cfd38defd7e47ee7364e0 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 12 Sep 2024 13:00:58 -0400 Subject: [PATCH 41/58] Update control files --- tests/control/convex_polyhedron.html | 2 +- tests/control/convex_polyhedron.stl | 2 +- tests/control/convex_polyhedron.x3d | 2 +- tests/control/polyhedron.html | 2 +- tests/control/polyhedron.stl | 2 +- tests/control/polyhedron.x3d | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/control/convex_polyhedron.html b/tests/control/convex_polyhedron.html index 4d1a5f26..f27b53d1 100644 --- a/tests/control/convex_polyhedron.html +++ b/tests/control/convex_polyhedron.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/tests/control/convex_polyhedron.stl b/tests/control/convex_polyhedron.stl index 1c9224ea..9d9a416e 100644 --- a/tests/control/convex_polyhedron.stl +++ b/tests/control/convex_polyhedron.stl @@ -83,4 +83,4 @@ facet normal 0.0 -0.0 4.0 vertex -1.0 1.0 1.0 endloop endfacet -endsolid ConvexPolyhedron +endsolid ConvexPolyhedron \ No newline at end of file diff --git a/tests/control/convex_polyhedron.x3d b/tests/control/convex_polyhedron.x3d index 7c4baa7f..d673d9e4 100644 --- a/tests/control/convex_polyhedron.x3d +++ b/tests/control/convex_polyhedron.x3d @@ -1 +1 @@ - + \ No newline at end of file diff --git a/tests/control/polyhedron.html b/tests/control/polyhedron.html index 279bc798..3c4d4187 100644 --- a/tests/control/polyhedron.html +++ b/tests/control/polyhedron.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/tests/control/polyhedron.stl b/tests/control/polyhedron.stl index 8d7bd97a..36280262 100644 --- a/tests/control/polyhedron.stl +++ b/tests/control/polyhedron.stl @@ -83,4 +83,4 @@ facet normal 0.0 4.0 -0.0 vertex 1.0 1.0 1.0 endloop endfacet -endsolid Polyhedron +endsolid Polyhedron \ No newline at end of file diff --git a/tests/control/polyhedron.x3d b/tests/control/polyhedron.x3d index 9510201b..727efcb4 100644 --- a/tests/control/polyhedron.x3d +++ b/tests/control/polyhedron.x3d @@ -1 +1 @@ - + \ No newline at end of file From 391834cdae48e3b9853667d6a253c74443f860c3 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 12 Sep 2024 13:06:57 -0400 Subject: [PATCH 42/58] Delete control files --- tests/control/convex_polyhedron.html | 1 - tests/control/convex_polyhedron.obj | 18 ------ tests/control/convex_polyhedron.off | 18 ------ tests/control/convex_polyhedron.ply | 25 -------- tests/control/convex_polyhedron.stl | 86 ---------------------------- tests/control/convex_polyhedron.vtk | 20 ------- tests/control/convex_polyhedron.x3d | 1 - tests/control/polyhedron.html | 1 - tests/control/polyhedron.obj | 18 ------ tests/control/polyhedron.off | 18 ------ tests/control/polyhedron.ply | 25 -------- tests/control/polyhedron.stl | 86 ---------------------------- tests/control/polyhedron.vtk | 20 ------- tests/control/polyhedron.x3d | 1 - 14 files changed, 338 deletions(-) delete mode 100644 tests/control/convex_polyhedron.html delete mode 100644 tests/control/convex_polyhedron.obj delete mode 100644 tests/control/convex_polyhedron.off delete mode 100644 tests/control/convex_polyhedron.ply delete mode 100644 tests/control/convex_polyhedron.stl delete mode 100644 tests/control/convex_polyhedron.vtk delete mode 100644 tests/control/convex_polyhedron.x3d delete mode 100644 tests/control/polyhedron.html delete mode 100644 tests/control/polyhedron.obj delete mode 100644 tests/control/polyhedron.off delete mode 100644 tests/control/polyhedron.ply delete mode 100644 tests/control/polyhedron.stl delete mode 100644 tests/control/polyhedron.vtk delete mode 100644 tests/control/polyhedron.x3d diff --git a/tests/control/convex_polyhedron.html b/tests/control/convex_polyhedron.html deleted file mode 100644 index f27b53d1..00000000 --- a/tests/control/convex_polyhedron.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tests/control/convex_polyhedron.obj b/tests/control/convex_polyhedron.obj deleted file mode 100644 index ed5a19cb..00000000 --- a/tests/control/convex_polyhedron.obj +++ /dev/null @@ -1,18 +0,0 @@ -# wavefront obj file written by Coxeter version 0.7.0 -# ConvexPolyhedron - -v -1.0 -1.0 -1.0 -v -1.0 -1.0 1.0 -v -1.0 1.0 -1.0 -v -1.0 1.0 1.0 -v 1.0 -1.0 -1.0 -v 1.0 -1.0 1.0 -v 1.0 1.0 -1.0 -v 1.0 1.0 1.0 - -f 1 3 7 5 -f 1 5 6 2 -f 5 7 8 6 -f 1 2 4 3 -f 3 4 8 7 -f 2 6 8 4 diff --git a/tests/control/convex_polyhedron.off b/tests/control/convex_polyhedron.off deleted file mode 100644 index 48c3bd25..00000000 --- a/tests/control/convex_polyhedron.off +++ /dev/null @@ -1,18 +0,0 @@ -OFF -# OFF file written by Coxeter version 0.7.0 -# ConvexPolyhedron -8 f6 12 --1.0 -1.0 -1.0 --1.0 -1.0 1.0 --1.0 1.0 -1.0 --1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -4 0 2 6 4 -4 0 4 5 1 -4 4 6 7 5 -4 0 1 3 2 -4 2 3 7 6 -4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.ply b/tests/control/convex_polyhedron.ply deleted file mode 100644 index 622eb5f5..00000000 --- a/tests/control/convex_polyhedron.ply +++ /dev/null @@ -1,25 +0,0 @@ -ply -format ascii 1.0 -comment PLY file written by Coxeter version 0.7.0 -comment ConvexPolyhedron -element vertex 8 -property float x -property float y -property float z -element face 6 -property list uchar uint vertex_indices -end_header --1.0 -1.0 -1.0 --1.0 -1.0 1.0 --1.0 1.0 -1.0 --1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -4 0 2 6 4 -4 0 4 5 1 -4 4 6 7 5 -4 0 1 3 2 -4 2 3 7 6 -4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.stl b/tests/control/convex_polyhedron.stl deleted file mode 100644 index 9d9a416e..00000000 --- a/tests/control/convex_polyhedron.stl +++ /dev/null @@ -1,86 +0,0 @@ -solid ConvexPolyhedron -facet normal 0.0 0.0 -4.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex -1.0 1.0 -1.0 - vertex 1.0 1.0 -1.0 - endloop -endfacet -facet normal 0.0 0.0 -4.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex 1.0 1.0 -1.0 - vertex 1.0 -1.0 -1.0 - endloop -endfacet -facet normal 0.0 -4.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex 1.0 -1.0 -1.0 - vertex 1.0 -1.0 1.0 - endloop -endfacet -facet normal 0.0 -4.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex 1.0 -1.0 1.0 - vertex -1.0 -1.0 1.0 - endloop -endfacet -facet normal 4.0 0.0 0.0 - outer loop - vertex 1.0 -1.0 -1.0 - vertex 1.0 1.0 -1.0 - vertex 1.0 1.0 1.0 - endloop -endfacet -facet normal 4.0 0.0 -0.0 - outer loop - vertex 1.0 -1.0 -1.0 - vertex 1.0 1.0 1.0 - vertex 1.0 -1.0 1.0 - endloop -endfacet -facet normal -4.0 0.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex -1.0 -1.0 1.0 - vertex -1.0 1.0 1.0 - endloop -endfacet -facet normal -4.0 0.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex -1.0 1.0 1.0 - vertex -1.0 1.0 -1.0 - endloop -endfacet -facet normal 0.0 4.0 0.0 - outer loop - vertex -1.0 1.0 -1.0 - vertex -1.0 1.0 1.0 - vertex 1.0 1.0 1.0 - endloop -endfacet -facet normal -0.0 4.0 0.0 - outer loop - vertex -1.0 1.0 -1.0 - vertex 1.0 1.0 1.0 - vertex 1.0 1.0 -1.0 - endloop -endfacet -facet normal 0.0 0.0 4.0 - outer loop - vertex -1.0 -1.0 1.0 - vertex 1.0 -1.0 1.0 - vertex 1.0 1.0 1.0 - endloop -endfacet -facet normal 0.0 -0.0 4.0 - outer loop - vertex -1.0 -1.0 1.0 - vertex 1.0 1.0 1.0 - vertex -1.0 1.0 1.0 - endloop -endfacet -endsolid ConvexPolyhedron \ No newline at end of file diff --git a/tests/control/convex_polyhedron.vtk b/tests/control/convex_polyhedron.vtk deleted file mode 100644 index 34a23afd..00000000 --- a/tests/control/convex_polyhedron.vtk +++ /dev/null @@ -1,20 +0,0 @@ -# vtk DataFile Version 3.0 -ConvexPolyhedron created by Coxeter version 0.7.0 -ASCII -DATASET POLYDATA -POINTS 8 float --1.0 -1.0 -1.0 --1.0 -1.0 1.0 --1.0 1.0 -1.0 --1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -POLYGONS 6 30 -4 0 2 6 4 -4 0 4 5 1 -4 4 6 7 5 -4 0 1 3 2 -4 2 3 7 6 -4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.x3d b/tests/control/convex_polyhedron.x3d deleted file mode 100644 index d673d9e4..00000000 --- a/tests/control/convex_polyhedron.x3d +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tests/control/polyhedron.html b/tests/control/polyhedron.html deleted file mode 100644 index 3c4d4187..00000000 --- a/tests/control/polyhedron.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tests/control/polyhedron.obj b/tests/control/polyhedron.obj deleted file mode 100644 index 26f336ce..00000000 --- a/tests/control/polyhedron.obj +++ /dev/null @@ -1,18 +0,0 @@ -# wavefront obj file written by Coxeter version 0.7.0 -# Polyhedron - -v -1.0 -1.0 -1.0 -v -1.0 -1.0 1.0 -v -1.0 1.0 -1.0 -v -1.0 1.0 1.0 -v 1.0 -1.0 -1.0 -v 1.0 -1.0 1.0 -v 1.0 1.0 -1.0 -v 1.0 1.0 1.0 - -f 1 2 4 3 -f 1 3 7 5 -f 5 7 8 6 -f 2 6 8 4 -f 1 5 6 2 -f 7 3 4 8 diff --git a/tests/control/polyhedron.off b/tests/control/polyhedron.off deleted file mode 100644 index 2c948353..00000000 --- a/tests/control/polyhedron.off +++ /dev/null @@ -1,18 +0,0 @@ -OFF -# OFF file written by Coxeter version 0.7.0 -# Polyhedron -8 f6 12 --1.0 -1.0 -1.0 --1.0 -1.0 1.0 --1.0 1.0 -1.0 --1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -4 0 1 3 2 -4 0 2 6 4 -4 4 6 7 5 -4 1 5 7 3 -4 0 4 5 1 -4 6 2 3 7 diff --git a/tests/control/polyhedron.ply b/tests/control/polyhedron.ply deleted file mode 100644 index f5cd5e56..00000000 --- a/tests/control/polyhedron.ply +++ /dev/null @@ -1,25 +0,0 @@ -ply -format ascii 1.0 -comment PLY file written by Coxeter version 0.7.0 -comment Polyhedron -element vertex 8 -property float x -property float y -property float z -element face 6 -property list uchar uint vertex_indices -end_header --1.0 -1.0 -1.0 --1.0 -1.0 1.0 --1.0 1.0 -1.0 --1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -4 0 1 3 2 -4 0 2 6 4 -4 4 6 7 5 -4 1 5 7 3 -4 0 4 5 1 -4 6 2 3 7 diff --git a/tests/control/polyhedron.stl b/tests/control/polyhedron.stl deleted file mode 100644 index 36280262..00000000 --- a/tests/control/polyhedron.stl +++ /dev/null @@ -1,86 +0,0 @@ -solid Polyhedron -facet normal -4.0 0.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex -1.0 -1.0 1.0 - vertex -1.0 1.0 1.0 - endloop -endfacet -facet normal -4.0 0.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex -1.0 1.0 1.0 - vertex -1.0 1.0 -1.0 - endloop -endfacet -facet normal 0.0 0.0 -4.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex -1.0 1.0 -1.0 - vertex 1.0 1.0 -1.0 - endloop -endfacet -facet normal 0.0 0.0 -4.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex 1.0 1.0 -1.0 - vertex 1.0 -1.0 -1.0 - endloop -endfacet -facet normal 4.0 0.0 0.0 - outer loop - vertex 1.0 -1.0 -1.0 - vertex 1.0 1.0 -1.0 - vertex 1.0 1.0 1.0 - endloop -endfacet -facet normal 4.0 0.0 -0.0 - outer loop - vertex 1.0 -1.0 -1.0 - vertex 1.0 1.0 1.0 - vertex 1.0 -1.0 1.0 - endloop -endfacet -facet normal 0.0 0.0 4.0 - outer loop - vertex -1.0 -1.0 1.0 - vertex 1.0 -1.0 1.0 - vertex 1.0 1.0 1.0 - endloop -endfacet -facet normal 0.0 -0.0 4.0 - outer loop - vertex -1.0 -1.0 1.0 - vertex 1.0 1.0 1.0 - vertex -1.0 1.0 1.0 - endloop -endfacet -facet normal 0.0 -4.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex 1.0 -1.0 -1.0 - vertex 1.0 -1.0 1.0 - endloop -endfacet -facet normal 0.0 -4.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex 1.0 -1.0 1.0 - vertex -1.0 -1.0 1.0 - endloop -endfacet -facet normal 0.0 4.0 -0.0 - outer loop - vertex 1.0 1.0 -1.0 - vertex -1.0 1.0 -1.0 - vertex -1.0 1.0 1.0 - endloop -endfacet -facet normal 0.0 4.0 -0.0 - outer loop - vertex 1.0 1.0 -1.0 - vertex -1.0 1.0 1.0 - vertex 1.0 1.0 1.0 - endloop -endfacet -endsolid Polyhedron \ No newline at end of file diff --git a/tests/control/polyhedron.vtk b/tests/control/polyhedron.vtk deleted file mode 100644 index d2920cbf..00000000 --- a/tests/control/polyhedron.vtk +++ /dev/null @@ -1,20 +0,0 @@ -# vtk DataFile Version 3.0 -Polyhedron created by Coxeter version 0.7.0 -ASCII -DATASET POLYDATA -POINTS 8 float --1.0 -1.0 -1.0 --1.0 -1.0 1.0 --1.0 1.0 -1.0 --1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -POLYGONS 6 30 -4 0 1 3 2 -4 0 2 6 4 -4 4 6 7 5 -4 1 5 7 3 -4 0 4 5 1 -4 6 2 3 7 diff --git a/tests/control/polyhedron.x3d b/tests/control/polyhedron.x3d deleted file mode 100644 index 727efcb4..00000000 --- a/tests/control/polyhedron.x3d +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file From 3332048164e564c087571ff2553b6507dba409da Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 12 Sep 2024 13:07:26 -0400 Subject: [PATCH 43/58] Create new control files --- tests/control/convex_polyhedron.html | 1 + tests/control/convex_polyhedron.obj | 18 ++++++ tests/control/convex_polyhedron.off | 18 ++++++ tests/control/convex_polyhedron.ply | 25 ++++++++ tests/control/convex_polyhedron.stl | 86 ++++++++++++++++++++++++++++ tests/control/convex_polyhedron.vtk | 20 +++++++ tests/control/convex_polyhedron.x3d | 1 + tests/control/polyhedron.html | 1 + tests/control/polyhedron.obj | 18 ++++++ tests/control/polyhedron.off | 18 ++++++ tests/control/polyhedron.ply | 25 ++++++++ tests/control/polyhedron.stl | 86 ++++++++++++++++++++++++++++ tests/control/polyhedron.vtk | 20 +++++++ tests/control/polyhedron.x3d | 1 + 14 files changed, 338 insertions(+) create mode 100644 tests/control/convex_polyhedron.html create mode 100644 tests/control/convex_polyhedron.obj create mode 100644 tests/control/convex_polyhedron.off create mode 100644 tests/control/convex_polyhedron.ply create mode 100644 tests/control/convex_polyhedron.stl create mode 100644 tests/control/convex_polyhedron.vtk create mode 100644 tests/control/convex_polyhedron.x3d create mode 100644 tests/control/polyhedron.html create mode 100644 tests/control/polyhedron.obj create mode 100644 tests/control/polyhedron.off create mode 100644 tests/control/polyhedron.ply create mode 100644 tests/control/polyhedron.stl create mode 100644 tests/control/polyhedron.vtk create mode 100644 tests/control/polyhedron.x3d diff --git a/tests/control/convex_polyhedron.html b/tests/control/convex_polyhedron.html new file mode 100644 index 00000000..f27b53d1 --- /dev/null +++ b/tests/control/convex_polyhedron.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/control/convex_polyhedron.obj b/tests/control/convex_polyhedron.obj new file mode 100644 index 00000000..ed5a19cb --- /dev/null +++ b/tests/control/convex_polyhedron.obj @@ -0,0 +1,18 @@ +# wavefront obj file written by Coxeter version 0.7.0 +# ConvexPolyhedron + +v -1.0 -1.0 -1.0 +v -1.0 -1.0 1.0 +v -1.0 1.0 -1.0 +v -1.0 1.0 1.0 +v 1.0 -1.0 -1.0 +v 1.0 -1.0 1.0 +v 1.0 1.0 -1.0 +v 1.0 1.0 1.0 + +f 1 3 7 5 +f 1 5 6 2 +f 5 7 8 6 +f 1 2 4 3 +f 3 4 8 7 +f 2 6 8 4 diff --git a/tests/control/convex_polyhedron.off b/tests/control/convex_polyhedron.off new file mode 100644 index 00000000..48c3bd25 --- /dev/null +++ b/tests/control/convex_polyhedron.off @@ -0,0 +1,18 @@ +OFF +# OFF file written by Coxeter version 0.7.0 +# ConvexPolyhedron +8 f6 12 +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +4 0 2 6 4 +4 0 4 5 1 +4 4 6 7 5 +4 0 1 3 2 +4 2 3 7 6 +4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.ply b/tests/control/convex_polyhedron.ply new file mode 100644 index 00000000..622eb5f5 --- /dev/null +++ b/tests/control/convex_polyhedron.ply @@ -0,0 +1,25 @@ +ply +format ascii 1.0 +comment PLY file written by Coxeter version 0.7.0 +comment ConvexPolyhedron +element vertex 8 +property float x +property float y +property float z +element face 6 +property list uchar uint vertex_indices +end_header +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +4 0 2 6 4 +4 0 4 5 1 +4 4 6 7 5 +4 0 1 3 2 +4 2 3 7 6 +4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.stl b/tests/control/convex_polyhedron.stl new file mode 100644 index 00000000..9d9a416e --- /dev/null +++ b/tests/control/convex_polyhedron.stl @@ -0,0 +1,86 @@ +solid ConvexPolyhedron +facet normal 0.0 0.0 -4.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 1.0 -1.0 + vertex 1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 0.0 -4.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 1.0 -1.0 + vertex 1.0 -1.0 -1.0 + endloop +endfacet +facet normal 0.0 -4.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 -1.0 -1.0 + vertex 1.0 -1.0 1.0 + endloop +endfacet +facet normal 0.0 -4.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 -1.0 1.0 + vertex -1.0 -1.0 1.0 + endloop +endfacet +facet normal 4.0 0.0 0.0 + outer loop + vertex 1.0 -1.0 -1.0 + vertex 1.0 1.0 -1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal 4.0 0.0 -0.0 + outer loop + vertex 1.0 -1.0 -1.0 + vertex 1.0 1.0 1.0 + vertex 1.0 -1.0 1.0 + endloop +endfacet +facet normal -4.0 0.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 -1.0 1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +facet normal -4.0 0.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 1.0 1.0 + vertex -1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 4.0 0.0 + outer loop + vertex -1.0 1.0 -1.0 + vertex -1.0 1.0 1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal -0.0 4.0 0.0 + outer loop + vertex -1.0 1.0 -1.0 + vertex 1.0 1.0 1.0 + vertex 1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 0.0 4.0 + outer loop + vertex -1.0 -1.0 1.0 + vertex 1.0 -1.0 1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal 0.0 -0.0 4.0 + outer loop + vertex -1.0 -1.0 1.0 + vertex 1.0 1.0 1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +endsolid ConvexPolyhedron \ No newline at end of file diff --git a/tests/control/convex_polyhedron.vtk b/tests/control/convex_polyhedron.vtk new file mode 100644 index 00000000..34a23afd --- /dev/null +++ b/tests/control/convex_polyhedron.vtk @@ -0,0 +1,20 @@ +# vtk DataFile Version 3.0 +ConvexPolyhedron created by Coxeter version 0.7.0 +ASCII +DATASET POLYDATA +POINTS 8 float +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +POLYGONS 6 30 +4 0 2 6 4 +4 0 4 5 1 +4 4 6 7 5 +4 0 1 3 2 +4 2 3 7 6 +4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.x3d b/tests/control/convex_polyhedron.x3d new file mode 100644 index 00000000..d673d9e4 --- /dev/null +++ b/tests/control/convex_polyhedron.x3d @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/control/polyhedron.html b/tests/control/polyhedron.html new file mode 100644 index 00000000..3c4d4187 --- /dev/null +++ b/tests/control/polyhedron.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/control/polyhedron.obj b/tests/control/polyhedron.obj new file mode 100644 index 00000000..26f336ce --- /dev/null +++ b/tests/control/polyhedron.obj @@ -0,0 +1,18 @@ +# wavefront obj file written by Coxeter version 0.7.0 +# Polyhedron + +v -1.0 -1.0 -1.0 +v -1.0 -1.0 1.0 +v -1.0 1.0 -1.0 +v -1.0 1.0 1.0 +v 1.0 -1.0 -1.0 +v 1.0 -1.0 1.0 +v 1.0 1.0 -1.0 +v 1.0 1.0 1.0 + +f 1 2 4 3 +f 1 3 7 5 +f 5 7 8 6 +f 2 6 8 4 +f 1 5 6 2 +f 7 3 4 8 diff --git a/tests/control/polyhedron.off b/tests/control/polyhedron.off new file mode 100644 index 00000000..2c948353 --- /dev/null +++ b/tests/control/polyhedron.off @@ -0,0 +1,18 @@ +OFF +# OFF file written by Coxeter version 0.7.0 +# Polyhedron +8 f6 12 +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +4 0 1 3 2 +4 0 2 6 4 +4 4 6 7 5 +4 1 5 7 3 +4 0 4 5 1 +4 6 2 3 7 diff --git a/tests/control/polyhedron.ply b/tests/control/polyhedron.ply new file mode 100644 index 00000000..f5cd5e56 --- /dev/null +++ b/tests/control/polyhedron.ply @@ -0,0 +1,25 @@ +ply +format ascii 1.0 +comment PLY file written by Coxeter version 0.7.0 +comment Polyhedron +element vertex 8 +property float x +property float y +property float z +element face 6 +property list uchar uint vertex_indices +end_header +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +4 0 1 3 2 +4 0 2 6 4 +4 4 6 7 5 +4 1 5 7 3 +4 0 4 5 1 +4 6 2 3 7 diff --git a/tests/control/polyhedron.stl b/tests/control/polyhedron.stl new file mode 100644 index 00000000..36280262 --- /dev/null +++ b/tests/control/polyhedron.stl @@ -0,0 +1,86 @@ +solid Polyhedron +facet normal -4.0 0.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 -1.0 1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +facet normal -4.0 0.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 1.0 1.0 + vertex -1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 0.0 -4.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 1.0 -1.0 + vertex 1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 0.0 -4.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 1.0 -1.0 + vertex 1.0 -1.0 -1.0 + endloop +endfacet +facet normal 4.0 0.0 0.0 + outer loop + vertex 1.0 -1.0 -1.0 + vertex 1.0 1.0 -1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal 4.0 0.0 -0.0 + outer loop + vertex 1.0 -1.0 -1.0 + vertex 1.0 1.0 1.0 + vertex 1.0 -1.0 1.0 + endloop +endfacet +facet normal 0.0 0.0 4.0 + outer loop + vertex -1.0 -1.0 1.0 + vertex 1.0 -1.0 1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal 0.0 -0.0 4.0 + outer loop + vertex -1.0 -1.0 1.0 + vertex 1.0 1.0 1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +facet normal 0.0 -4.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 -1.0 -1.0 + vertex 1.0 -1.0 1.0 + endloop +endfacet +facet normal 0.0 -4.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 -1.0 1.0 + vertex -1.0 -1.0 1.0 + endloop +endfacet +facet normal 0.0 4.0 -0.0 + outer loop + vertex 1.0 1.0 -1.0 + vertex -1.0 1.0 -1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +facet normal 0.0 4.0 -0.0 + outer loop + vertex 1.0 1.0 -1.0 + vertex -1.0 1.0 1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +endsolid Polyhedron \ No newline at end of file diff --git a/tests/control/polyhedron.vtk b/tests/control/polyhedron.vtk new file mode 100644 index 00000000..d2920cbf --- /dev/null +++ b/tests/control/polyhedron.vtk @@ -0,0 +1,20 @@ +# vtk DataFile Version 3.0 +Polyhedron created by Coxeter version 0.7.0 +ASCII +DATASET POLYDATA +POINTS 8 float +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +POLYGONS 6 30 +4 0 1 3 2 +4 0 2 6 4 +4 4 6 7 5 +4 1 5 7 3 +4 0 4 5 1 +4 6 2 3 7 diff --git a/tests/control/polyhedron.x3d b/tests/control/polyhedron.x3d new file mode 100644 index 00000000..727efcb4 --- /dev/null +++ b/tests/control/polyhedron.x3d @@ -0,0 +1 @@ + \ No newline at end of file From bc7263c66730a1a7683f9afa7fe2cadd6a0ad8b9 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 12 Sep 2024 13:09:31 -0400 Subject: [PATCH 44/58] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fe0a677a..1815bd1c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: - id: end-of-file-fixer exclude: ^tests/control/ - id: trailing-whitespace - exclude: '(?:setup.cfg.*|paper/.*)' + exclude: '(?:setup.cfg.*|paper/.*)|^tests/control/' - id: debug-statements - id: check-builtin-literals - id: check-executables-have-shebangs From b5c05bb0ac1aaddaa1b9dc265fc7d7efee876e53 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 12 Sep 2024 13:09:49 -0400 Subject: [PATCH 45/58] Delete new control files --- tests/control/convex_polyhedron.html | 1 - tests/control/convex_polyhedron.obj | 18 ------ tests/control/convex_polyhedron.off | 18 ------ tests/control/convex_polyhedron.ply | 25 -------- tests/control/convex_polyhedron.stl | 86 ---------------------------- tests/control/convex_polyhedron.vtk | 20 ------- tests/control/convex_polyhedron.x3d | 1 - tests/control/polyhedron.html | 1 - tests/control/polyhedron.obj | 18 ------ tests/control/polyhedron.off | 18 ------ tests/control/polyhedron.ply | 25 -------- tests/control/polyhedron.stl | 86 ---------------------------- tests/control/polyhedron.vtk | 20 ------- tests/control/polyhedron.x3d | 1 - 14 files changed, 338 deletions(-) delete mode 100644 tests/control/convex_polyhedron.html delete mode 100644 tests/control/convex_polyhedron.obj delete mode 100644 tests/control/convex_polyhedron.off delete mode 100644 tests/control/convex_polyhedron.ply delete mode 100644 tests/control/convex_polyhedron.stl delete mode 100644 tests/control/convex_polyhedron.vtk delete mode 100644 tests/control/convex_polyhedron.x3d delete mode 100644 tests/control/polyhedron.html delete mode 100644 tests/control/polyhedron.obj delete mode 100644 tests/control/polyhedron.off delete mode 100644 tests/control/polyhedron.ply delete mode 100644 tests/control/polyhedron.stl delete mode 100644 tests/control/polyhedron.vtk delete mode 100644 tests/control/polyhedron.x3d diff --git a/tests/control/convex_polyhedron.html b/tests/control/convex_polyhedron.html deleted file mode 100644 index f27b53d1..00000000 --- a/tests/control/convex_polyhedron.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tests/control/convex_polyhedron.obj b/tests/control/convex_polyhedron.obj deleted file mode 100644 index ed5a19cb..00000000 --- a/tests/control/convex_polyhedron.obj +++ /dev/null @@ -1,18 +0,0 @@ -# wavefront obj file written by Coxeter version 0.7.0 -# ConvexPolyhedron - -v -1.0 -1.0 -1.0 -v -1.0 -1.0 1.0 -v -1.0 1.0 -1.0 -v -1.0 1.0 1.0 -v 1.0 -1.0 -1.0 -v 1.0 -1.0 1.0 -v 1.0 1.0 -1.0 -v 1.0 1.0 1.0 - -f 1 3 7 5 -f 1 5 6 2 -f 5 7 8 6 -f 1 2 4 3 -f 3 4 8 7 -f 2 6 8 4 diff --git a/tests/control/convex_polyhedron.off b/tests/control/convex_polyhedron.off deleted file mode 100644 index 48c3bd25..00000000 --- a/tests/control/convex_polyhedron.off +++ /dev/null @@ -1,18 +0,0 @@ -OFF -# OFF file written by Coxeter version 0.7.0 -# ConvexPolyhedron -8 f6 12 --1.0 -1.0 -1.0 --1.0 -1.0 1.0 --1.0 1.0 -1.0 --1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -4 0 2 6 4 -4 0 4 5 1 -4 4 6 7 5 -4 0 1 3 2 -4 2 3 7 6 -4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.ply b/tests/control/convex_polyhedron.ply deleted file mode 100644 index 622eb5f5..00000000 --- a/tests/control/convex_polyhedron.ply +++ /dev/null @@ -1,25 +0,0 @@ -ply -format ascii 1.0 -comment PLY file written by Coxeter version 0.7.0 -comment ConvexPolyhedron -element vertex 8 -property float x -property float y -property float z -element face 6 -property list uchar uint vertex_indices -end_header --1.0 -1.0 -1.0 --1.0 -1.0 1.0 --1.0 1.0 -1.0 --1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -4 0 2 6 4 -4 0 4 5 1 -4 4 6 7 5 -4 0 1 3 2 -4 2 3 7 6 -4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.stl b/tests/control/convex_polyhedron.stl deleted file mode 100644 index 9d9a416e..00000000 --- a/tests/control/convex_polyhedron.stl +++ /dev/null @@ -1,86 +0,0 @@ -solid ConvexPolyhedron -facet normal 0.0 0.0 -4.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex -1.0 1.0 -1.0 - vertex 1.0 1.0 -1.0 - endloop -endfacet -facet normal 0.0 0.0 -4.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex 1.0 1.0 -1.0 - vertex 1.0 -1.0 -1.0 - endloop -endfacet -facet normal 0.0 -4.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex 1.0 -1.0 -1.0 - vertex 1.0 -1.0 1.0 - endloop -endfacet -facet normal 0.0 -4.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex 1.0 -1.0 1.0 - vertex -1.0 -1.0 1.0 - endloop -endfacet -facet normal 4.0 0.0 0.0 - outer loop - vertex 1.0 -1.0 -1.0 - vertex 1.0 1.0 -1.0 - vertex 1.0 1.0 1.0 - endloop -endfacet -facet normal 4.0 0.0 -0.0 - outer loop - vertex 1.0 -1.0 -1.0 - vertex 1.0 1.0 1.0 - vertex 1.0 -1.0 1.0 - endloop -endfacet -facet normal -4.0 0.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex -1.0 -1.0 1.0 - vertex -1.0 1.0 1.0 - endloop -endfacet -facet normal -4.0 0.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex -1.0 1.0 1.0 - vertex -1.0 1.0 -1.0 - endloop -endfacet -facet normal 0.0 4.0 0.0 - outer loop - vertex -1.0 1.0 -1.0 - vertex -1.0 1.0 1.0 - vertex 1.0 1.0 1.0 - endloop -endfacet -facet normal -0.0 4.0 0.0 - outer loop - vertex -1.0 1.0 -1.0 - vertex 1.0 1.0 1.0 - vertex 1.0 1.0 -1.0 - endloop -endfacet -facet normal 0.0 0.0 4.0 - outer loop - vertex -1.0 -1.0 1.0 - vertex 1.0 -1.0 1.0 - vertex 1.0 1.0 1.0 - endloop -endfacet -facet normal 0.0 -0.0 4.0 - outer loop - vertex -1.0 -1.0 1.0 - vertex 1.0 1.0 1.0 - vertex -1.0 1.0 1.0 - endloop -endfacet -endsolid ConvexPolyhedron \ No newline at end of file diff --git a/tests/control/convex_polyhedron.vtk b/tests/control/convex_polyhedron.vtk deleted file mode 100644 index 34a23afd..00000000 --- a/tests/control/convex_polyhedron.vtk +++ /dev/null @@ -1,20 +0,0 @@ -# vtk DataFile Version 3.0 -ConvexPolyhedron created by Coxeter version 0.7.0 -ASCII -DATASET POLYDATA -POINTS 8 float --1.0 -1.0 -1.0 --1.0 -1.0 1.0 --1.0 1.0 -1.0 --1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -POLYGONS 6 30 -4 0 2 6 4 -4 0 4 5 1 -4 4 6 7 5 -4 0 1 3 2 -4 2 3 7 6 -4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.x3d b/tests/control/convex_polyhedron.x3d deleted file mode 100644 index d673d9e4..00000000 --- a/tests/control/convex_polyhedron.x3d +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tests/control/polyhedron.html b/tests/control/polyhedron.html deleted file mode 100644 index 3c4d4187..00000000 --- a/tests/control/polyhedron.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tests/control/polyhedron.obj b/tests/control/polyhedron.obj deleted file mode 100644 index 26f336ce..00000000 --- a/tests/control/polyhedron.obj +++ /dev/null @@ -1,18 +0,0 @@ -# wavefront obj file written by Coxeter version 0.7.0 -# Polyhedron - -v -1.0 -1.0 -1.0 -v -1.0 -1.0 1.0 -v -1.0 1.0 -1.0 -v -1.0 1.0 1.0 -v 1.0 -1.0 -1.0 -v 1.0 -1.0 1.0 -v 1.0 1.0 -1.0 -v 1.0 1.0 1.0 - -f 1 2 4 3 -f 1 3 7 5 -f 5 7 8 6 -f 2 6 8 4 -f 1 5 6 2 -f 7 3 4 8 diff --git a/tests/control/polyhedron.off b/tests/control/polyhedron.off deleted file mode 100644 index 2c948353..00000000 --- a/tests/control/polyhedron.off +++ /dev/null @@ -1,18 +0,0 @@ -OFF -# OFF file written by Coxeter version 0.7.0 -# Polyhedron -8 f6 12 --1.0 -1.0 -1.0 --1.0 -1.0 1.0 --1.0 1.0 -1.0 --1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -4 0 1 3 2 -4 0 2 6 4 -4 4 6 7 5 -4 1 5 7 3 -4 0 4 5 1 -4 6 2 3 7 diff --git a/tests/control/polyhedron.ply b/tests/control/polyhedron.ply deleted file mode 100644 index f5cd5e56..00000000 --- a/tests/control/polyhedron.ply +++ /dev/null @@ -1,25 +0,0 @@ -ply -format ascii 1.0 -comment PLY file written by Coxeter version 0.7.0 -comment Polyhedron -element vertex 8 -property float x -property float y -property float z -element face 6 -property list uchar uint vertex_indices -end_header --1.0 -1.0 -1.0 --1.0 -1.0 1.0 --1.0 1.0 -1.0 --1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -4 0 1 3 2 -4 0 2 6 4 -4 4 6 7 5 -4 1 5 7 3 -4 0 4 5 1 -4 6 2 3 7 diff --git a/tests/control/polyhedron.stl b/tests/control/polyhedron.stl deleted file mode 100644 index 36280262..00000000 --- a/tests/control/polyhedron.stl +++ /dev/null @@ -1,86 +0,0 @@ -solid Polyhedron -facet normal -4.0 0.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex -1.0 -1.0 1.0 - vertex -1.0 1.0 1.0 - endloop -endfacet -facet normal -4.0 0.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex -1.0 1.0 1.0 - vertex -1.0 1.0 -1.0 - endloop -endfacet -facet normal 0.0 0.0 -4.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex -1.0 1.0 -1.0 - vertex 1.0 1.0 -1.0 - endloop -endfacet -facet normal 0.0 0.0 -4.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex 1.0 1.0 -1.0 - vertex 1.0 -1.0 -1.0 - endloop -endfacet -facet normal 4.0 0.0 0.0 - outer loop - vertex 1.0 -1.0 -1.0 - vertex 1.0 1.0 -1.0 - vertex 1.0 1.0 1.0 - endloop -endfacet -facet normal 4.0 0.0 -0.0 - outer loop - vertex 1.0 -1.0 -1.0 - vertex 1.0 1.0 1.0 - vertex 1.0 -1.0 1.0 - endloop -endfacet -facet normal 0.0 0.0 4.0 - outer loop - vertex -1.0 -1.0 1.0 - vertex 1.0 -1.0 1.0 - vertex 1.0 1.0 1.0 - endloop -endfacet -facet normal 0.0 -0.0 4.0 - outer loop - vertex -1.0 -1.0 1.0 - vertex 1.0 1.0 1.0 - vertex -1.0 1.0 1.0 - endloop -endfacet -facet normal 0.0 -4.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex 1.0 -1.0 -1.0 - vertex 1.0 -1.0 1.0 - endloop -endfacet -facet normal 0.0 -4.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex 1.0 -1.0 1.0 - vertex -1.0 -1.0 1.0 - endloop -endfacet -facet normal 0.0 4.0 -0.0 - outer loop - vertex 1.0 1.0 -1.0 - vertex -1.0 1.0 -1.0 - vertex -1.0 1.0 1.0 - endloop -endfacet -facet normal 0.0 4.0 -0.0 - outer loop - vertex 1.0 1.0 -1.0 - vertex -1.0 1.0 1.0 - vertex 1.0 1.0 1.0 - endloop -endfacet -endsolid Polyhedron \ No newline at end of file diff --git a/tests/control/polyhedron.vtk b/tests/control/polyhedron.vtk deleted file mode 100644 index d2920cbf..00000000 --- a/tests/control/polyhedron.vtk +++ /dev/null @@ -1,20 +0,0 @@ -# vtk DataFile Version 3.0 -Polyhedron created by Coxeter version 0.7.0 -ASCII -DATASET POLYDATA -POINTS 8 float --1.0 -1.0 -1.0 --1.0 -1.0 1.0 --1.0 1.0 -1.0 --1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -POLYGONS 6 30 -4 0 1 3 2 -4 0 2 6 4 -4 4 6 7 5 -4 1 5 7 3 -4 0 4 5 1 -4 6 2 3 7 diff --git a/tests/control/polyhedron.x3d b/tests/control/polyhedron.x3d deleted file mode 100644 index 727efcb4..00000000 --- a/tests/control/polyhedron.x3d +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file From e9e568a356e8468f7440a377d38cf0a5b4fc76c2 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 12 Sep 2024 13:10:19 -0400 Subject: [PATCH 46/58] Create new control files --- tests/control/convex_polyhedron.html | 1 + tests/control/convex_polyhedron.obj | 18 ++++++ tests/control/convex_polyhedron.off | 18 ++++++ tests/control/convex_polyhedron.ply | 25 ++++++++ tests/control/convex_polyhedron.stl | 86 ++++++++++++++++++++++++++++ tests/control/convex_polyhedron.vtk | 20 +++++++ tests/control/convex_polyhedron.x3d | 1 + tests/control/polyhedron.html | 1 + tests/control/polyhedron.obj | 18 ++++++ tests/control/polyhedron.off | 18 ++++++ tests/control/polyhedron.ply | 25 ++++++++ tests/control/polyhedron.stl | 86 ++++++++++++++++++++++++++++ tests/control/polyhedron.vtk | 20 +++++++ tests/control/polyhedron.x3d | 1 + 14 files changed, 338 insertions(+) create mode 100644 tests/control/convex_polyhedron.html create mode 100644 tests/control/convex_polyhedron.obj create mode 100644 tests/control/convex_polyhedron.off create mode 100644 tests/control/convex_polyhedron.ply create mode 100644 tests/control/convex_polyhedron.stl create mode 100644 tests/control/convex_polyhedron.vtk create mode 100644 tests/control/convex_polyhedron.x3d create mode 100644 tests/control/polyhedron.html create mode 100644 tests/control/polyhedron.obj create mode 100644 tests/control/polyhedron.off create mode 100644 tests/control/polyhedron.ply create mode 100644 tests/control/polyhedron.stl create mode 100644 tests/control/polyhedron.vtk create mode 100644 tests/control/polyhedron.x3d diff --git a/tests/control/convex_polyhedron.html b/tests/control/convex_polyhedron.html new file mode 100644 index 00000000..f27b53d1 --- /dev/null +++ b/tests/control/convex_polyhedron.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/control/convex_polyhedron.obj b/tests/control/convex_polyhedron.obj new file mode 100644 index 00000000..ed5a19cb --- /dev/null +++ b/tests/control/convex_polyhedron.obj @@ -0,0 +1,18 @@ +# wavefront obj file written by Coxeter version 0.7.0 +# ConvexPolyhedron + +v -1.0 -1.0 -1.0 +v -1.0 -1.0 1.0 +v -1.0 1.0 -1.0 +v -1.0 1.0 1.0 +v 1.0 -1.0 -1.0 +v 1.0 -1.0 1.0 +v 1.0 1.0 -1.0 +v 1.0 1.0 1.0 + +f 1 3 7 5 +f 1 5 6 2 +f 5 7 8 6 +f 1 2 4 3 +f 3 4 8 7 +f 2 6 8 4 diff --git a/tests/control/convex_polyhedron.off b/tests/control/convex_polyhedron.off new file mode 100644 index 00000000..48c3bd25 --- /dev/null +++ b/tests/control/convex_polyhedron.off @@ -0,0 +1,18 @@ +OFF +# OFF file written by Coxeter version 0.7.0 +# ConvexPolyhedron +8 f6 12 +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +4 0 2 6 4 +4 0 4 5 1 +4 4 6 7 5 +4 0 1 3 2 +4 2 3 7 6 +4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.ply b/tests/control/convex_polyhedron.ply new file mode 100644 index 00000000..622eb5f5 --- /dev/null +++ b/tests/control/convex_polyhedron.ply @@ -0,0 +1,25 @@ +ply +format ascii 1.0 +comment PLY file written by Coxeter version 0.7.0 +comment ConvexPolyhedron +element vertex 8 +property float x +property float y +property float z +element face 6 +property list uchar uint vertex_indices +end_header +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +4 0 2 6 4 +4 0 4 5 1 +4 4 6 7 5 +4 0 1 3 2 +4 2 3 7 6 +4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.stl b/tests/control/convex_polyhedron.stl new file mode 100644 index 00000000..9d9a416e --- /dev/null +++ b/tests/control/convex_polyhedron.stl @@ -0,0 +1,86 @@ +solid ConvexPolyhedron +facet normal 0.0 0.0 -4.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 1.0 -1.0 + vertex 1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 0.0 -4.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 1.0 -1.0 + vertex 1.0 -1.0 -1.0 + endloop +endfacet +facet normal 0.0 -4.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 -1.0 -1.0 + vertex 1.0 -1.0 1.0 + endloop +endfacet +facet normal 0.0 -4.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 -1.0 1.0 + vertex -1.0 -1.0 1.0 + endloop +endfacet +facet normal 4.0 0.0 0.0 + outer loop + vertex 1.0 -1.0 -1.0 + vertex 1.0 1.0 -1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal 4.0 0.0 -0.0 + outer loop + vertex 1.0 -1.0 -1.0 + vertex 1.0 1.0 1.0 + vertex 1.0 -1.0 1.0 + endloop +endfacet +facet normal -4.0 0.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 -1.0 1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +facet normal -4.0 0.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 1.0 1.0 + vertex -1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 4.0 0.0 + outer loop + vertex -1.0 1.0 -1.0 + vertex -1.0 1.0 1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal -0.0 4.0 0.0 + outer loop + vertex -1.0 1.0 -1.0 + vertex 1.0 1.0 1.0 + vertex 1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 0.0 4.0 + outer loop + vertex -1.0 -1.0 1.0 + vertex 1.0 -1.0 1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal 0.0 -0.0 4.0 + outer loop + vertex -1.0 -1.0 1.0 + vertex 1.0 1.0 1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +endsolid ConvexPolyhedron \ No newline at end of file diff --git a/tests/control/convex_polyhedron.vtk b/tests/control/convex_polyhedron.vtk new file mode 100644 index 00000000..34a23afd --- /dev/null +++ b/tests/control/convex_polyhedron.vtk @@ -0,0 +1,20 @@ +# vtk DataFile Version 3.0 +ConvexPolyhedron created by Coxeter version 0.7.0 +ASCII +DATASET POLYDATA +POINTS 8 float +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +POLYGONS 6 30 +4 0 2 6 4 +4 0 4 5 1 +4 4 6 7 5 +4 0 1 3 2 +4 2 3 7 6 +4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.x3d b/tests/control/convex_polyhedron.x3d new file mode 100644 index 00000000..d673d9e4 --- /dev/null +++ b/tests/control/convex_polyhedron.x3d @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/control/polyhedron.html b/tests/control/polyhedron.html new file mode 100644 index 00000000..3c4d4187 --- /dev/null +++ b/tests/control/polyhedron.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/control/polyhedron.obj b/tests/control/polyhedron.obj new file mode 100644 index 00000000..26f336ce --- /dev/null +++ b/tests/control/polyhedron.obj @@ -0,0 +1,18 @@ +# wavefront obj file written by Coxeter version 0.7.0 +# Polyhedron + +v -1.0 -1.0 -1.0 +v -1.0 -1.0 1.0 +v -1.0 1.0 -1.0 +v -1.0 1.0 1.0 +v 1.0 -1.0 -1.0 +v 1.0 -1.0 1.0 +v 1.0 1.0 -1.0 +v 1.0 1.0 1.0 + +f 1 2 4 3 +f 1 3 7 5 +f 5 7 8 6 +f 2 6 8 4 +f 1 5 6 2 +f 7 3 4 8 diff --git a/tests/control/polyhedron.off b/tests/control/polyhedron.off new file mode 100644 index 00000000..2c948353 --- /dev/null +++ b/tests/control/polyhedron.off @@ -0,0 +1,18 @@ +OFF +# OFF file written by Coxeter version 0.7.0 +# Polyhedron +8 f6 12 +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +4 0 1 3 2 +4 0 2 6 4 +4 4 6 7 5 +4 1 5 7 3 +4 0 4 5 1 +4 6 2 3 7 diff --git a/tests/control/polyhedron.ply b/tests/control/polyhedron.ply new file mode 100644 index 00000000..f5cd5e56 --- /dev/null +++ b/tests/control/polyhedron.ply @@ -0,0 +1,25 @@ +ply +format ascii 1.0 +comment PLY file written by Coxeter version 0.7.0 +comment Polyhedron +element vertex 8 +property float x +property float y +property float z +element face 6 +property list uchar uint vertex_indices +end_header +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +4 0 1 3 2 +4 0 2 6 4 +4 4 6 7 5 +4 1 5 7 3 +4 0 4 5 1 +4 6 2 3 7 diff --git a/tests/control/polyhedron.stl b/tests/control/polyhedron.stl new file mode 100644 index 00000000..36280262 --- /dev/null +++ b/tests/control/polyhedron.stl @@ -0,0 +1,86 @@ +solid Polyhedron +facet normal -4.0 0.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 -1.0 1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +facet normal -4.0 0.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 1.0 1.0 + vertex -1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 0.0 -4.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 1.0 -1.0 + vertex 1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 0.0 -4.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 1.0 -1.0 + vertex 1.0 -1.0 -1.0 + endloop +endfacet +facet normal 4.0 0.0 0.0 + outer loop + vertex 1.0 -1.0 -1.0 + vertex 1.0 1.0 -1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal 4.0 0.0 -0.0 + outer loop + vertex 1.0 -1.0 -1.0 + vertex 1.0 1.0 1.0 + vertex 1.0 -1.0 1.0 + endloop +endfacet +facet normal 0.0 0.0 4.0 + outer loop + vertex -1.0 -1.0 1.0 + vertex 1.0 -1.0 1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal 0.0 -0.0 4.0 + outer loop + vertex -1.0 -1.0 1.0 + vertex 1.0 1.0 1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +facet normal 0.0 -4.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 -1.0 -1.0 + vertex 1.0 -1.0 1.0 + endloop +endfacet +facet normal 0.0 -4.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 -1.0 1.0 + vertex -1.0 -1.0 1.0 + endloop +endfacet +facet normal 0.0 4.0 -0.0 + outer loop + vertex 1.0 1.0 -1.0 + vertex -1.0 1.0 -1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +facet normal 0.0 4.0 -0.0 + outer loop + vertex 1.0 1.0 -1.0 + vertex -1.0 1.0 1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +endsolid Polyhedron \ No newline at end of file diff --git a/tests/control/polyhedron.vtk b/tests/control/polyhedron.vtk new file mode 100644 index 00000000..d2920cbf --- /dev/null +++ b/tests/control/polyhedron.vtk @@ -0,0 +1,20 @@ +# vtk DataFile Version 3.0 +Polyhedron created by Coxeter version 0.7.0 +ASCII +DATASET POLYDATA +POINTS 8 float +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +POLYGONS 6 30 +4 0 1 3 2 +4 0 2 6 4 +4 4 6 7 5 +4 1 5 7 3 +4 0 4 5 1 +4 6 2 3 7 diff --git a/tests/control/polyhedron.x3d b/tests/control/polyhedron.x3d new file mode 100644 index 00000000..727efcb4 --- /dev/null +++ b/tests/control/polyhedron.x3d @@ -0,0 +1 @@ + \ No newline at end of file From 69c037793c80db1d2fe9ad8efa4e7e3053ba682b Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 12 Sep 2024 13:12:09 -0400 Subject: [PATCH 47/58] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1815bd1c..a30b6491 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,9 +6,9 @@ repos: rev: 'v4.6.0' hooks: - id: end-of-file-fixer - exclude: ^tests/control/ + exclude: '^tests/control/*' - id: trailing-whitespace - exclude: '(?:setup.cfg.*|paper/.*)|^tests/control/' + exclude: '(?:setup.cfg.*|paper/.*)|^tests/control/*' - id: debug-statements - id: check-builtin-literals - id: check-executables-have-shebangs From 8955118ac8cc375ef690b73b0ed579b9f4457926 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 12 Sep 2024 13:13:08 -0400 Subject: [PATCH 48/58] Delete new control files --- tests/control/convex_polyhedron.html | 1 - tests/control/convex_polyhedron.obj | 18 ------ tests/control/convex_polyhedron.off | 18 ------ tests/control/convex_polyhedron.ply | 25 -------- tests/control/convex_polyhedron.stl | 86 ---------------------------- tests/control/convex_polyhedron.vtk | 20 ------- tests/control/convex_polyhedron.x3d | 1 - tests/control/polyhedron.html | 1 - tests/control/polyhedron.obj | 18 ------ tests/control/polyhedron.off | 18 ------ tests/control/polyhedron.ply | 25 -------- tests/control/polyhedron.stl | 86 ---------------------------- tests/control/polyhedron.vtk | 20 ------- tests/control/polyhedron.x3d | 1 - 14 files changed, 338 deletions(-) delete mode 100644 tests/control/convex_polyhedron.html delete mode 100644 tests/control/convex_polyhedron.obj delete mode 100644 tests/control/convex_polyhedron.off delete mode 100644 tests/control/convex_polyhedron.ply delete mode 100644 tests/control/convex_polyhedron.stl delete mode 100644 tests/control/convex_polyhedron.vtk delete mode 100644 tests/control/convex_polyhedron.x3d delete mode 100644 tests/control/polyhedron.html delete mode 100644 tests/control/polyhedron.obj delete mode 100644 tests/control/polyhedron.off delete mode 100644 tests/control/polyhedron.ply delete mode 100644 tests/control/polyhedron.stl delete mode 100644 tests/control/polyhedron.vtk delete mode 100644 tests/control/polyhedron.x3d diff --git a/tests/control/convex_polyhedron.html b/tests/control/convex_polyhedron.html deleted file mode 100644 index f27b53d1..00000000 --- a/tests/control/convex_polyhedron.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tests/control/convex_polyhedron.obj b/tests/control/convex_polyhedron.obj deleted file mode 100644 index ed5a19cb..00000000 --- a/tests/control/convex_polyhedron.obj +++ /dev/null @@ -1,18 +0,0 @@ -# wavefront obj file written by Coxeter version 0.7.0 -# ConvexPolyhedron - -v -1.0 -1.0 -1.0 -v -1.0 -1.0 1.0 -v -1.0 1.0 -1.0 -v -1.0 1.0 1.0 -v 1.0 -1.0 -1.0 -v 1.0 -1.0 1.0 -v 1.0 1.0 -1.0 -v 1.0 1.0 1.0 - -f 1 3 7 5 -f 1 5 6 2 -f 5 7 8 6 -f 1 2 4 3 -f 3 4 8 7 -f 2 6 8 4 diff --git a/tests/control/convex_polyhedron.off b/tests/control/convex_polyhedron.off deleted file mode 100644 index 48c3bd25..00000000 --- a/tests/control/convex_polyhedron.off +++ /dev/null @@ -1,18 +0,0 @@ -OFF -# OFF file written by Coxeter version 0.7.0 -# ConvexPolyhedron -8 f6 12 --1.0 -1.0 -1.0 --1.0 -1.0 1.0 --1.0 1.0 -1.0 --1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -4 0 2 6 4 -4 0 4 5 1 -4 4 6 7 5 -4 0 1 3 2 -4 2 3 7 6 -4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.ply b/tests/control/convex_polyhedron.ply deleted file mode 100644 index 622eb5f5..00000000 --- a/tests/control/convex_polyhedron.ply +++ /dev/null @@ -1,25 +0,0 @@ -ply -format ascii 1.0 -comment PLY file written by Coxeter version 0.7.0 -comment ConvexPolyhedron -element vertex 8 -property float x -property float y -property float z -element face 6 -property list uchar uint vertex_indices -end_header --1.0 -1.0 -1.0 --1.0 -1.0 1.0 --1.0 1.0 -1.0 --1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -4 0 2 6 4 -4 0 4 5 1 -4 4 6 7 5 -4 0 1 3 2 -4 2 3 7 6 -4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.stl b/tests/control/convex_polyhedron.stl deleted file mode 100644 index 9d9a416e..00000000 --- a/tests/control/convex_polyhedron.stl +++ /dev/null @@ -1,86 +0,0 @@ -solid ConvexPolyhedron -facet normal 0.0 0.0 -4.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex -1.0 1.0 -1.0 - vertex 1.0 1.0 -1.0 - endloop -endfacet -facet normal 0.0 0.0 -4.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex 1.0 1.0 -1.0 - vertex 1.0 -1.0 -1.0 - endloop -endfacet -facet normal 0.0 -4.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex 1.0 -1.0 -1.0 - vertex 1.0 -1.0 1.0 - endloop -endfacet -facet normal 0.0 -4.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex 1.0 -1.0 1.0 - vertex -1.0 -1.0 1.0 - endloop -endfacet -facet normal 4.0 0.0 0.0 - outer loop - vertex 1.0 -1.0 -1.0 - vertex 1.0 1.0 -1.0 - vertex 1.0 1.0 1.0 - endloop -endfacet -facet normal 4.0 0.0 -0.0 - outer loop - vertex 1.0 -1.0 -1.0 - vertex 1.0 1.0 1.0 - vertex 1.0 -1.0 1.0 - endloop -endfacet -facet normal -4.0 0.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex -1.0 -1.0 1.0 - vertex -1.0 1.0 1.0 - endloop -endfacet -facet normal -4.0 0.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex -1.0 1.0 1.0 - vertex -1.0 1.0 -1.0 - endloop -endfacet -facet normal 0.0 4.0 0.0 - outer loop - vertex -1.0 1.0 -1.0 - vertex -1.0 1.0 1.0 - vertex 1.0 1.0 1.0 - endloop -endfacet -facet normal -0.0 4.0 0.0 - outer loop - vertex -1.0 1.0 -1.0 - vertex 1.0 1.0 1.0 - vertex 1.0 1.0 -1.0 - endloop -endfacet -facet normal 0.0 0.0 4.0 - outer loop - vertex -1.0 -1.0 1.0 - vertex 1.0 -1.0 1.0 - vertex 1.0 1.0 1.0 - endloop -endfacet -facet normal 0.0 -0.0 4.0 - outer loop - vertex -1.0 -1.0 1.0 - vertex 1.0 1.0 1.0 - vertex -1.0 1.0 1.0 - endloop -endfacet -endsolid ConvexPolyhedron \ No newline at end of file diff --git a/tests/control/convex_polyhedron.vtk b/tests/control/convex_polyhedron.vtk deleted file mode 100644 index 34a23afd..00000000 --- a/tests/control/convex_polyhedron.vtk +++ /dev/null @@ -1,20 +0,0 @@ -# vtk DataFile Version 3.0 -ConvexPolyhedron created by Coxeter version 0.7.0 -ASCII -DATASET POLYDATA -POINTS 8 float --1.0 -1.0 -1.0 --1.0 -1.0 1.0 --1.0 1.0 -1.0 --1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -POLYGONS 6 30 -4 0 2 6 4 -4 0 4 5 1 -4 4 6 7 5 -4 0 1 3 2 -4 2 3 7 6 -4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.x3d b/tests/control/convex_polyhedron.x3d deleted file mode 100644 index d673d9e4..00000000 --- a/tests/control/convex_polyhedron.x3d +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tests/control/polyhedron.html b/tests/control/polyhedron.html deleted file mode 100644 index 3c4d4187..00000000 --- a/tests/control/polyhedron.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tests/control/polyhedron.obj b/tests/control/polyhedron.obj deleted file mode 100644 index 26f336ce..00000000 --- a/tests/control/polyhedron.obj +++ /dev/null @@ -1,18 +0,0 @@ -# wavefront obj file written by Coxeter version 0.7.0 -# Polyhedron - -v -1.0 -1.0 -1.0 -v -1.0 -1.0 1.0 -v -1.0 1.0 -1.0 -v -1.0 1.0 1.0 -v 1.0 -1.0 -1.0 -v 1.0 -1.0 1.0 -v 1.0 1.0 -1.0 -v 1.0 1.0 1.0 - -f 1 2 4 3 -f 1 3 7 5 -f 5 7 8 6 -f 2 6 8 4 -f 1 5 6 2 -f 7 3 4 8 diff --git a/tests/control/polyhedron.off b/tests/control/polyhedron.off deleted file mode 100644 index 2c948353..00000000 --- a/tests/control/polyhedron.off +++ /dev/null @@ -1,18 +0,0 @@ -OFF -# OFF file written by Coxeter version 0.7.0 -# Polyhedron -8 f6 12 --1.0 -1.0 -1.0 --1.0 -1.0 1.0 --1.0 1.0 -1.0 --1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -4 0 1 3 2 -4 0 2 6 4 -4 4 6 7 5 -4 1 5 7 3 -4 0 4 5 1 -4 6 2 3 7 diff --git a/tests/control/polyhedron.ply b/tests/control/polyhedron.ply deleted file mode 100644 index f5cd5e56..00000000 --- a/tests/control/polyhedron.ply +++ /dev/null @@ -1,25 +0,0 @@ -ply -format ascii 1.0 -comment PLY file written by Coxeter version 0.7.0 -comment Polyhedron -element vertex 8 -property float x -property float y -property float z -element face 6 -property list uchar uint vertex_indices -end_header --1.0 -1.0 -1.0 --1.0 -1.0 1.0 --1.0 1.0 -1.0 --1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -4 0 1 3 2 -4 0 2 6 4 -4 4 6 7 5 -4 1 5 7 3 -4 0 4 5 1 -4 6 2 3 7 diff --git a/tests/control/polyhedron.stl b/tests/control/polyhedron.stl deleted file mode 100644 index 36280262..00000000 --- a/tests/control/polyhedron.stl +++ /dev/null @@ -1,86 +0,0 @@ -solid Polyhedron -facet normal -4.0 0.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex -1.0 -1.0 1.0 - vertex -1.0 1.0 1.0 - endloop -endfacet -facet normal -4.0 0.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex -1.0 1.0 1.0 - vertex -1.0 1.0 -1.0 - endloop -endfacet -facet normal 0.0 0.0 -4.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex -1.0 1.0 -1.0 - vertex 1.0 1.0 -1.0 - endloop -endfacet -facet normal 0.0 0.0 -4.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex 1.0 1.0 -1.0 - vertex 1.0 -1.0 -1.0 - endloop -endfacet -facet normal 4.0 0.0 0.0 - outer loop - vertex 1.0 -1.0 -1.0 - vertex 1.0 1.0 -1.0 - vertex 1.0 1.0 1.0 - endloop -endfacet -facet normal 4.0 0.0 -0.0 - outer loop - vertex 1.0 -1.0 -1.0 - vertex 1.0 1.0 1.0 - vertex 1.0 -1.0 1.0 - endloop -endfacet -facet normal 0.0 0.0 4.0 - outer loop - vertex -1.0 -1.0 1.0 - vertex 1.0 -1.0 1.0 - vertex 1.0 1.0 1.0 - endloop -endfacet -facet normal 0.0 -0.0 4.0 - outer loop - vertex -1.0 -1.0 1.0 - vertex 1.0 1.0 1.0 - vertex -1.0 1.0 1.0 - endloop -endfacet -facet normal 0.0 -4.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex 1.0 -1.0 -1.0 - vertex 1.0 -1.0 1.0 - endloop -endfacet -facet normal 0.0 -4.0 0.0 - outer loop - vertex -1.0 -1.0 -1.0 - vertex 1.0 -1.0 1.0 - vertex -1.0 -1.0 1.0 - endloop -endfacet -facet normal 0.0 4.0 -0.0 - outer loop - vertex 1.0 1.0 -1.0 - vertex -1.0 1.0 -1.0 - vertex -1.0 1.0 1.0 - endloop -endfacet -facet normal 0.0 4.0 -0.0 - outer loop - vertex 1.0 1.0 -1.0 - vertex -1.0 1.0 1.0 - vertex 1.0 1.0 1.0 - endloop -endfacet -endsolid Polyhedron \ No newline at end of file diff --git a/tests/control/polyhedron.vtk b/tests/control/polyhedron.vtk deleted file mode 100644 index d2920cbf..00000000 --- a/tests/control/polyhedron.vtk +++ /dev/null @@ -1,20 +0,0 @@ -# vtk DataFile Version 3.0 -Polyhedron created by Coxeter version 0.7.0 -ASCII -DATASET POLYDATA -POINTS 8 float --1.0 -1.0 -1.0 --1.0 -1.0 1.0 --1.0 1.0 -1.0 --1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -POLYGONS 6 30 -4 0 1 3 2 -4 0 2 6 4 -4 4 6 7 5 -4 1 5 7 3 -4 0 4 5 1 -4 6 2 3 7 diff --git a/tests/control/polyhedron.x3d b/tests/control/polyhedron.x3d deleted file mode 100644 index 727efcb4..00000000 --- a/tests/control/polyhedron.x3d +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file From f956ddc68de28d9d9315bc2b09f1b9b4c2066440 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 12 Sep 2024 13:13:26 -0400 Subject: [PATCH 49/58] Create new control files --- tests/control/convex_polyhedron.html | 1 + tests/control/convex_polyhedron.obj | 18 ++++++ tests/control/convex_polyhedron.off | 18 ++++++ tests/control/convex_polyhedron.ply | 25 ++++++++ tests/control/convex_polyhedron.stl | 86 ++++++++++++++++++++++++++++ tests/control/convex_polyhedron.vtk | 20 +++++++ tests/control/convex_polyhedron.x3d | 1 + tests/control/polyhedron.html | 1 + tests/control/polyhedron.obj | 18 ++++++ tests/control/polyhedron.off | 18 ++++++ tests/control/polyhedron.ply | 25 ++++++++ tests/control/polyhedron.stl | 86 ++++++++++++++++++++++++++++ tests/control/polyhedron.vtk | 20 +++++++ tests/control/polyhedron.x3d | 1 + 14 files changed, 338 insertions(+) create mode 100644 tests/control/convex_polyhedron.html create mode 100644 tests/control/convex_polyhedron.obj create mode 100644 tests/control/convex_polyhedron.off create mode 100644 tests/control/convex_polyhedron.ply create mode 100644 tests/control/convex_polyhedron.stl create mode 100644 tests/control/convex_polyhedron.vtk create mode 100644 tests/control/convex_polyhedron.x3d create mode 100644 tests/control/polyhedron.html create mode 100644 tests/control/polyhedron.obj create mode 100644 tests/control/polyhedron.off create mode 100644 tests/control/polyhedron.ply create mode 100644 tests/control/polyhedron.stl create mode 100644 tests/control/polyhedron.vtk create mode 100644 tests/control/polyhedron.x3d diff --git a/tests/control/convex_polyhedron.html b/tests/control/convex_polyhedron.html new file mode 100644 index 00000000..f27b53d1 --- /dev/null +++ b/tests/control/convex_polyhedron.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/control/convex_polyhedron.obj b/tests/control/convex_polyhedron.obj new file mode 100644 index 00000000..ed5a19cb --- /dev/null +++ b/tests/control/convex_polyhedron.obj @@ -0,0 +1,18 @@ +# wavefront obj file written by Coxeter version 0.7.0 +# ConvexPolyhedron + +v -1.0 -1.0 -1.0 +v -1.0 -1.0 1.0 +v -1.0 1.0 -1.0 +v -1.0 1.0 1.0 +v 1.0 -1.0 -1.0 +v 1.0 -1.0 1.0 +v 1.0 1.0 -1.0 +v 1.0 1.0 1.0 + +f 1 3 7 5 +f 1 5 6 2 +f 5 7 8 6 +f 1 2 4 3 +f 3 4 8 7 +f 2 6 8 4 diff --git a/tests/control/convex_polyhedron.off b/tests/control/convex_polyhedron.off new file mode 100644 index 00000000..48c3bd25 --- /dev/null +++ b/tests/control/convex_polyhedron.off @@ -0,0 +1,18 @@ +OFF +# OFF file written by Coxeter version 0.7.0 +# ConvexPolyhedron +8 f6 12 +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +4 0 2 6 4 +4 0 4 5 1 +4 4 6 7 5 +4 0 1 3 2 +4 2 3 7 6 +4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.ply b/tests/control/convex_polyhedron.ply new file mode 100644 index 00000000..622eb5f5 --- /dev/null +++ b/tests/control/convex_polyhedron.ply @@ -0,0 +1,25 @@ +ply +format ascii 1.0 +comment PLY file written by Coxeter version 0.7.0 +comment ConvexPolyhedron +element vertex 8 +property float x +property float y +property float z +element face 6 +property list uchar uint vertex_indices +end_header +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +4 0 2 6 4 +4 0 4 5 1 +4 4 6 7 5 +4 0 1 3 2 +4 2 3 7 6 +4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.stl b/tests/control/convex_polyhedron.stl new file mode 100644 index 00000000..9d9a416e --- /dev/null +++ b/tests/control/convex_polyhedron.stl @@ -0,0 +1,86 @@ +solid ConvexPolyhedron +facet normal 0.0 0.0 -4.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 1.0 -1.0 + vertex 1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 0.0 -4.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 1.0 -1.0 + vertex 1.0 -1.0 -1.0 + endloop +endfacet +facet normal 0.0 -4.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 -1.0 -1.0 + vertex 1.0 -1.0 1.0 + endloop +endfacet +facet normal 0.0 -4.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 -1.0 1.0 + vertex -1.0 -1.0 1.0 + endloop +endfacet +facet normal 4.0 0.0 0.0 + outer loop + vertex 1.0 -1.0 -1.0 + vertex 1.0 1.0 -1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal 4.0 0.0 -0.0 + outer loop + vertex 1.0 -1.0 -1.0 + vertex 1.0 1.0 1.0 + vertex 1.0 -1.0 1.0 + endloop +endfacet +facet normal -4.0 0.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 -1.0 1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +facet normal -4.0 0.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 1.0 1.0 + vertex -1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 4.0 0.0 + outer loop + vertex -1.0 1.0 -1.0 + vertex -1.0 1.0 1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal -0.0 4.0 0.0 + outer loop + vertex -1.0 1.0 -1.0 + vertex 1.0 1.0 1.0 + vertex 1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 0.0 4.0 + outer loop + vertex -1.0 -1.0 1.0 + vertex 1.0 -1.0 1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal 0.0 -0.0 4.0 + outer loop + vertex -1.0 -1.0 1.0 + vertex 1.0 1.0 1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +endsolid ConvexPolyhedron \ No newline at end of file diff --git a/tests/control/convex_polyhedron.vtk b/tests/control/convex_polyhedron.vtk new file mode 100644 index 00000000..34a23afd --- /dev/null +++ b/tests/control/convex_polyhedron.vtk @@ -0,0 +1,20 @@ +# vtk DataFile Version 3.0 +ConvexPolyhedron created by Coxeter version 0.7.0 +ASCII +DATASET POLYDATA +POINTS 8 float +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +POLYGONS 6 30 +4 0 2 6 4 +4 0 4 5 1 +4 4 6 7 5 +4 0 1 3 2 +4 2 3 7 6 +4 1 5 7 3 diff --git a/tests/control/convex_polyhedron.x3d b/tests/control/convex_polyhedron.x3d new file mode 100644 index 00000000..d673d9e4 --- /dev/null +++ b/tests/control/convex_polyhedron.x3d @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/control/polyhedron.html b/tests/control/polyhedron.html new file mode 100644 index 00000000..3c4d4187 --- /dev/null +++ b/tests/control/polyhedron.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/control/polyhedron.obj b/tests/control/polyhedron.obj new file mode 100644 index 00000000..26f336ce --- /dev/null +++ b/tests/control/polyhedron.obj @@ -0,0 +1,18 @@ +# wavefront obj file written by Coxeter version 0.7.0 +# Polyhedron + +v -1.0 -1.0 -1.0 +v -1.0 -1.0 1.0 +v -1.0 1.0 -1.0 +v -1.0 1.0 1.0 +v 1.0 -1.0 -1.0 +v 1.0 -1.0 1.0 +v 1.0 1.0 -1.0 +v 1.0 1.0 1.0 + +f 1 2 4 3 +f 1 3 7 5 +f 5 7 8 6 +f 2 6 8 4 +f 1 5 6 2 +f 7 3 4 8 diff --git a/tests/control/polyhedron.off b/tests/control/polyhedron.off new file mode 100644 index 00000000..2c948353 --- /dev/null +++ b/tests/control/polyhedron.off @@ -0,0 +1,18 @@ +OFF +# OFF file written by Coxeter version 0.7.0 +# Polyhedron +8 f6 12 +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +4 0 1 3 2 +4 0 2 6 4 +4 4 6 7 5 +4 1 5 7 3 +4 0 4 5 1 +4 6 2 3 7 diff --git a/tests/control/polyhedron.ply b/tests/control/polyhedron.ply new file mode 100644 index 00000000..f5cd5e56 --- /dev/null +++ b/tests/control/polyhedron.ply @@ -0,0 +1,25 @@ +ply +format ascii 1.0 +comment PLY file written by Coxeter version 0.7.0 +comment Polyhedron +element vertex 8 +property float x +property float y +property float z +element face 6 +property list uchar uint vertex_indices +end_header +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +4 0 1 3 2 +4 0 2 6 4 +4 4 6 7 5 +4 1 5 7 3 +4 0 4 5 1 +4 6 2 3 7 diff --git a/tests/control/polyhedron.stl b/tests/control/polyhedron.stl new file mode 100644 index 00000000..36280262 --- /dev/null +++ b/tests/control/polyhedron.stl @@ -0,0 +1,86 @@ +solid Polyhedron +facet normal -4.0 0.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 -1.0 1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +facet normal -4.0 0.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 1.0 1.0 + vertex -1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 0.0 -4.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex -1.0 1.0 -1.0 + vertex 1.0 1.0 -1.0 + endloop +endfacet +facet normal 0.0 0.0 -4.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 1.0 -1.0 + vertex 1.0 -1.0 -1.0 + endloop +endfacet +facet normal 4.0 0.0 0.0 + outer loop + vertex 1.0 -1.0 -1.0 + vertex 1.0 1.0 -1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal 4.0 0.0 -0.0 + outer loop + vertex 1.0 -1.0 -1.0 + vertex 1.0 1.0 1.0 + vertex 1.0 -1.0 1.0 + endloop +endfacet +facet normal 0.0 0.0 4.0 + outer loop + vertex -1.0 -1.0 1.0 + vertex 1.0 -1.0 1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +facet normal 0.0 -0.0 4.0 + outer loop + vertex -1.0 -1.0 1.0 + vertex 1.0 1.0 1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +facet normal 0.0 -4.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 -1.0 -1.0 + vertex 1.0 -1.0 1.0 + endloop +endfacet +facet normal 0.0 -4.0 0.0 + outer loop + vertex -1.0 -1.0 -1.0 + vertex 1.0 -1.0 1.0 + vertex -1.0 -1.0 1.0 + endloop +endfacet +facet normal 0.0 4.0 -0.0 + outer loop + vertex 1.0 1.0 -1.0 + vertex -1.0 1.0 -1.0 + vertex -1.0 1.0 1.0 + endloop +endfacet +facet normal 0.0 4.0 -0.0 + outer loop + vertex 1.0 1.0 -1.0 + vertex -1.0 1.0 1.0 + vertex 1.0 1.0 1.0 + endloop +endfacet +endsolid Polyhedron \ No newline at end of file diff --git a/tests/control/polyhedron.vtk b/tests/control/polyhedron.vtk new file mode 100644 index 00000000..d2920cbf --- /dev/null +++ b/tests/control/polyhedron.vtk @@ -0,0 +1,20 @@ +# vtk DataFile Version 3.0 +Polyhedron created by Coxeter version 0.7.0 +ASCII +DATASET POLYDATA +POINTS 8 float +-1.0 -1.0 -1.0 +-1.0 -1.0 1.0 +-1.0 1.0 -1.0 +-1.0 1.0 1.0 +1.0 -1.0 -1.0 +1.0 -1.0 1.0 +1.0 1.0 -1.0 +1.0 1.0 1.0 +POLYGONS 6 30 +4 0 1 3 2 +4 0 2 6 4 +4 4 6 7 5 +4 1 5 7 3 +4 0 4 5 1 +4 6 2 3 7 diff --git a/tests/control/polyhedron.x3d b/tests/control/polyhedron.x3d new file mode 100644 index 00000000..727efcb4 --- /dev/null +++ b/tests/control/polyhedron.x3d @@ -0,0 +1 @@ + \ No newline at end of file From 37175d33b796a5c72047aa1e2c2df38e9770a6de Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 12 Sep 2024 13:40:04 -0400 Subject: [PATCH 50/58] Prevent trailing newlines --- coxeter/io.py | 96 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 40 deletions(-) diff --git a/coxeter/io.py b/coxeter/io.py index 8d72660e..8c26770a 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -34,20 +34,26 @@ def to_obj(shape, filename): ------ OSError: If open() encounters a problem. """ - with open(filename, "w") as file: - file.write( - f"# wavefront obj file written by Coxeter " - f"version {__version__}\n" - f"# {shape.__class__.__name__}\n\n" - ) + content = "" + content += ( + f"# wavefront obj file written by Coxeter " + f"version {__version__}\n" + f"# {shape.__class__.__name__}\n\n" + ) - for v in shape.vertices: - file.write(f"v {' '.join([str(coord) for coord in v])}\n") + for v in shape.vertices: + content += f"v {' '.join([str(coord) for coord in v])}\n" - file.write("\n") + content += "\n" + + for f in shape.faces: + content += f"f {' '.join([str(v_index+1) for v_index in f])}\n" + + content = content[:-1] + + with open(filename, "w") as file: + file.write(content) - for f in shape.faces: - file.write(f"f {' '.join([str(v_index+1) for v_index in f])}\n") def to_off(shape, filename): @@ -61,22 +67,26 @@ def to_off(shape, filename): ------ OSError: If open() encounters a problem. """ - with open(filename, "w") as file: - file.write( - f"OFF\n# OFF file written by Coxeter " - f"version {__version__}\n" - f"# {shape.__class__.__name__}\n" - ) + content = "" + content += ( + f"OFF\n# OFF file written by Coxeter " + f"version {__version__}\n" + f"# {shape.__class__.__name__}\n" + ) - file.write( - f"{len(shape.vertices)} f{len(shape.faces)} " f"{len(shape.edges)}\n" - ) + content += f"{len(shape.vertices)} f{len(shape.faces)} " f"{len(shape.edges)}\n" - for v in shape.vertices: - file.write(f"{' '.join([str(coord) for coord in v])}\n") + for v in shape.vertices: + content += f"{' '.join([str(coord) for coord in v])}\n" + + for f in shape.faces: + content += f"{len(f)} {' '.join([str(v_index) for v_index in f])}\n" + + content = content[:-1] + + with open(filename, "w") as file: + file.write(content) - for f in shape.faces: - file.write(f"{len(f)} {' '.join([str(v_index) for v_index in f])}\n") def to_stl(shape, filename): @@ -138,23 +148,28 @@ def to_ply(shape, filename): ------ OSError: If open() encounters a problem. """ - with open(filename, "w") as file: - file.write( - f"ply\nformat ascii 1.0\n" - f"comment PLY file written by Coxeter version {__version__}\n" - f"comment {shape.__class__.__name__}\n" - f"element vertex {len(shape.vertices)}\n" - f"property float x\nproperty float y\nproperty float z\n" - f"element face {len(shape.faces)}\n" - f"property list uchar uint vertex_indices\n" - f"end_header\n" - ) - - for v in shape.vertices: - file.write(f"{' '.join([str(coord) for coord in v])}\n") + content = "" + content += ( + f"ply\nformat ascii 1.0\n" + f"comment PLY file written by Coxeter version {__version__}\n" + f"comment {shape.__class__.__name__}\n" + f"element vertex {len(shape.vertices)}\n" + f"property float x\nproperty float y\nproperty float z\n" + f"element face {len(shape.faces)}\n" + f"property list uchar uint vertex_indices\n" + f"end_header\n" + ) - for f in shape.faces: - file.write(f"{len(f)} {' '.join([str(int(v_index)) for v_index in f])}\n") + for v in shape.vertices: + content += f"{' '.join([str(coord) for coord in v])}\n" + + for f in shape.faces: + content += f"{len(f)} {' '.join([str(int(v_index)) for v_index in f])}\n" + + content = content[:-1] + + with open(filename, "w") as file: + file.write(content) def to_x3d(shape, filename): @@ -244,6 +259,7 @@ def to_vtk(shape, filename): content += f"POLYGONS {num_points} {num_points + num_connections}\n" for f in shape.faces: content += f"{len(f)} {' '.join([str(v_index) for v_index in f])}\n" + content = content.rstrip('\n') # Write file with open(filename, "wb") as file: From fe03d119663c9779b574ad80de0ba3e7ddee6e59 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 12 Sep 2024 13:40:31 -0400 Subject: [PATCH 51/58] Update control files --- tests/control/convex_polyhedron.obj | 2 +- tests/control/convex_polyhedron.off | 2 +- tests/control/convex_polyhedron.ply | 2 +- tests/control/convex_polyhedron.vtk | 2 +- tests/control/polyhedron.obj | 2 +- tests/control/polyhedron.off | 2 +- tests/control/polyhedron.ply | 2 +- tests/control/polyhedron.vtk | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/control/convex_polyhedron.obj b/tests/control/convex_polyhedron.obj index ed5a19cb..f7d02752 100644 --- a/tests/control/convex_polyhedron.obj +++ b/tests/control/convex_polyhedron.obj @@ -15,4 +15,4 @@ f 1 5 6 2 f 5 7 8 6 f 1 2 4 3 f 3 4 8 7 -f 2 6 8 4 +f 2 6 8 4 \ No newline at end of file diff --git a/tests/control/convex_polyhedron.off b/tests/control/convex_polyhedron.off index 48c3bd25..53a4191e 100644 --- a/tests/control/convex_polyhedron.off +++ b/tests/control/convex_polyhedron.off @@ -15,4 +15,4 @@ OFF 4 4 6 7 5 4 0 1 3 2 4 2 3 7 6 -4 1 5 7 3 +4 1 5 7 3 \ No newline at end of file diff --git a/tests/control/convex_polyhedron.ply b/tests/control/convex_polyhedron.ply index 622eb5f5..f63de5c8 100644 --- a/tests/control/convex_polyhedron.ply +++ b/tests/control/convex_polyhedron.ply @@ -22,4 +22,4 @@ end_header 4 4 6 7 5 4 0 1 3 2 4 2 3 7 6 -4 1 5 7 3 +4 1 5 7 3 \ No newline at end of file diff --git a/tests/control/convex_polyhedron.vtk b/tests/control/convex_polyhedron.vtk index 34a23afd..c3220389 100644 --- a/tests/control/convex_polyhedron.vtk +++ b/tests/control/convex_polyhedron.vtk @@ -17,4 +17,4 @@ POLYGONS 6 30 4 4 6 7 5 4 0 1 3 2 4 2 3 7 6 -4 1 5 7 3 +4 1 5 7 3 \ No newline at end of file diff --git a/tests/control/polyhedron.obj b/tests/control/polyhedron.obj index 26f336ce..6a29e23b 100644 --- a/tests/control/polyhedron.obj +++ b/tests/control/polyhedron.obj @@ -15,4 +15,4 @@ f 1 3 7 5 f 5 7 8 6 f 2 6 8 4 f 1 5 6 2 -f 7 3 4 8 +f 7 3 4 8 \ No newline at end of file diff --git a/tests/control/polyhedron.off b/tests/control/polyhedron.off index 2c948353..ecf81648 100644 --- a/tests/control/polyhedron.off +++ b/tests/control/polyhedron.off @@ -15,4 +15,4 @@ OFF 4 4 6 7 5 4 1 5 7 3 4 0 4 5 1 -4 6 2 3 7 +4 6 2 3 7 \ No newline at end of file diff --git a/tests/control/polyhedron.ply b/tests/control/polyhedron.ply index f5cd5e56..6e058bd0 100644 --- a/tests/control/polyhedron.ply +++ b/tests/control/polyhedron.ply @@ -22,4 +22,4 @@ end_header 4 4 6 7 5 4 1 5 7 3 4 0 4 5 1 -4 6 2 3 7 +4 6 2 3 7 \ No newline at end of file diff --git a/tests/control/polyhedron.vtk b/tests/control/polyhedron.vtk index d2920cbf..a6080c4e 100644 --- a/tests/control/polyhedron.vtk +++ b/tests/control/polyhedron.vtk @@ -17,4 +17,4 @@ POLYGONS 6 30 4 4 6 7 5 4 1 5 7 3 4 0 4 5 1 -4 6 2 3 7 +4 6 2 3 7 \ No newline at end of file From b6bf21594bfffd2649998fded87647834dc3036a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:40:45 +0000 Subject: [PATCH 52/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- coxeter/io.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/coxeter/io.py b/coxeter/io.py index 8c26770a..db7a73fa 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -48,14 +48,13 @@ def to_obj(shape, filename): for f in shape.faces: content += f"f {' '.join([str(v_index+1) for v_index in f])}\n" - + content = content[:-1] with open(filename, "w") as file: file.write(content) - def to_off(shape, filename): """Save shape to an Object File Format (OFF) file. @@ -88,7 +87,6 @@ def to_off(shape, filename): file.write(content) - def to_stl(shape, filename): """Save shape to a stereolithography (STL) file. @@ -259,7 +257,7 @@ def to_vtk(shape, filename): content += f"POLYGONS {num_points} {num_points + num_connections}\n" for f in shape.faces: content += f"{len(f)} {' '.join([str(v_index) for v_index in f])}\n" - content = content.rstrip('\n') + content = content.rstrip("\n") # Write file with open(filename, "wb") as file: From 763a2622290c9f9567773f111f00c27400fd2ba8 Mon Sep 17 00:00:00 2001 From: janbridley Date: Thu, 12 Sep 2024 13:57:51 -0400 Subject: [PATCH 53/58] Fix pre-commit regex --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a30b6491..e016bd4e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,9 +6,9 @@ repos: rev: 'v4.6.0' hooks: - id: end-of-file-fixer - exclude: '^tests/control/*' + exclude: '^tests/control/.*' - id: trailing-whitespace - exclude: '(?:setup.cfg.*|paper/.*)|^tests/control/*' + exclude: '(?:setup.cfg.*|paper/.*)|^tests/control/.*' - id: debug-statements - id: check-builtin-literals - id: check-executables-have-shebangs From b2a79d10dc260d9e0d1091d26f47ae6ec4c36029 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Thu, 12 Sep 2024 14:12:50 -0400 Subject: [PATCH 54/58] Switch to OS-agnostic file comparison --- tests/test_io.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/test_io.py b/tests/test_io.py index 1f17414f..5582a101 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -9,11 +9,17 @@ import filecmp import tempfile from pathlib import Path - +from coxeter import io +from coxeter.shapes import Polyhedron, ConvexPolyhedron import pytest -from coxeter import io -from coxeter.shapes import ConvexPolyhedron, Polyhedron +def compare_text_files(file_path_1, file_path_2): + """Check whether two text files have identical contents, ignoring different + newline characters.""" + with open(file_path_1, "r") as file1, open(file_path_2, "r") as file2: + file1_contents, file2_contents = file1.read(), file2.read() + return file1_contents == file2_contents + EXPORT_FUNCS_BY_FILE_TYPE = { "obj": io.to_obj, @@ -80,7 +86,7 @@ def test_regression(file_type, export_func, shape_name): test_file_path = Path(tempdir) / f"test_{shape_name}.{file_type}" export_func(shape=shape, filename=test_file_path) - assert filecmp.cmp(control_file_path, test_file_path, shallow=False), ( + assert compare_text_files(control_file_path, test_file_path), ( f"During regression testing with the shape '{shape_name}' and " f"file type '{file_type}', {control_file_path.name} and " f"{test_file_path.name} were found to be not equivalent." From 6e28a64f1f8a4d633daed3122a4e3a4ea7f7866e Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Fri, 13 Sep 2024 09:29:37 -0400 Subject: [PATCH 55/58] Check file equality by line --- tests/test_io.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/test_io.py b/tests/test_io.py index 5582a101..f5f64253 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -17,8 +17,8 @@ def compare_text_files(file_path_1, file_path_2): """Check whether two text files have identical contents, ignoring different newline characters.""" with open(file_path_1, "r") as file1, open(file_path_2, "r") as file2: - file1_contents, file2_contents = file1.read(), file2.read() - return file1_contents == file2_contents + file1_contents, file2_contents = file1.readlines(), file2.readlines() + assert file1_contents == file2_contents EXPORT_FUNCS_BY_FILE_TYPE = { @@ -86,11 +86,7 @@ def test_regression(file_type, export_func, shape_name): test_file_path = Path(tempdir) / f"test_{shape_name}.{file_type}" export_func(shape=shape, filename=test_file_path) - assert compare_text_files(control_file_path, test_file_path), ( - f"During regression testing with the shape '{shape_name}' and " - f"file type '{file_type}', {control_file_path.name} and " - f"{test_file_path.name} were found to be not equivalent." - ) + compare_text_files(control_file_path, test_file_path) if __name__ == "__main__": From 7f45afaef449bff36c8f88914c0d3b0e7bdb1e27 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Fri, 13 Sep 2024 09:53:10 -0400 Subject: [PATCH 56/58] Alternate solution to circular import --- coxeter/__init__.py | 6 +++--- coxeter/io.py | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/coxeter/__init__.py b/coxeter/__init__.py index 1092b195..5c3a0ac6 100644 --- a/coxeter/__init__.py +++ b/coxeter/__init__.py @@ -16,9 +16,9 @@ applications such as inertia tensors. """ +__version__ = "0.8.0" + from . import families, io, shapes from .shape_getters import from_gsd_type_shapes -__all__ = ["families", "shapes", "from_gsd_type_shapes", "io"] - -__version__ = "0.8.0" +__all__ = ["families", "shapes", "from_gsd_type_shapes", "io"] \ No newline at end of file diff --git a/coxeter/io.py b/coxeter/io.py index db7a73fa..1ebba2c1 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -14,10 +14,8 @@ from copy import deepcopy from importlib.metadata import version from xml.etree import ElementTree - import numpy as np - -__version__ = version("coxeter") +from coxeter import __version__ def to_obj(shape, filename): From d8b77261a497fd6af4e2e91e21cf3f0968ff2348 Mon Sep 17 00:00:00 2001 From: josephburkhart Date: Fri, 13 Sep 2024 09:53:21 -0400 Subject: [PATCH 57/58] Update control files --- tests/control/convex_polyhedron.obj | 2 +- tests/control/convex_polyhedron.off | 2 +- tests/control/convex_polyhedron.ply | 2 +- tests/control/convex_polyhedron.vtk | 2 +- tests/control/polyhedron.obj | 2 +- tests/control/polyhedron.off | 2 +- tests/control/polyhedron.ply | 2 +- tests/control/polyhedron.vtk | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/control/convex_polyhedron.obj b/tests/control/convex_polyhedron.obj index f7d02752..7a3ba776 100644 --- a/tests/control/convex_polyhedron.obj +++ b/tests/control/convex_polyhedron.obj @@ -1,4 +1,4 @@ -# wavefront obj file written by Coxeter version 0.7.0 +# wavefront obj file written by Coxeter version 0.8.0 # ConvexPolyhedron v -1.0 -1.0 -1.0 diff --git a/tests/control/convex_polyhedron.off b/tests/control/convex_polyhedron.off index 53a4191e..abbdbbdf 100644 --- a/tests/control/convex_polyhedron.off +++ b/tests/control/convex_polyhedron.off @@ -1,5 +1,5 @@ OFF -# OFF file written by Coxeter version 0.7.0 +# OFF file written by Coxeter version 0.8.0 # ConvexPolyhedron 8 f6 12 -1.0 -1.0 -1.0 diff --git a/tests/control/convex_polyhedron.ply b/tests/control/convex_polyhedron.ply index f63de5c8..f295bac9 100644 --- a/tests/control/convex_polyhedron.ply +++ b/tests/control/convex_polyhedron.ply @@ -1,6 +1,6 @@ ply format ascii 1.0 -comment PLY file written by Coxeter version 0.7.0 +comment PLY file written by Coxeter version 0.8.0 comment ConvexPolyhedron element vertex 8 property float x diff --git a/tests/control/convex_polyhedron.vtk b/tests/control/convex_polyhedron.vtk index c3220389..5cdef7f5 100644 --- a/tests/control/convex_polyhedron.vtk +++ b/tests/control/convex_polyhedron.vtk @@ -1,5 +1,5 @@ # vtk DataFile Version 3.0 -ConvexPolyhedron created by Coxeter version 0.7.0 +ConvexPolyhedron created by Coxeter version 0.8.0 ASCII DATASET POLYDATA POINTS 8 float diff --git a/tests/control/polyhedron.obj b/tests/control/polyhedron.obj index 6a29e23b..73d79f00 100644 --- a/tests/control/polyhedron.obj +++ b/tests/control/polyhedron.obj @@ -1,4 +1,4 @@ -# wavefront obj file written by Coxeter version 0.7.0 +# wavefront obj file written by Coxeter version 0.8.0 # Polyhedron v -1.0 -1.0 -1.0 diff --git a/tests/control/polyhedron.off b/tests/control/polyhedron.off index ecf81648..bfe2e196 100644 --- a/tests/control/polyhedron.off +++ b/tests/control/polyhedron.off @@ -1,5 +1,5 @@ OFF -# OFF file written by Coxeter version 0.7.0 +# OFF file written by Coxeter version 0.8.0 # Polyhedron 8 f6 12 -1.0 -1.0 -1.0 diff --git a/tests/control/polyhedron.ply b/tests/control/polyhedron.ply index 6e058bd0..2de634b2 100644 --- a/tests/control/polyhedron.ply +++ b/tests/control/polyhedron.ply @@ -1,6 +1,6 @@ ply format ascii 1.0 -comment PLY file written by Coxeter version 0.7.0 +comment PLY file written by Coxeter version 0.8.0 comment Polyhedron element vertex 8 property float x diff --git a/tests/control/polyhedron.vtk b/tests/control/polyhedron.vtk index a6080c4e..a8d8ce23 100644 --- a/tests/control/polyhedron.vtk +++ b/tests/control/polyhedron.vtk @@ -1,5 +1,5 @@ # vtk DataFile Version 3.0 -Polyhedron created by Coxeter version 0.7.0 +Polyhedron created by Coxeter version 0.8.0 ASCII DATASET POLYDATA POINTS 8 float From 43bc02556adfa3301ccafd5eeb5c3ff6e244d362 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 13:55:30 +0000 Subject: [PATCH 58/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- coxeter/__init__.py | 2 +- coxeter/io.py | 3 ++- tests/test_io.py | 12 +++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/coxeter/__init__.py b/coxeter/__init__.py index 5c3a0ac6..6ccb9fc9 100644 --- a/coxeter/__init__.py +++ b/coxeter/__init__.py @@ -21,4 +21,4 @@ from . import families, io, shapes from .shape_getters import from_gsd_type_shapes -__all__ = ["families", "shapes", "from_gsd_type_shapes", "io"] \ No newline at end of file +__all__ = ["families", "shapes", "from_gsd_type_shapes", "io"] diff --git a/coxeter/io.py b/coxeter/io.py index 1ebba2c1..3bc6c6ec 100644 --- a/coxeter/io.py +++ b/coxeter/io.py @@ -12,9 +12,10 @@ import os from copy import deepcopy -from importlib.metadata import version from xml.etree import ElementTree + import numpy as np + from coxeter import __version__ diff --git a/tests/test_io.py b/tests/test_io.py index f5f64253..5e588a09 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -6,17 +6,19 @@ # This software is licensed under the BSD 3-Clause License. """Regression tests for the I/O module.""" -import filecmp import tempfile from pathlib import Path -from coxeter import io -from coxeter.shapes import Polyhedron, ConvexPolyhedron + import pytest +from coxeter import io +from coxeter.shapes import ConvexPolyhedron, Polyhedron + + def compare_text_files(file_path_1, file_path_2): - """Check whether two text files have identical contents, ignoring different + """Check whether two text files have identical contents, ignoring different newline characters.""" - with open(file_path_1, "r") as file1, open(file_path_2, "r") as file2: + with open(file_path_1) as file1, open(file_path_2) as file2: file1_contents, file2_contents = file1.readlines(), file2.readlines() assert file1_contents == file2_contents