@@ -324,9 +324,19 @@ class Bezier2D(PCurve2D):
324324
325325 def __init__ (self , control_points : typing .List [Point2D ]):
326326 self .control_points = control_points
327- self .degree = None
327+ self ._degree = None
328328 self .curve_connections = []
329329
330+ @property
331+ def degree (self ):
332+ return self ._degree
333+
334+ @degree .setter
335+ def degree (self , value ):
336+ raise AttributeError ("The 'degree' property is read-only. Use the Bezier2D.elevate_degree method to increase"
337+ "the degree of the curve while retaining the shape, or manually add or remove control "
338+ "points to change the degree directly." )
339+
330340 @staticmethod
331341 def bernstein_poly (n : int , i : int , t : int or float or np .ndarray ):
332342 r"""
@@ -544,6 +554,7 @@ def elevate_degree(self) -> "Bezier2D":
544554 new_control_points [0 , :] = P [0 , :]
545555 new_control_points [- 1 , :] = P [- 1 , :]
546556
557+ # Update all the other control points
547558 for i in range (1 , n + 1 ): # 1 <= i <= n
548559 new_control_points [i , :] = i / (n + 1 ) * P [i - 1 , :] + (1 - i / (n + 1 )) * P [i , :]
549560
@@ -595,9 +606,19 @@ class Bezier3D(PCurve3D):
595606
596607 def __init__ (self , control_points : typing .List [Point3D ]):
597608 self .control_points = control_points
598- self .degree = None
609+ self ._degree = None
599610 self .curve_connections = []
600611
612+ @property
613+ def degree (self ):
614+ return self ._degree
615+
616+ @degree .setter
617+ def degree (self , value ):
618+ raise AttributeError ("The 'degree' property is read-only. Use the Bezier3D.elevate_degree method to increase"
619+ "the degree of the curve while retaining the shape, or manually add or remove control "
620+ "points to change the degree directly." )
621+
601622 def to_iges (self , * args , ** kwargs ) -> aerocaps .iges .entity .IGESEntity :
602623 return aerocaps .iges .curves .BezierIGES (
603624 control_points_XYZ = self .get_control_point_array (),
@@ -833,6 +854,7 @@ def elevate_degree(self) -> "Bezier3D":
833854 new_control_points [0 , :] = P [0 , :]
834855 new_control_points [- 1 , :] = P [- 1 , :]
835856
857+ # Update all the other control points
836858 for i in range (1 , n + 1 ): # 1 <= i <= n
837859 new_control_points [i , :] = i / (n + 1 ) * P [i - 1 , :] + (1 - i / (n + 1 )) * P [i , :]
838860
0 commit comments