def set_uniform(self, control_points: Sequence['Vertex'], degree: int = 3) -> None: """ B-spline with uniform knot vector, does NOT start and end at your first and last control points. """ self.dxf.flags = 0 self.dxf.degree = degree self.control_points = control_points self.knots = uniform_knot_vector(len(control_points), degree + 1)
def set_closed(self, control_points: Sequence["Vertex"], degree=3) -> None: """ Closed B-spline with uniform knot vector, start and end at your first control point. """ self.dxf.flags = self.PERIODIC | self.CLOSED self.dxf.degree = degree self.control_points = control_points # type: ignore self.control_points.extend(control_points[:degree]) # AutoDesk Developer Docs: # If the spline is periodic, the length of knot vector will be greater # than length of the control array by 1, but this does not work with # BricsCAD. self.knots = uniform_knot_vector(len(self.control_points), degree + 1)
def test_auditing_weight_count(self, auditor, spline, degree): order = degree + 1 spline.dxf.degree = degree count = required_control_points(order) add_n_control_points(spline, count) spline.knots = uniform_knot_vector(count, order) spline.weights = range(count - 1) spline.audit(auditor) assert len(auditor.fixes) == 1 assert auditor.fixes[0].code == AuditError.INVALID_SPLINE_WEIGHT_COUNT # Test if invalid spline will be destroyed: auditor.empty_trashcan() assert spline.is_alive is False