-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNURBS.py
44 lines (35 loc) · 999 Bytes
/
NURBS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from geomdl import BSpline
from geomdl import knotvector
# Import Matplotlib visualization module
from geomdl.visualization import VisMPL
# Create the curve instance
def createCurveInstance():
crv = BSpline.Curve()
return crv
# Set degree
def setDegree(crv, degree):
crv.degree = degree
# Set control points
def setControlPts(crv, pts):
crv.ctrlpts = pts
# Set knot vector
def setKnotVector(crv):
crv.knotvector = knotvector.generate(crv.degree, crv.ctrlpts_size)
# Insert knot
def insertKnor(crv, val):
crv.insert_knot(0.3)
# Set the visualization component of the curve
def vis(crv):
crv.vis = VisMPL.VisCurve2D()
# Plot the curve
def crvPlot(crv):
crv.render()
def geoSetUp(deg, pts):
crv = BSpline.Curve()
crv.degree = deg
crv.ctrlpts = pts
crv.knotvector = knotvector.generate(crv.degree, crv.ctrlpts_size)
return crv
def crvShow(crv):
crv.vis = VisMPL.VisCurve2D()
crv.render()