From 69b03402508a02c697066f6c1549323e617c0496 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Date: Sat, 16 Mar 2024 20:48:19 -0400 Subject: [PATCH] docs: update README.md --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 47ff371..bb1dd8f 100644 --- a/README.md +++ b/README.md @@ -24,22 +24,26 @@ Discover the staggering performance of OpenSTL in comparison to [numpy-stl](http ### Read and write from a STL file ```python import openstl +import numpy as np # Define an array of triangles # Following the STL standard, each triangle is defined with : normal, v0, v1, v2 -triangles = np.array([ +quad = np.array([ [[0.0, 0.0, 1.0], [0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [1.0, 1.0, 0.0]], [[0.0, 0.0, 1.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [1.0, 1.0, 0.0]], ]) # Serialize the triangles to a file -openstl.write("output.stl", triangles, openstl.format.binary) # Or openstl.format.ascii (slower but human readable) +success = openstl.write("output.stl", quad, openstl.format.binary) # Or openstl.format.ascii (slower but human readable) + +if not success: + raise Exception("Error: Failed to write to the specified file.") # Deserialize triangles from a file -deserialized_triangles = openstl.read("output.stl") +deserialized_quad = openstl.read("output.stl") # Print the deserialized triangles -print("Deserialized Triangles:", deserialized_triangles) +print("Deserialized Triangles:", deserialized_quad) ``` # C++ Usage