Closed jzwar closed 8 months ago
@j042 There are some points I would like to discuss with you before I continue...
Testing script:
import splinepy as spp
import numpy as np
box = spp.helpme.create.box(10, 5).bspline
box.elevate_degrees([0, 1])
box.insert_knots(0, [0.5])
# Create a simple curve
spline_curve = spp.Bezier(
degrees=[2],
control_points=[
[0, 0],
[2, 0],
[2, 2]
]
)
spp.io.svg.export("spline_curve_1.svg", spline_curve)
# Make it more complex
rational_spline_curve = spline_curve.nurbs
rational_spline_curve.elevate_degrees([0, 0])
rational_spline_curve.insert_knots(0, [0.4, 0.6])
rational_spline_curve.weights = np.random.random(
(rational_spline_curve.cps.shape[0]))
spp.io.svg.export("spline_curve_3.svg", rational_spline_curve)
# Export some surfaces
circle = spp.helpme.create.surface_circle(1)
spp.io.svg.export("spline_circle_1.svg", circle)
#
circle = circle.nurbs
circle.insert_knots(0, [0.333, 0.666])
circle.insert_knots(1, [0.333, 0.666])
spp.io.svg.export("spline_circle_2.svg", circle)
results in:
so smooth
Wooooow, so high-res, I zoomed in until I could count the individual atoms of the lines, this is absolutely mind-blowing 🤯 Amazing job guys! 🔥
Add round caps using
stroke-linecap:round
@j042 @danielwolff1 I hope you are impressed 😊
rebased since merging was blocked due to changes in splinepy.io.__init__.py
resolved
For the reviewers : @j042 @clemens-fricke and whoever has time:
I will add Gustaf objects in a later PR. Vertices and Faces. I can open an issue if required
2024-02-07 16:20:34,554 splinepy [WARNING] SVG export only supports (up to) cubic polynomial splines -- using approximation
2024-02-07 16:20:34,555 splinepy [INFO] n_control_points was not given and therefore calculated with knot_vector and degree
2024-02-07 16:20:34,557 splinepy [WARNING] SVG export only supports (up to) cubic polynomial splines -- using approximation
2024-02-07 16:20:34,558 splinepy [INFO] n_control_points was not given and therefore calculated with knot_vector and degree
Traceback (most recent call last):
File "/home/clemensfricke/Documents/git/splinepy/examples/test.py", line 6, in <module>
splinepy.io.export("gus.svg", spline)
File "/home/clemensfricke/Documents/git/splinepy/splinepy/io/default.py", line 50, in export
extension_to_io[extension].export(fname, splinepy_obj)
File "/home/clemensfricke/Documents/git/splinepy/splinepy/io/svg.py", line 910, in export
_export_spline(
File "/home/clemensfricke/Documents/git/splinepy/splinepy/io/svg.py", line 794, in _export_spline
knot_lines.append(spline.extract.spline(1, knot))
File "/home/clemensfricke/Documents/git/splinepy/splinepy/helpme/extract.py", line 705, in spline
return spline(self._helpee, splitting_plane, interval)
File "/home/clemensfricke/Documents/git/splinepy/splinepy/helpme/extract.py", line 460, in spline
spline_copy.insert_knots(para_dim, split_plane)
File "/home/clemensfricke/Documents/git/splinepy/splinepy/bspline.py", line 112, in insert_knots
inserted = _splinepy_core.insert_knots(
ValueError: vector::reserve
knot insertion for C^-1 at bounding box @j042
2024-02-07 16:20:34,554 splinepy [WARNING] SVG export only supports (up to) cubic polynomial splines -- using approximation 2024-02-07 16:20:34,555 splinepy [INFO] n_control_points was not given and therefore calculated with knot_vector and degree 2024-02-07 16:20:34,557 splinepy [WARNING] SVG export only supports (up to) cubic polynomial splines -- using approximation 2024-02-07 16:20:34,558 splinepy [INFO] n_control_points was not given and therefore calculated with knot_vector and degree Traceback (most recent call last): File "/home/clemensfricke/Documents/git/splinepy/examples/test.py", line 6, in <module> splinepy.io.export("gus.svg", spline) File "/home/clemensfricke/Documents/git/splinepy/splinepy/io/default.py", line 50, in export extension_to_io[extension].export(fname, splinepy_obj) File "/home/clemensfricke/Documents/git/splinepy/splinepy/io/svg.py", line 910, in export _export_spline( File "/home/clemensfricke/Documents/git/splinepy/splinepy/io/svg.py", line 794, in _export_spline knot_lines.append(spline.extract.spline(1, knot)) File "/home/clemensfricke/Documents/git/splinepy/splinepy/helpme/extract.py", line 705, in spline return spline(self._helpee, splitting_plane, interval) File "/home/clemensfricke/Documents/git/splinepy/splinepy/helpme/extract.py", line 460, in spline spline_copy.insert_knots(para_dim, split_plane) File "/home/clemensfricke/Documents/git/splinepy/splinepy/bspline.py", line 112, in insert_knots inserted = _splinepy_core.insert_knots( ValueError: vector::reserve
knot insertion for C^-1 at bounding box @j042
This should be fixed now, please check if the import-export works for you now, I pushed something to your cli convert branch and tested it on linux and Mac. @clemens-fricke
@jzwar knot insertion at bounds is an issue?
@jzwar knot insertion at bounds is an issue?
It was an issue at the upper bound
Also works for me now. :+1:
@jzwar knot insertion at bounds is an issue?
It was an issue at the upper bound
Ok, do you want the fix in this PR or are you okay with next PR? I have a few things to update in BSplineLib and I can include this
@jzwar knot insertion at bounds is an issue?
It was an issue at the upper bound
Ok, do you want the fix in this PR or are you okay with next PR? I have a few things to update in BSplineLib and I can include this
I fixed it "a bit" already. Is this your very subtle way to tell me to retract my changes and leave it to a separate PR
@jzwar knot insertion at bounds is an issue?
It was an issue at the upper bound
Ok, do you want the fix in this PR or are you okay with next PR? I have a few things to update in BSplineLib and I can include this
I fixed it "a bit" already. Is this your very subtle way to tell me to retract my changes and leave it to a separate PR
haha no, it's rather - thanks for your fix, as it fixes the issue, may I have a bit more time to fix the upstream issue?
For sick graphics in publications
Are you tired of png exports in 500MP just to satisfy your eyes? Be afraid no longer, as this PR finally provides vector graphics for 2D geometries.
Addressed issues
Bug fix in extract spline is fixed (issue not reported)
Function to flip the direction of parametric axes is added (issue not reported)
[x] Export Curve splines as paths
[x] Export Knots for curves as rectangles
[x] Export control mesh (also for 2D)
[x] Export surface splines and knots as paths (with filling)
[x] Export fields as images
[x] Export quivers as arrows with color using spline data
Showcase
Output
THIS PR IS BLOCKED BY FITTING PR #320
Checklists