Implement SplineStructure superclass of SplineObject #122
+290
−135
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
One of the design choices made in nutils is that it makes sense to separate topology and data as much as possible. It's a point of view that I find I'm increasingly sympathetic to, and I find it sometimes quite annoying that in Splipy I'm forced to always have a control point array for each SplineObject even when what I'm really doing is having a spline 'structure' (that is, a set of bases) and a number of fields defined on that structure (that is, control point arrays).
I'd like to be able to use Splipy in this way. If it won't be the officially sanctioned usage pattern then I'd at least like it to be possible.
As a first step, this PR creates a superclass of SplineObject called SplineStructure, which has everything that a SplineObject has minus a control point array. I moved most of the methods that were possible to define only in terms of bases to the super class. Some other methods for operations that work on both the bases and the control points, I've implemented as a superclass method that can be called from the subclass.
These operations also make sense to move either wholly or partially to the superclass, but I've left them alone for now:
lower_periodic
,split
,make_periodic
andmake_splines_identical
.In the future I would like to take this one step further: most of these methods should be defined on the SplineStructure superclass, and they should return objects of some new type
ControlPointOperation
or something like that, which can be applied to the control point arrays. Then the SplineObject class can do stuff like:and in my own code I can do stuff like