bspy 3.0.0__tar.gz → 3.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bspy-3.0.0 → bspy-3.0.1}/PKG-INFO +4 -4
- {bspy-3.0.0 → bspy-3.0.1}/README.md +3 -3
- {bspy-3.0.0 → bspy-3.0.1}/bspy/_spline_operations.py +9 -3
- {bspy-3.0.0 → bspy-3.0.1}/bspy/bspyApp.py +34 -34
- {bspy-3.0.0 → bspy-3.0.1}/bspy/drawableSpline.py +10 -6
- {bspy-3.0.0 → bspy-3.0.1}/bspy/spline.py +8 -2
- {bspy-3.0.0 → bspy-3.0.1}/bspy/splineOpenGLFrame.py +24 -16
- {bspy-3.0.0 → bspy-3.0.1}/bspy.egg-info/PKG-INFO +4 -4
- {bspy-3.0.0 → bspy-3.0.1}/setup.cfg +1 -1
- {bspy-3.0.0 → bspy-3.0.1}/LICENSE +0 -0
- {bspy-3.0.0 → bspy-3.0.1}/bspy/__init__.py +0 -0
- {bspy-3.0.0 → bspy-3.0.1}/bspy/_spline_domain.py +0 -0
- {bspy-3.0.0 → bspy-3.0.1}/bspy/_spline_evaluation.py +0 -0
- {bspy-3.0.0 → bspy-3.0.1}/bspy/_spline_fitting.py +0 -0
- {bspy-3.0.0 → bspy-3.0.1}/bspy/_spline_intersection.py +0 -0
- {bspy-3.0.0 → bspy-3.0.1}/bspy.egg-info/SOURCES.txt +0 -0
- {bspy-3.0.0 → bspy-3.0.1}/bspy.egg-info/dependency_links.txt +0 -0
- {bspy-3.0.0 → bspy-3.0.1}/bspy.egg-info/requires.txt +0 -0
- {bspy-3.0.0 → bspy-3.0.1}/bspy.egg-info/top_level.txt +0 -0
- {bspy-3.0.0 → bspy-3.0.1}/pyproject.toml +0 -0
- {bspy-3.0.0 → bspy-3.0.1}/tests/test_bspy.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: bspy
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.1
|
|
4
4
|
Summary: Library for manipulating and rendering non-uniform B-splines
|
|
5
5
|
Home-page: http://github.com/ericbrec/BSpy
|
|
6
6
|
Author: Eric Brechner
|
|
@@ -37,7 +37,7 @@ Other methods add, subtract, and multiply splines, as well as confine spline cur
|
|
|
37
37
|
There are methods to evaluate spline values, derivatives, integrals, normals, curvature, and the Jacobian, as well as methods that return spline representations of derivatives, normals, integrals, graphs, and convolutions. In addition, there are methods to manipulate the domain of splines, including trim, join, reparametrize, transpose, reverse, add and remove knots, elevate and extrapolate, and fold and unfold. There are methods to manipulate the range of splines, including dot product, cross product, translate, rotate, scale, and transform. Finally, there are methods to compute the zeros and contours of a spline and to intersect two splines.
|
|
38
38
|
|
|
39
39
|
The [SplineOpenGLFrame](https://ericbrec.github.io/BSpy/bspy/splineOpenGLFrame.html) class is an
|
|
40
|
-
[OpenGLFrame](https://pypi.org/project/pyopengltk/) with custom shaders to render spline curves and surfaces.
|
|
40
|
+
[OpenGLFrame](https://pypi.org/project/pyopengltk/) with custom shaders to render spline curves and surfaces. Only tested on Windows systems.
|
|
41
41
|
|
|
42
42
|
The [DrawableSpline](https://ericbrec.github.io/BSpy/bspy/drawableSpline.html) class converts a
|
|
43
43
|
[Spline](https://ericbrec.github.io/BSpy/bspy/spline.html) to a curve, surface, or solid that can be drawn in a
|
|
@@ -48,11 +48,11 @@ Spline surfaces and solids with more than 3 dependent variables will have their
|
|
|
48
48
|
The [bspyApp](https://ericbrec.github.io/BSpy/bspy/bspyApp.html) class is a
|
|
49
49
|
[tkinter.Tk](https://docs.python.org/3/library/tkinter.html) app that hosts a
|
|
50
50
|
[SplineOpenGLFrame](https://ericbrec.github.io/BSpy/bspy/splineOpenGLFrame.html),
|
|
51
|
-
a listbox full of splines, and a set of controls to adjust and view the selected splines.
|
|
51
|
+
a listbox full of splines, and a set of controls to adjust and view the selected splines. Only tested on Windows systems.
|
|
52
52
|
|
|
53
53
|
The [bspyGraphics](https://ericbrec.github.io/BSpy/bspy/bspyApp.html#bspyGraphics) class is a graphics engine to display splines.
|
|
54
54
|
It launches a [bspyApp](https://ericbrec.github.io/BSpy/bspy/bspyApp.html) and issues commands to the app for use
|
|
55
|
-
in [jupyter](https://jupyter.org/) notebooks and other scripting environments.
|
|
55
|
+
in [jupyter](https://jupyter.org/) notebooks and other scripting environments. Only tested on Windows systems.
|
|
56
56
|
|
|
57
57
|

|
|
58
58
|
|
|
@@ -7,7 +7,7 @@ Other methods add, subtract, and multiply splines, as well as confine spline cur
|
|
|
7
7
|
There are methods to evaluate spline values, derivatives, integrals, normals, curvature, and the Jacobian, as well as methods that return spline representations of derivatives, normals, integrals, graphs, and convolutions. In addition, there are methods to manipulate the domain of splines, including trim, join, reparametrize, transpose, reverse, add and remove knots, elevate and extrapolate, and fold and unfold. There are methods to manipulate the range of splines, including dot product, cross product, translate, rotate, scale, and transform. Finally, there are methods to compute the zeros and contours of a spline and to intersect two splines.
|
|
8
8
|
|
|
9
9
|
The [SplineOpenGLFrame](https://ericbrec.github.io/BSpy/bspy/splineOpenGLFrame.html) class is an
|
|
10
|
-
[OpenGLFrame](https://pypi.org/project/pyopengltk/) with custom shaders to render spline curves and surfaces.
|
|
10
|
+
[OpenGLFrame](https://pypi.org/project/pyopengltk/) with custom shaders to render spline curves and surfaces. Only tested on Windows systems.
|
|
11
11
|
|
|
12
12
|
The [DrawableSpline](https://ericbrec.github.io/BSpy/bspy/drawableSpline.html) class converts a
|
|
13
13
|
[Spline](https://ericbrec.github.io/BSpy/bspy/spline.html) to a curve, surface, or solid that can be drawn in a
|
|
@@ -18,11 +18,11 @@ Spline surfaces and solids with more than 3 dependent variables will have their
|
|
|
18
18
|
The [bspyApp](https://ericbrec.github.io/BSpy/bspy/bspyApp.html) class is a
|
|
19
19
|
[tkinter.Tk](https://docs.python.org/3/library/tkinter.html) app that hosts a
|
|
20
20
|
[SplineOpenGLFrame](https://ericbrec.github.io/BSpy/bspy/splineOpenGLFrame.html),
|
|
21
|
-
a listbox full of splines, and a set of controls to adjust and view the selected splines.
|
|
21
|
+
a listbox full of splines, and a set of controls to adjust and view the selected splines. Only tested on Windows systems.
|
|
22
22
|
|
|
23
23
|
The [bspyGraphics](https://ericbrec.github.io/BSpy/bspy/bspyApp.html#bspyGraphics) class is a graphics engine to display splines.
|
|
24
24
|
It launches a [bspyApp](https://ericbrec.github.io/BSpy/bspy/bspyApp.html) and issues commands to the app for use
|
|
25
|
-
in [jupyter](https://jupyter.org/) notebooks and other scripting environments.
|
|
25
|
+
in [jupyter](https://jupyter.org/) notebooks and other scripting environments. Only tested on Windows systems.
|
|
26
26
|
|
|
27
27
|

|
|
28
28
|
|
|
@@ -100,6 +100,15 @@ def confine(self, range_bounds):
|
|
|
100
100
|
for i in range(spline.nDep):
|
|
101
101
|
intersectBoundary(i, 0)
|
|
102
102
|
intersectBoundary(i, 1)
|
|
103
|
+
|
|
104
|
+
# Put the intersection points in order.
|
|
105
|
+
intersections.sort(key=lambda intersection: intersection[0])
|
|
106
|
+
|
|
107
|
+
# Remove repeat points at start and end.
|
|
108
|
+
if intersections[1][0] - intersections[0][0] < epsilon:
|
|
109
|
+
del intersections[1]
|
|
110
|
+
if intersections[-1][0] - intersections[-2][0] < epsilon:
|
|
111
|
+
del intersections[-2]
|
|
103
112
|
|
|
104
113
|
# Insert order-1 knots at each intersection point.
|
|
105
114
|
for (knot, boundaryPoint, headedOutside) in intersections:
|
|
@@ -110,9 +119,6 @@ def confine(self, range_bounds):
|
|
|
110
119
|
spline = spline.insert_knots(([knot] * count,))
|
|
111
120
|
else:
|
|
112
121
|
spline = spline.insert_knots(([knot] * (order - 1),))
|
|
113
|
-
|
|
114
|
-
# Put the intersection points in order.
|
|
115
|
-
intersections.sort(key=lambda intersection: intersection[0])
|
|
116
122
|
|
|
117
123
|
# Go through the boundary points, assigning boundary coefficients, interpolating between boundary points,
|
|
118
124
|
# and removing knots and coefficients where the curve stalls.
|
|
@@ -82,7 +82,7 @@ class bspyApp(tk.Tk):
|
|
|
82
82
|
controls = tk.Frame(self)
|
|
83
83
|
controls.pack(side=tk.RIGHT, fill=tk.BOTH, expand=tk.YES)
|
|
84
84
|
|
|
85
|
-
self.frame = SplineOpenGLFrame(controls)
|
|
85
|
+
self.frame = SplineOpenGLFrame(controls, draw_func=self._DrawSplines)
|
|
86
86
|
self.frame.pack(side=tk.TOP, fill=tk.BOTH, expand=tk.YES)
|
|
87
87
|
|
|
88
88
|
buttons = tk.Frame(controls)
|
|
@@ -98,6 +98,7 @@ class bspyApp(tk.Tk):
|
|
|
98
98
|
self.scale.set(0.5)
|
|
99
99
|
|
|
100
100
|
self.splineList = []
|
|
101
|
+
self.splineDrawList = []
|
|
101
102
|
self.splineRadius = 0.0
|
|
102
103
|
self.adjust = None
|
|
103
104
|
self.workQueue = workQueue
|
|
@@ -138,21 +139,17 @@ class bspyApp(tk.Tk):
|
|
|
138
139
|
|
|
139
140
|
def draw(self, spline, name = None):
|
|
140
141
|
"""Add a `Spline` to the listbox and draw it. Can be called before the app is running."""
|
|
141
|
-
|
|
142
|
-
if name is not None:
|
|
143
|
-
spline.metadata["Name"] = name
|
|
144
|
-
self.splineList.append(spline)
|
|
145
|
-
self.listBox.insert(tk.END, spline)
|
|
142
|
+
self.list(spline, name)
|
|
146
143
|
self.listBox.selection_set(self.listBox.size() - 1)
|
|
147
144
|
self.update()
|
|
148
145
|
|
|
149
146
|
def save_splines(self):
|
|
150
|
-
if self.
|
|
151
|
-
initialName = self.
|
|
147
|
+
if self.splineDrawList:
|
|
148
|
+
initialName = self.splineDrawList[0].metadata.get("Name", "spline") + ".json"
|
|
152
149
|
fileName = filedialog.asksaveasfilename(title="Save splines", initialfile=initialName,
|
|
153
150
|
defaultextension=".json", filetypes=(('Json files', '*.json'),('All files', '*.*')))
|
|
154
151
|
if fileName:
|
|
155
|
-
self.
|
|
152
|
+
self.splineDrawList[0].save(fileName, *self.splineDrawList[1:])
|
|
156
153
|
|
|
157
154
|
def load_splines(self):
|
|
158
155
|
fileName = filedialog.askopenfilename(title="Load splines",
|
|
@@ -200,7 +197,7 @@ class bspyApp(tk.Tk):
|
|
|
200
197
|
|
|
201
198
|
def update(self):
|
|
202
199
|
"""Update the spline draw list, set the default view, reset the bounds, and refresh the frame."""
|
|
203
|
-
self.
|
|
200
|
+
self.splineDrawList = []
|
|
204
201
|
gotOne = False
|
|
205
202
|
for item in self.listBox.curselection():
|
|
206
203
|
spline = self.splineList[item]
|
|
@@ -212,25 +209,24 @@ class bspyApp(tk.Tk):
|
|
|
212
209
|
splineMin = spline.coefs[:3].min(axis=coefsAxis)
|
|
213
210
|
splineMax = spline.coefs[:3].max(axis=coefsAxis)
|
|
214
211
|
gotOne = True
|
|
215
|
-
self.
|
|
212
|
+
self.splineDrawList.append(spline)
|
|
216
213
|
|
|
217
214
|
if gotOne:
|
|
218
215
|
newRadius = 0.5 * np.max(splineMax - splineMin)
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
self.frame.ResetView()
|
|
216
|
+
self.splineRadius = newRadius
|
|
217
|
+
atDefaultEye = np.allclose(self.frame.eye, self.frame.defaultEye)
|
|
218
|
+
center = 0.5 * (splineMax + splineMin)
|
|
219
|
+
self.frame.SetDefaultView(center + (0.0, 0.0, 3.0 * newRadius), center, (0.0, 1.0, 0.0))
|
|
220
|
+
self.frame.ResetBounds()
|
|
221
|
+
if atDefaultEye:
|
|
222
|
+
self.frame.ResetView()
|
|
227
223
|
else:
|
|
228
224
|
self.splineRadius = 0.0
|
|
229
225
|
|
|
230
226
|
if self.adjust is not None:
|
|
231
|
-
if self.
|
|
232
|
-
self.bits.set(self.
|
|
233
|
-
animate = self.
|
|
227
|
+
if self.splineDrawList:
|
|
228
|
+
self.bits.set(self.splineDrawList[0].get_options())
|
|
229
|
+
animate = self.splineDrawList[0].get_animate()
|
|
234
230
|
else:
|
|
235
231
|
self.bits.set(0)
|
|
236
232
|
animate = None
|
|
@@ -240,6 +236,10 @@ class bspyApp(tk.Tk):
|
|
|
240
236
|
|
|
241
237
|
self.frame.Update()
|
|
242
238
|
|
|
239
|
+
def _DrawSplines(self, frame, transform):
|
|
240
|
+
for spline in self.splineDrawList:
|
|
241
|
+
spline._Draw(frame, transform)
|
|
242
|
+
|
|
243
243
|
def _ListSelectionChanged(self, event):
|
|
244
244
|
"""Handle when the listbox selection has changed."""
|
|
245
245
|
self.update()
|
|
@@ -259,8 +259,8 @@ class bspyApp(tk.Tk):
|
|
|
259
259
|
self.checkButtons.pack(side=tk.LEFT, fill=tk.BOTH, expand=tk.YES)
|
|
260
260
|
|
|
261
261
|
self.bits = tk.IntVar()
|
|
262
|
-
if self.
|
|
263
|
-
self.bits.set(self.
|
|
262
|
+
if self.splineDrawList:
|
|
263
|
+
self.bits.set(self.splineDrawList[0].get_options())
|
|
264
264
|
else:
|
|
265
265
|
self.bits.set(0)
|
|
266
266
|
_BitCheckbutton(self.checkButtons, DrawableSpline.SHADED, text="Shaded", anchor=tk.W, variable=self.bits, command=self._ChangeOptions).pack(side=tk.TOP, fill=tk.X)
|
|
@@ -274,8 +274,8 @@ class bspyApp(tk.Tk):
|
|
|
274
274
|
tk.Button(buttons, text='Line color', command=self._LineColorChange).pack(side=tk.TOP, fill=tk.X)
|
|
275
275
|
self.animate = tk.StringVar()
|
|
276
276
|
self.animateOptions = {"Animate: Off" : None, "Animate: u(0)" : 0, "Animate: v(1)" : 1, "Animate: w(2)" : 2}
|
|
277
|
-
if self.
|
|
278
|
-
animate = self.
|
|
277
|
+
if self.splineDrawList:
|
|
278
|
+
animate = self.splineDrawList[0].get_animate()
|
|
279
279
|
else:
|
|
280
280
|
animate = None
|
|
281
281
|
self.animate.set(next(key for key, value in self.animateOptions.items() if value == animate))
|
|
@@ -299,7 +299,7 @@ class bspyApp(tk.Tk):
|
|
|
299
299
|
|
|
300
300
|
def _ChangeOptions(self, options):
|
|
301
301
|
"""Handle when the spline options are changed."""
|
|
302
|
-
for spline in self.
|
|
302
|
+
for spline in self.splineDrawList:
|
|
303
303
|
spline.set_options(options)
|
|
304
304
|
self.frame.Update()
|
|
305
305
|
|
|
@@ -307,7 +307,7 @@ class bspyApp(tk.Tk):
|
|
|
307
307
|
"""Handle when the spline animation is changed."""
|
|
308
308
|
nInd = self.animateOptions[value]
|
|
309
309
|
animating = False
|
|
310
|
-
for spline in self.
|
|
310
|
+
for spline in self.splineDrawList:
|
|
311
311
|
if nInd is None or nInd < spline.nInd:
|
|
312
312
|
spline.set_animate(nInd)
|
|
313
313
|
animating = True
|
|
@@ -316,21 +316,21 @@ class bspyApp(tk.Tk):
|
|
|
316
316
|
|
|
317
317
|
def _FillColorChange(self):
|
|
318
318
|
"""Handle when the fill color changed."""
|
|
319
|
-
if self.
|
|
320
|
-
oldColor = 255.0 * self.
|
|
319
|
+
if self.splineDrawList:
|
|
320
|
+
oldColor = 255.0 * self.splineDrawList[0].get_fill_color()
|
|
321
321
|
newColor = askcolor(title="Set spline fill color", color="#%02x%02x%02x" % (int(oldColor[0]), int(oldColor[1]), int(oldColor[2])))
|
|
322
322
|
if newColor[0] is not None:
|
|
323
|
-
for spline in self.
|
|
323
|
+
for spline in self.splineDrawList:
|
|
324
324
|
spline.set_fill_color(newColor[0])
|
|
325
325
|
self.frame.Update()
|
|
326
326
|
|
|
327
327
|
def _LineColorChange(self):
|
|
328
328
|
"""Handle when the line color changed."""
|
|
329
|
-
if self.
|
|
330
|
-
oldColor = 255.0 * self.
|
|
329
|
+
if self.splineDrawList:
|
|
330
|
+
oldColor = 255.0 * self.splineDrawList[0].get_line_color()
|
|
331
331
|
newColor = askcolor(title="Set spline line color", color="#%02x%02x%02x" % (int(oldColor[0]), int(oldColor[1]), int(oldColor[2])))
|
|
332
332
|
if newColor[0] is not None:
|
|
333
|
-
for spline in self.
|
|
333
|
+
for spline in self.splineDrawList:
|
|
334
334
|
spline.set_line_color(newColor[0])
|
|
335
335
|
self.frame.Update()
|
|
336
336
|
|
|
@@ -145,10 +145,14 @@ class DrawableSpline(Spline):
|
|
|
145
145
|
floatCount += 2 + self.order[i] + self.nCoef[i]
|
|
146
146
|
coefficientCount *= self.nCoef[i]
|
|
147
147
|
if not(floatCount + self.nDep * coefficientCount <= self._maxFloats): raise ValueError("Spline to large to draw")
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
if not "fillColor" in self.metadata:
|
|
149
|
+
self.metadata["fillColor"] = np.array((0.0, 1.0, 0.0, 1.0), np.float32)
|
|
150
|
+
if not "lineColor" in self.metadata:
|
|
151
|
+
self.metadata["lineColor"] = np.array((0.0, 0.0, 0.0, 1.0) if self.nInd > 1 else (1.0, 1.0, 1.0, 1.0), np.float32)
|
|
152
|
+
if not "options" in self.metadata:
|
|
153
|
+
self.metadata["options"] = self.SHADED | self.BOUNDARY
|
|
154
|
+
if not "animate" in self.metadata:
|
|
155
|
+
self.metadata["animate"] = None
|
|
152
156
|
|
|
153
157
|
def __str__(self):
|
|
154
158
|
return self.metadata.get("Name", "[{0}, {1}]".format(self.coefs[0], self.coefs[1]))
|
|
@@ -198,7 +202,7 @@ class DrawableSpline(Spline):
|
|
|
198
202
|
if rangeCoef > 1.0e-8:
|
|
199
203
|
coefs[i] = (coefs[i] - minCoef) / rangeCoef
|
|
200
204
|
else:
|
|
201
|
-
coefs[i] = 1.0
|
|
205
|
+
coefs[i] = max(0.0, min(1.0, minCoef))
|
|
202
206
|
elif spline.nInd == 3:
|
|
203
207
|
if spline.nDep == 1:
|
|
204
208
|
spline = spline.graph()
|
|
@@ -215,7 +219,7 @@ class DrawableSpline(Spline):
|
|
|
215
219
|
if rangeCoef > 1.0e-8:
|
|
216
220
|
coefs[i] = (coefs[i] - minCoef) / rangeCoef
|
|
217
221
|
else:
|
|
218
|
-
coefs[i] = 1.0
|
|
222
|
+
coefs[i] = max(0.0, min(1.0, minCoef))
|
|
219
223
|
else:
|
|
220
224
|
raise ValueError("Can't convert to drawable spline.")
|
|
221
225
|
|
|
@@ -676,7 +676,10 @@ class Spline:
|
|
|
676
676
|
def vectorized(*uvwInstance):
|
|
677
677
|
return tuple(bspy._spline_evaluation.derivative(self, with_respect_to, uvwInstance))
|
|
678
678
|
uFunc = np.frompyfunc(vectorized, self.nInd, self.nDep)
|
|
679
|
-
|
|
679
|
+
if self.nDep > 1:
|
|
680
|
+
return tuple([a.astype(self.coefs.dtype, copy=False) for a in uFunc(*uvw, **kwargs)])
|
|
681
|
+
else:
|
|
682
|
+
return np.array([x[0] for x in uFunc(*uvw, **kwargs)], self.coefs.dtype)
|
|
680
683
|
else:
|
|
681
684
|
return bspy._spline_evaluation.derivative(self, with_respect_to, *uvw)
|
|
682
685
|
|
|
@@ -841,7 +844,10 @@ class Spline:
|
|
|
841
844
|
def vectorized(*uvwInstance):
|
|
842
845
|
return tuple(bspy._spline_evaluation.evaluate(self, uvwInstance))
|
|
843
846
|
uFunc = np.frompyfunc(vectorized, self.nInd, self.nDep)
|
|
844
|
-
|
|
847
|
+
if self.nDep > 1:
|
|
848
|
+
return tuple([a.astype(self.coefs.dtype, copy=False) for a in uFunc(*uvw, **kwargs)])
|
|
849
|
+
else:
|
|
850
|
+
return np.array([x[0] for x in uFunc(*uvw, **kwargs)], self.coefs.dtype)
|
|
845
851
|
else:
|
|
846
852
|
return bspy._spline_evaluation.evaluate(self, *uvw)
|
|
847
853
|
|
|
@@ -2,13 +2,16 @@ import numpy as np
|
|
|
2
2
|
import tkinter as tk
|
|
3
3
|
from OpenGL.GL import *
|
|
4
4
|
import OpenGL.GL.shaders as shaders
|
|
5
|
-
|
|
5
|
+
try:
|
|
6
|
+
from pyopengltk import OpenGLFrame
|
|
7
|
+
except ImportError:
|
|
8
|
+
from tkinter import Frame as OpenGLFrame
|
|
6
9
|
from bspy import DrawableSpline
|
|
7
10
|
from bspy.drawableSpline import _set_color
|
|
8
11
|
|
|
9
12
|
class SplineOpenGLFrame(OpenGLFrame):
|
|
10
13
|
"""
|
|
11
|
-
A tkinter `OpenGLFrame` with shaders to display a `DrawableSpline
|
|
14
|
+
A tkinter `OpenGLFrame` with shaders to display a `DrawableSpline`.
|
|
12
15
|
"""
|
|
13
16
|
|
|
14
17
|
ROTATE = 1
|
|
@@ -939,10 +942,10 @@ class SplineOpenGLFrame(OpenGLFrame):
|
|
|
939
942
|
}
|
|
940
943
|
"""
|
|
941
944
|
|
|
942
|
-
def __init__(self, *args, eye=(0.0, 0.0, 3.0), center=(0.0, 0.0, 0.0), up=(0.0, 1.0, 0.0), **kw):
|
|
945
|
+
def __init__(self, *args, eye=(0.0, 0.0, 3.0), center=(0.0, 0.0, 0.0), up=(0.0, 1.0, 0.0), draw_func=None, **kw):
|
|
943
946
|
OpenGLFrame.__init__(self, *args, **kw)
|
|
944
947
|
|
|
945
|
-
self.
|
|
948
|
+
self.draw_func = draw_func
|
|
946
949
|
self.animating = False
|
|
947
950
|
self.animate = 0 # Set to number of milliseconds before showing next frame (0 means no animation)
|
|
948
951
|
self.frameCount = 0
|
|
@@ -994,12 +997,6 @@ class SplineOpenGLFrame(OpenGLFrame):
|
|
|
994
997
|
self.backgroundColor = _set_color(r, g, b, a)
|
|
995
998
|
if self.glInitialized:
|
|
996
999
|
glClearColor(self.backgroundColor[0], self.backgroundColor[1], self.backgroundColor[2], self.backgroundColor[3])
|
|
997
|
-
|
|
998
|
-
def SetSplineList(self, list):
|
|
999
|
-
"""
|
|
1000
|
-
Set the `DrawableSpline` list which determines the splines to display.
|
|
1001
|
-
"""
|
|
1002
|
-
self.splineDrawList = list
|
|
1003
1000
|
|
|
1004
1001
|
def ResetView(self):
|
|
1005
1002
|
"""
|
|
@@ -1174,8 +1171,8 @@ class SplineOpenGLFrame(OpenGLFrame):
|
|
|
1174
1171
|
(self.horizon[2], self.vertical[2], self.look[2], 0.0),
|
|
1175
1172
|
(-np.dot(self.horizon, self.eye), -np.dot(self.vertical, self.eye), -np.dot(self.look, self.eye), 1.0)), np.float32)
|
|
1176
1173
|
|
|
1177
|
-
|
|
1178
|
-
|
|
1174
|
+
if self.draw_func is not None:
|
|
1175
|
+
self.draw_func(self, transform)
|
|
1179
1176
|
|
|
1180
1177
|
glFlush()
|
|
1181
1178
|
|
|
@@ -1192,7 +1189,10 @@ class SplineOpenGLFrame(OpenGLFrame):
|
|
|
1192
1189
|
"""
|
|
1193
1190
|
Update the frame, typically after updating the spline list.
|
|
1194
1191
|
"""
|
|
1195
|
-
|
|
1192
|
+
try:
|
|
1193
|
+
self.tkExpose(None)
|
|
1194
|
+
except AttributeError:
|
|
1195
|
+
pass
|
|
1196
1196
|
|
|
1197
1197
|
def Reset(self):
|
|
1198
1198
|
"""
|
|
@@ -1216,14 +1216,22 @@ class SplineOpenGLFrame(OpenGLFrame):
|
|
|
1216
1216
|
|
|
1217
1217
|
def SetScale(self, scale):
|
|
1218
1218
|
"""
|
|
1219
|
-
Set
|
|
1219
|
+
Set anchor distance and/or flying speed (depending on mode).
|
|
1220
1220
|
|
|
1221
1221
|
Parameters
|
|
1222
1222
|
----------
|
|
1223
1223
|
scale : `float`
|
|
1224
|
-
|
|
1224
|
+
Scale between 0 and 1.
|
|
1225
1225
|
"""
|
|
1226
|
-
self.
|
|
1226
|
+
if self.mode == self.FLY:
|
|
1227
|
+
self.speed = 0.033 * self.anchorDistance * (100.0 ** float(scale) - 1.0) / 99.0
|
|
1228
|
+
else:
|
|
1229
|
+
defaultAnchorDistance = np.linalg.norm(self.defaultEye - self.defaultCenter)
|
|
1230
|
+
self.anchorDistance = 2.0 * float(scale) * defaultAnchorDistance
|
|
1231
|
+
self.anchorDistance = max(self.anchorDistance, 0.01)
|
|
1232
|
+
self.speed = 0.033 * self.anchorDistance
|
|
1233
|
+
self.eye = self.anchorPosition + self.anchorDistance * self.look
|
|
1234
|
+
self.Update()
|
|
1227
1235
|
|
|
1228
1236
|
def SetAnimating(self, animating):
|
|
1229
1237
|
self.animating = animating
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: bspy
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.1
|
|
4
4
|
Summary: Library for manipulating and rendering non-uniform B-splines
|
|
5
5
|
Home-page: http://github.com/ericbrec/BSpy
|
|
6
6
|
Author: Eric Brechner
|
|
@@ -37,7 +37,7 @@ Other methods add, subtract, and multiply splines, as well as confine spline cur
|
|
|
37
37
|
There are methods to evaluate spline values, derivatives, integrals, normals, curvature, and the Jacobian, as well as methods that return spline representations of derivatives, normals, integrals, graphs, and convolutions. In addition, there are methods to manipulate the domain of splines, including trim, join, reparametrize, transpose, reverse, add and remove knots, elevate and extrapolate, and fold and unfold. There are methods to manipulate the range of splines, including dot product, cross product, translate, rotate, scale, and transform. Finally, there are methods to compute the zeros and contours of a spline and to intersect two splines.
|
|
38
38
|
|
|
39
39
|
The [SplineOpenGLFrame](https://ericbrec.github.io/BSpy/bspy/splineOpenGLFrame.html) class is an
|
|
40
|
-
[OpenGLFrame](https://pypi.org/project/pyopengltk/) with custom shaders to render spline curves and surfaces.
|
|
40
|
+
[OpenGLFrame](https://pypi.org/project/pyopengltk/) with custom shaders to render spline curves and surfaces. Only tested on Windows systems.
|
|
41
41
|
|
|
42
42
|
The [DrawableSpline](https://ericbrec.github.io/BSpy/bspy/drawableSpline.html) class converts a
|
|
43
43
|
[Spline](https://ericbrec.github.io/BSpy/bspy/spline.html) to a curve, surface, or solid that can be drawn in a
|
|
@@ -48,11 +48,11 @@ Spline surfaces and solids with more than 3 dependent variables will have their
|
|
|
48
48
|
The [bspyApp](https://ericbrec.github.io/BSpy/bspy/bspyApp.html) class is a
|
|
49
49
|
[tkinter.Tk](https://docs.python.org/3/library/tkinter.html) app that hosts a
|
|
50
50
|
[SplineOpenGLFrame](https://ericbrec.github.io/BSpy/bspy/splineOpenGLFrame.html),
|
|
51
|
-
a listbox full of splines, and a set of controls to adjust and view the selected splines.
|
|
51
|
+
a listbox full of splines, and a set of controls to adjust and view the selected splines. Only tested on Windows systems.
|
|
52
52
|
|
|
53
53
|
The [bspyGraphics](https://ericbrec.github.io/BSpy/bspy/bspyApp.html#bspyGraphics) class is a graphics engine to display splines.
|
|
54
54
|
It launches a [bspyApp](https://ericbrec.github.io/BSpy/bspy/bspyApp.html) and issues commands to the app for use
|
|
55
|
-
in [jupyter](https://jupyter.org/) notebooks and other scripting environments.
|
|
55
|
+
in [jupyter](https://jupyter.org/) notebooks and other scripting environments. Only tested on Windows systems.
|
|
56
56
|
|
|
57
57
|

|
|
58
58
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|