def __init__(self, x, y, degree=3, w=None): try: from geomdl import NURBS, utilities self.utilities = utilities except ImportError: error_message('The module `geomdl` is not installed, but it is required for NURBS!') self._x = x self._y = y self._n = len(x) if(w is None): w = np.ones(x.shape) self._w = w # Create the curve curve = NURBS.Curve() curve.degree = degree self._degree = degree cpoints = np.zeros((self._n,2)) cpoints[:,0] = x cpoints[:,1] = y self._cpoints = cpoints curve.ctrlpts = cpoints curve.knotvector = utilities.generate_knot_vector(degree, len(cpoints)) curve.weights = w self._curve = curve
def spline(wi, wi1, wi2, deg = 2, delta = .05): curve = NURBS.Curve() curve.degree = deg curve.ctrlpts = [wi, wi1, wi2] curve.knotvector = [0, 0, 0, 1, 1, 1] curve.delta = delta return curve.evalpts
def build_geomdl(cls, degree, knotvector, control_points, weights=None, normalize_knots=False): if weights is not None: curve = NURBS.Curve(normalize_kv=normalize_knots) else: curve = BSpline.Curve(normalize_kv=normalize_knots) curve.degree = degree if isinstance(control_points, np.ndarray): control_points = control_points.tolist() curve.ctrlpts = control_points if weights is not None: if isinstance(weights, np.ndarray): weights = weights.tolist() curve.weights = weights if isinstance(knotvector, np.ndarray): knotvector = knotvector.tolist() curve.knotvector = knotvector result = SvGeomdlCurve(curve) result.u_bounds = curve.knotvector[0], curve.knotvector[-1] return result
def full_circle2(radius=1): """ Generates a full NURBS circle from 7 control points. :param radius: radius of the circle :type radius: int, float :return: a NURBS curve :rtype: NURBS.Curve """ if radius <= 0: raise GeomdlException( "Curve radius cannot be less than and equal to zero") # Control points for a unit circle control_points = [[1.0, 0.5, 1.0], [0.0, 1.0, 0.5], [-1.0, 0.5, 1.0], [-1.0, -0.5, 0.5], [0.0, -1.0, 1.0], [1.0, -0.5, 0.5], [1.0, 0.5, 1.0]] # Set radius ctrlpts = [] if radius != 1: for point in control_points: npt = [i * radius for i in point[0:2]] npt.append(point[-1]) ctrlpts.append(npt) else: ctrlpts = control_points # Generate the curve curve = NURBS.Curve() curve.degree = 2 curve.ctrlptsw = ctrlpts curve.knotvector = [0, 0, 0, 0.33, 0.33, 0.66, 0.66, 1, 1, 1] # Return the generated curve return curve
def InterpolationNURBS(points, weights, knots, par, vellist, Tint, err, L, length, it_num): crv = NURBS.Curve() #задание кривой crv.degree = 3 #степень crv.ctrlpts = points #контрольные точки crv.weights = weights #весы опорных точек crv.knotvector = knots #узловой вектор x_list = [] y_list = [] t = par[0] s = 0 i = 0 print("Параметр u начальный и конечный: " + str(par)) while t <= par[1] and i < len(vellist) and s < length: result = crv.evaluate_single(t) der = crv.derivatives(t, order=2) x_list.append(result[0]) y_list.append(result[1]) duds1 = 1 / (sqrt(der[1][0] * der[1][0] + der[1][1] * der[1][1])) duds2 = (der[1][0] * der[2][0] + der[1][1] * der[2][1]) / (pow( der[1][0] * der[1][0] + der[1][1] * der[1][1], 2)) if i > 0: si = sqrt((pow((x_list[-1] - x_list[-2]), 2)) + (pow((y_list[-1] - y_list[-2]), 2))) s += si t = t + (vellist[i] * Tint + err) * duds1 + pow( vellist[i] * Tint + err, 2) * duds2 / 2 t = t i += 1 return x_list, y_list, s
def createNURBSSurface(self, pts, corsequences, sagsequences, degree=3): # Dimensions of the control points grid npoints_u = len(corsequences) npoints_v = len(sagsequences) # Weights vector weights = [1] * (npoints_u * npoints_v) # Combine weights vector with the control points list t_ctrlptsw = compat.combine_ctrlpts_weights(pts, weights) # Since NURBS-Python uses v-row order, we need to convert the exported ones n_ctrlptsw = compat.change_ctrlpts_row_order(t_ctrlptsw, npoints_u, npoints_v) # Since we have no information on knot vectors, let's auto-generate them n_knotvector_u = utils.generate_knot_vector(degree, npoints_u) n_knotvector_v = utils.generate_knot_vector(degree, npoints_v) # Create a NURBS surface instance surf = NURBS.Surface() # Using __call__ method to fill the surface object surf(degree, degree, npoints_u, npoints_v, n_ctrlptsw, n_knotvector_u, n_knotvector_v) return surf
def build_geomdl(cls, degree_u, degree_v, knotvector_u, knotvector_v, control_points, weights, normalize_knots=False): def convert_row(verts_row, weights_row): return [(x * w, y * w, z * w, w) for (x, y, z), w in zip(verts_row, weights_row)] if weights is None: surf = BSpline.Surface(normalize_kv=normalize_knots) else: surf = NURBS.Surface(normalize_kv=normalize_knots) surf.degree_u = degree_u surf.degree_v = degree_v if weights is None: ctrlpts = control_points else: ctrlpts = list(map(convert_row, control_points, weights)) surf.ctrlpts2d = ctrlpts surf.knotvector_u = knotvector_u surf.knotvector_v = knotvector_v result = SvGeomdlSurface(surf) result.u_bounds = surf.knotvector_u[0], surf.knotvector_u[-1] result.v_bounds = surf.knotvector_v[0], surf.knotvector_v[-1] return result
def generateNURBS(self, curve_pts, degree, weights=None): # Create a NURBS curve instance curve = NURBS.Curve() # Set evaluation delta curve.delta = 0.01 # Set curve degree curve.degree = degree # Set weights # weights = [1.0, 10.0, 1.0, 1.0, 1.0, 1.0] if weights is None: weights = [1] * (len(curve_pts)) ctrlptsw = self.combine_ctrlpts_weights(curve_pts, weights) # Set control points # curve.ctrlpts = [[5.0, 5.0, 1.0], [100.0, 100.0, 10.0], [10.0, 15.0, 1.0], [15.0, 15.0, 1.0], [15.0, 10.0, 1.0], [10.0, 5.0, 1.0]] curve.ctrlpts = ctrlptsw # Auto-generate knot vector curve.knotvector = utils.generate_knot_vector(curve.degree, len(curve.ctrlpts)) # Set knot vector # curve.knotvector = [0.0, 0.0, 0.0, 0.0, 0.33, 0.66, 1.0, 1.0, 1.0, 1.0] # return curve, curve.knotvector return curve
def generateNURBS(curve_pts, degree, weights=None): # Create a NURBS curve instance curve = NURBS.Curve() # Set evaluation delta curve.delta = 0.01 # Set curve degree curve.degree = degree if heart == 0: # Set weights - obs. the 10th and 20th points are setted to 100 because is the down corner of the lung weights = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 100.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 100.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] else: # Set weights - obs. the 5yh, 10th are setted to 100 because is in the heart region weights = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 100.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 100.0, 1.0, 1.0, 1.0, 100.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] ctrlptsw = combine_ctrlpts_weights(curve_pts, weights) # Set control points curve.ctrlpts = ctrlptsw # Auto-generate knot vector curve.knotvector = utils.generate_knot_vector(curve.degree, len(curve.ctrlpts)) return curve, curve.knotvector
def initialize_NURBS(curve_param, sim_param, y_objective): """Builds NURBS from given control points""" # initialization: curve = NURBS.Curve() curve.degree = curve_param.curve_degree ctr_points = [] # assign control points according to current y_vector # build control points from the y-values and set additional knots to enforce periodicity: additional_nodes = curve.degree + 3 # defined by order of spline defining the width of the local support # also needs to force symmetry for area left of x = 0., since this is also used in cubic interpolation for i in range(additional_nodes): # set knots left of domain Omega to enforce left hand side symmetry # add points at beginning of spline, that correspond to the right part of the spline to enforce periodicity # needs to start from leftmost point to create a proper spline ctr_points.append([sim_param.x_min - (additional_nodes - i) * curve_param.delta_x_control, y_objective[-(additional_nodes - i)]]) for i in range(curve_param.n_ctr): # set control points within Omega ctr_points.append([curve_param.x_control[i], y_objective[i]]) for i in range(additional_nodes): # set knots right of domain Omega to enforce right hand side symmetry # add points at end of spline, that correspond to the begin of the spline to enforce periodicity # f(x_max) = f(x_min) must be enforced ctr_points.append([sim_param.x_max + i * curve_param.delta_x_control, y_objective[i]]) # set up the curve curve.ctrlpts = ctr_points curve.knotvector = utilities.generate_knot_vector(curve.degree, len(curve.ctrlpts)) # Auto-generate knot vector curve.sample_size = curve_param.evaluation_size # Set number of evaluation points used in interpolation later return curve
def full_circle(radius=1): """ Generates a NURBS full circle from 9 control points. :param radius: radius of the circle :type radius: int, float :return: a NURBS curve :rtype: NURBS.Curve2D """ if radius <= 0: raise ValueError("Curve radius cannot be less than and equal to zero") # Control points for a unit circle control_points = [[0.0, -1.0, 1.0], [-0.707, -0.707, 0.707], [-1.0, 0.0, 1.0], [-0.707, 0.707, 0.707], [0.0, 1.0, 1.0], [0.707, 0.707, 0.707], [1.0, 0.0, 1.0], [0.707, -0.707, 0.707], [0.0, -1.0, 1.0]] # Set radius ctrlpts = [] if radius != 1: for point in control_points: npt = [i * radius for i in point[0:2]] npt.append(point[-1]) ctrlpts.append(npt) else: ctrlpts = control_points # Generate the curve curve = NURBS.Curve2D() curve.degree = 2 curve.ctrlpts = ctrlpts curve.knotvector = [0, 0, 0, 0.25, 0.25, 0.5, 0.5, 0.75, 0.75, 1, 1, 1] # Return the generated curve return curve
def __init__(self, geomData): self.curv = NURBS.Curve() self.curv.degree = geomData['degree_u'] # self.curv.ctrlpts_size = geomData['ctrlpts_size_u'] self.curv.ctrlpts = self.getUnweightedCpts(geomData['ctrlpts'], geomData['weights']) self.curv.weights = geomData['weights'] self.curv.knotvector = geomData['knotvector_u']
def cylinder(radius=1, height=1): """ Generates a NURBS cylindrical surface. The cylindrical surface example is kindly contributed by John-Eric Dufour. :param radius: radius of the cylinder :type radius: int, float :param height: height of the cylinder :type height: int, float :return: a NURBS surface :rtype: NURBS.Surface """ if radius <= 0 or height <= 0: raise ValueError("Radius and/or height cannot be less than and equal to zero") # Control points for a base cylinder control_points = [[[1.0, 0.0, 0.0, 1.0], [0.7071, 0.7071, 0.0, 0.7071], [0.0, 1.0, 0.0, 1.0], [-0.7071, 0.7071, 0.0, 0.7071], [-1.0, 0.0, 0.0, 1.0], [-0.7071, -0.7071, 0.0, 0.7071], [0.0, -1.0, 0.0, 1.0], [0.7071, -0.7071, 0.0, 0.7071], [1.0, 0.0, 0.0, 1.0]], [[1.0, 0.0, 1.0, 1.0], [0.7071, 0.7071, 0.7071, 0.7071], [0.0, 1.0, 1.0, 1.0], [-0.7071, 0.7071, 0.7071, 0.7071], [-1.0, 0.0, 1.0, 1.0], [-0.7071, -0.7071, 0.7071, 0.7071], [0.0, -1.0, 1.0, 1.0], [0.7071, -0.7071, 0.7071, 0.7071], [1.0, 0.0, 1.0, 1.0]]] # Set height if height != 1: ctrlpts_top = [] for point in control_points[1]: npt = point npt[2] = npt[2] * height ctrlpts_top.append(npt) control_points[1] = ctrlpts_top # Set radius ctrlpts = [] if radius != 1: for row in control_points: temp = [] for point in row: npt = [i * radius for i in point[0:2]] npt.append(point[2]) npt.append(point[3]) temp.append(npt) ctrlpts.append(temp) else: ctrlpts = control_points # Generate the surface surface = NURBS.Surface() surface.degree_u = 1 surface.degree_v = 2 surface.ctrlpts2d = ctrlpts surface.knotvector_u = [0.0, 0.0, 1.0, 1.0] surface.knotvector_v = [0.0, 0.0, 0.0, 0.25, 0.25, 0.5, 0.5, 0.75, 0.75, 1.0, 1.0, 1.0] # Return the generated surface return surface
def create_bezie_curve(self,p0, p1, p2, w): curve = NURBS.Curve() curve.degree = 2 curve.ctrlpts = [p0, p1, p2] curve.weights = [1, w, 1] curve.knotvector = utilities.generate_knot_vector(curve.degree, len(curve.ctrlpts)) curve.sample_size = 200 curve.evaluate() return curve
def __init__(self, geomData): self.surf = NURBS.Surface() self.surf.degree_u = geomData['degree_u'] self.surf.degree_v = geomData['degree_v'] self.surf.ctrlpts_size_u = geomData['ctrlpts_size_u'] self.surf.ctrlpts_size_v = geomData['ctrlpts_size_v'] self.surf.ctrlpts = self.getUnweightedCpts(geomData['ctrlpts'], geomData['weights']) self.surf.weights = geomData['weights'] self.surf.knotvector_u = geomData['knotvector_u'] self.surf.knotvector_v = geomData['knotvector_v']
def nurbs_surface(): """ Creates a NURBS surface instance """ surf = NURBS.Surface() surf.degree_u = 2 surf.degree_v = 2 surf.ctrlpts_size_u = 3 surf.ctrlpts_size_v = 3 surf.ctrlpts = [[0, 0, 0], [0, 1, 0], [0, 2, -3], [1, 0, 6], [1, 1, 0], [1, 2, 0], [2, 0, 0], [2, 1, 0], [2, 2, 3]] # use the auto-generated weights vector surf.knotvector_u = [0, 0, 0, 1, 1, 1] surf.knotvector_v = [0, 0, 0, 1, 1, 1] return surf
def __init__(self, geomData): self.vol = NURBS.Volume() self.vol.degree_u = geomData['degree_u'] self.vol.degree_v = geomData['degree_v'] self.vol.degree_w = geomData['degree_w'] self.vol.ctrlpts_size_u = geomData['ctrlpts_size_u'] self.vol.ctrlpts_size_v = geomData['ctrlpts_size_v'] self.vol.ctrlpts_size_w = geomData['ctrlpts_size_w'] self.vol.ctrlpts = self.getUnweightedCpts(geomData['ctrlpts'], geomData['weights']) self.vol.weights = geomData['weights'] self.vol.knotvector_u = geomData['knotvector_u'] self.vol.knotvector_v = geomData['knotvector_v'] self.vol.knotvector_w = geomData['knotvector_w']
def plot_BC(BC_ctrlpts, BC_knot, p): """Plot a boundary curve :param BC_ctrlpts: boundary control points :param BC_knot: boundary knot vector :param p: boundary degree """ cu = NURBS.Curve() cu.degree = p cu.ctrlpts = BC_ctrlpts.tolist() cu.knotvector = BC_knot cu.delta = 0.01 # Plot the control point polygon and the evaluated curve cu.vis = VisMPL.VisCurve2D() cu.render()
def init_nurbs(p, q, knot_u, knot_v, ctrlpts): """Create a python NURBS surface object :param p,q: degree in U and V directions :param knot_u,knot_v: knot vectors in U and V directions :param ctrlpts: control point matrix """ surf = NURBS.Surface() surf.degree_u = p surf.degree_v = q surf.ctrlpts2d = ctrlpts.tolist() surf.knotvector_u = knot_u surf.knotvector_v = knot_v return surf
def ns_curve2(): # Create a curve instance curve = NURBS.Curve() # Set curve degree curve.degree = 5 # Set weighted control points curve.ctrlptsw = [[5.0, 15.0, 0.0, 0.1], [10.0, 25.0, 5.0, 0.2], [20.0, 20.0, 10.0, 1.0], [15.0, -5.0, 15.0, 1.0], [7.5, 10.0, 20.0, 1.0], [12.5, 15.0, 25.0, 1.0], [15.0, 0.0, 30.0, 0.5], [5.0, -10.0, 35.0, 1.0], [10.0, 15.0, 40.0, 0.7], [5.0, 15.0, 30.0, 1.0], [15.0, 20.0, 40.0, 1.0]] # Set knot vector curve.knotvector = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] return curve
def nurbs_curve(): """ Creates a 4th order 2D NURBS Curve instance """ # Create a curve instance curve = NURBS.Curve() # Set curve degree curve.degree = 3 # Set weighted control points curve.ctrlptsw = [[5.0, 5.0, 1.0], [10.0, 10.0, 1.0], [20.0, 15.0, 1.0], [35.0, 15.0, 1.0], [45.0, 10.0, 1.0], [50.0, 5.0, 1.0]] # Set knot vector curve.knotvector = [0.0, 0.0, 0.0, 0.0, 0.33, 0.66, 1.0, 1.0, 1.0, 1.0] return curve
def test_nurbs_surface_ctrlpts2(): surf = NURBS.Surface() ctrlpts = [[1.0, 1.0, 10.0, 1.0], [1.0, 2.0, 11.0, 1.0], [1.0, 3.0, 12.0, 1.0], [2.0, 1.0, 13.0, 1.0], [2.0, 2.0, 14.0, 1.0], [2.0, 3.0, 15.0, 1.0], [3.0, 1.0, 16.0, 1.0], [3.0, 2.0, 17.0, 1.0], [3.0, 3.0, 18.0, 1.0], [4.0, 1.0, 19.0, 1.0], [4.0, 2.0, 20.0, 1.0], [4.0, 3.0, 21.0, 1.0]] surf.ctrlpts_size_v = 3 surf.ctrlpts_size_u = 4 surf.degree_u = 2 surf.degree_v = 2 surf.ctrlptsw = ctrlpts # Check assignment assert surf.ctrlpts2d[2][1] == [3.0, 2.0, 17.0, 1.0]
def letter_i(): base = NURBS.Curve() base.degree = 3 base.ctrlptsw = [[1, 20, 1], [0, 10, 0.5], [0, 19, 1], [0, 10, 1], [0, 1, 1], [0, 0, 0.5], [1, 0, 1], [1, 0, 0.5], [2, 1, 1], [2, 10, 1], [2, 19, 1], [1, 10, 0.5], [1, 20, 1]] base.knotvector = utilities.generate_knot_vector(base.degree, len(base.ctrlpts)) hat = curve2d.full_circle(radius=1) operations.translate(hat, (1, 22), inplace=True) letter = Multi.MultiCurve() letter.add([base, hat]) return letter
def test_nurbs_surface_weights3(): surf = NURBS.Surface() ctrlpts = [[1.0, 1.0, 10.0, 1.0], [1.0, 2.0, 11.0, 1.0], [1.0, 3.0, 12.0, 1.0], [2.0, 1.0, 13.0, 1.0], [2.0, 2.0, 14.0, 0.5], [2.0, 3.0, 15.0, 1.0], [3.0, 1.0, 16.0, 0.2], [3.0, 2.0, 17.0, 1.0], [3.0, 3.0, 18.0, 1.0], [4.0, 1.0, 19.0, 1.0], [4.0, 2.0, 20.0, 1.0], [4.0, 3.0, 21.0, 1.0]] surf.ctrlpts_size_v = 3 surf.ctrlpts_size_u = 4 surf.degree_u = 2 surf.degree_v = 2 surf.ctrlptsw = ctrlpts # Check assignment assert surf.weights[4] == 0.5
def eval_bspline(b: pyiges.curves_surfaces.BSpline, delta=0.001, n=10): """ Return: numpy array of sampled points on bspline """ # Create a geomdl 3-dimensional B-spline Curve from incoming pyiges spline curve = NURBS.Curve() curve.degree = b.M curve.ctrlpts = b.control_points curve.weights = b.W + [1] curve.knotvector = b.T curve.delta = delta # TODO sampling - this could get out of hand depending on model dims and scale #TODO conditional delta: min length, n and check for straight lines return np.array(curve.evalpts)
def test_nurbs_surface_knot_vector_v(): surf = NURBS.Surface() ctrlpts = [[1.0, 1.0, 10.0, 1.0], [1.0, 2.0, 11.0, 1.0], [1.0, 3.0, 12.0, 1.0], [2.0, 1.0, 13.0, 1.0], [2.0, 2.0, 14.0, 1.0], [2.0, 3.0, 15.0, 1.0], [3.0, 1.0, 16.0, 1.0], [3.0, 2.0, 17.0, 1.0], [3.0, 3.0, 18.0, 1.0], [4.0, 1.0, 19.0, 1.0], [4.0, 2.0, 20.0, 1.0], [4.0, 3.0, 21.0, 1.0]] surf.ctrlpts_size_v = 3 surf.ctrlpts_size_u = 4 surf.degree_u = 2 surf.degree_v = 2 surf.ctrlptsw = ctrlpts surf.knotvector_u = [0.0, 0.0, 0.0, 0.5, 1.0, 1.0, 1.0] surf.knotvector_v = [0.0, 0.0, 0.0, 1.0, 1.0, 1.0] assert surf.knotvector_v == [0.0, 0.0, 0.0, 1.0, 1.0, 1.0]
def nurbs_surface(): """ Creates a NURBS Surface instance """ # Create a surface instance surf = NURBS.Surface() # Set degrees surf.degree_u = 3 surf.degree_v = 3 # Set weighted control points surf.set_ctrlpts(CONTROL_POINTS, 6, 6) # Set knot vectors surf.knotvector_u = [0.0, 0.0, 0.0, 0.0, 0.33, 0.66, 1.0, 1.0, 1.0, 1.0] surf.knotvector_v = [0.0, 0.0, 0.0, 0.0, 0.33, 0.66, 1.0, 1.0, 1.0, 1.0] return surf
def nurbs_surface2(): """ Creates a NURBS Surface instance (alternative control points) """ # Create a surface instance surf = NURBS.Surface() # Set degrees surf.degree_u = 3 surf.degree_v = 3 # Set weighted control points surf.ctrlpts_size_u = 6 surf.ctrlpts_size_v = 6 surf.ctrlptsw = CONTROL_POINTS2 # Set knot vectors surf.knotvector_u = [0.0, 0.0, 0.0, 0.0, 0.33, 0.66, 1.0, 1.0, 1.0, 1.0] surf.knotvector_v = [0.0, 0.0, 0.0, 0.0, 0.33, 0.66, 1.0, 1.0, 1.0, 1.0] return surf
def load_spline_surf(self, spline): # Create a BSpline surface if spline["v_rational"] or spline["u_rational"]: surf = NURBS.Surface() control_points = np.array(spline["poles"]) size_u, size_v = control_points.shape[0], control_points.shape[1] # Set degrees surf.degree_u = spline["u_degree"] surf.degree_v = spline["v_degree"] # Set control points surf.ctrlpts2d = np.concatenate( [control_points, np.ones((size_u, size_v, 1))], 2).tolist() surf.knotvector_v = spline["v_knots"] surf.knotvector_u = spline["u_knots"] weights = spline["weights"] l = [] for i in weights: l += i surf.weights = l return surf else: surf = BSpline.Surface() # Set degrees surf.degree_u = spline["u_degree"] surf.degree_v = spline["v_degree"] # Set control points surf.ctrlpts2d = spline["poles"] # Set knot vectors surf.knotvector_u = spline["u_knots"] surf.knotvector_v = spline["v_knots"] return surf
def _process_2d_spline(self, spline: dxf.Spline, delta=0.1): """ Uses geomdl module to create intermediate b-spline from dxf spline. This is then sampled as a linestring since shapely does not support splines. """ curve = NURBS.Curve() curve.degree = spline.dxf.degree curve.ctrlpts = spline.control_points curve.weights = [1] * spline.control_point_count() #spline.weights #curve.weights = spline.weights + [1] * np.array(spline.control_point_count()- len(spline.weights)) curve.knotvector = spline.knots curve.delta = delta # TODO sampling - this could get out of hand depending on model dims and scale #TODO conditional delta: min length, n and check for straight lines xyz = np.array(curve.evalpts) xy = list([x[:-1] for x in xyz]) #remove z data pl = sg.LineString(xy) self.geometry.append(pl)