-
Notifications
You must be signed in to change notification settings - Fork 24
Labels
cadTasks relating to the cad moduleTasks relating to the cad modulecodesTasks relating to integration of external codesTasks relating to integration of external codesgeometryTasks relating to the geometry moduleTasks relating to the geometry module
Description
Describe the bug
Extracting only the blue part of the wire:
Serialising and saving as a JSON file, and then reading from the JSON file and deserialising:
Steps to reproduce
- Create a spline
- Cut it into at least two shorter pieces.
- Serialise one of the shorter piece
- deserialise
- the deserialised wire is the FULL, uncut spline.
import json
import matplotlib.pyplot as plt
import numpy as np
from bluemira.display import plot_2d, show_cad
from bluemira.display.displayer import DisplayCADOptions
from bluemira.geometry.tools import split_wire, interpolate_bspline
# boolean_cut, make_circle, make_polygon
from bluemira.geometry.tools import deserialise_shape, serialise_shape
from bluemira.geometry.wire import BluemiraWire
x = np.linspace(0, 10, 1000)
y = np.zeros(1000)
z = 0.5 * np.sin(x) + 3 * np.cos(x) ** 2
spline = interpolate_bspline(np.array([x, y, z]))
cut_point = (1.5* np.pi, 0, 0.5* -1 + 3 * 0**2)
wire_1, wire_2 = split_wire(spline, cut_point, 1E-5)
show_cad([wire_1, wire_2], [DisplayCADOptions(color="blue"), DisplayCADOptions(color="red")])
with open("/tmp/half-of-a-wire.json", "w") as j:
ax = plt.subplot()
ax.set_title("Wire being saved into a json file")
plot_2d(wire_1, ax=ax)
json.dump(serialise_shape(wire_1), j)
with open("/tmp/half-of-a-wire.json") as j:
reconstructed_wire = deserialise_shape(json.load(j))
ax = plt.subplot()
ax.set_title("Wire re-constructed from the json file")
plot_2d(reconstructed_wire, ax=ax)Tracebacks
Version
develop
OS
Ubuntu 24 (or equivalent recent Linux distribution)
OS details
No response
Metadata
Metadata
Assignees
Labels
cadTasks relating to the cad moduleTasks relating to the cad modulecodesTasks relating to integration of external codesTasks relating to integration of external codesgeometryTasks relating to the geometry moduleTasks relating to the geometry module