@@ -61,27 +61,30 @@ def rhino_surface_from_parameters(
6161 is_u_periodic = False ,
6262 is_v_periodic = False ,
6363):
64- rhino_surface = Rhino .Geometry .NurbsSurface .Create (3 , True , u_degree + 1 , v_degree + 1 , len (points [0 ]), len (points ))
64+ u_order = u_degree + 1
65+ v_order = v_degree + 1
66+ u_point_count = len (points )
67+ v_point_count = len (points [0 ])
68+ is_rational = True # TODO: check if all weights are the same
69+ dimensions = 3
70+ rhino_surface = Rhino .Geometry .NurbsSurface .Create (dimensions , is_rational , u_order , v_order , u_point_count , v_point_count )
71+
6572 u_knotvector = [knot for knot , mult in zip (u_knots , u_mults ) for _ in range (mult )]
6673 v_knotvector = [knot for knot , mult in zip (v_knots , v_mults ) for _ in range (mult )]
67- u_count = len (points [0 ])
68- v_count = len (points )
69- u_order = u_degree + 1
70- v_order = v_degree + 1
7174 # account for superfluous knots
7275 # https://developer.rhino3d.com/guides/opennurbs/superfluous-knots/
73- if len (u_knotvector ) == u_count + u_order :
76+ if len (u_knotvector ) == u_point_count + u_order :
7477 u_knotvector [:] = u_knotvector [1 :- 1 ]
75- if len (v_knotvector ) == v_count + v_order :
78+ if len (v_knotvector ) == v_point_count + v_order :
7679 v_knotvector [:] = v_knotvector [1 :- 1 ]
7780 # add knots
7881 for index , knot in enumerate (u_knotvector ):
7982 rhino_surface .KnotsU [index ] = knot
8083 for index , knot in enumerate (v_knotvector ):
8184 rhino_surface .KnotsV [index ] = knot
8285 # add control points
83- for i in range (v_count ):
84- for j in range (u_count ):
86+ for i in range (u_point_count ):
87+ for j in range (v_point_count ):
8588 rhino_surface .Points .SetPoint (i , j , point_to_rhino (points [i ][j ]), weights [i ][j ])
8689 return rhino_surface
8790
0 commit comments