@@ -52,23 +52,28 @@ def data(self):
5252 boundary = self ._loops [0 ].data
5353 holes = [loop .data for loop in self ._loops [1 :]]
5454 surface_type , surface = self ._get_surface_geometry (self ._surface )
55- return {"boundary" : boundary , "holes" : holes , "surface_type" : surface_type , "surface" : surface }
55+ surface_data = {"value" : surface .data , "type" : surface_type }
56+ return {"boundary" : boundary , "surface" : surface_data , "holes" : holes }
5657
5758 @data .setter
5859 def data (self , value ):
5960 boundary = RhinoBrepLoop .from_data (value ["boundary" ])
6061 holes = [RhinoBrepLoop .from_data (loop ) for loop in value ["holes" ]]
6162 self ._loops = [boundary ] + holes
62- type_ = value [ "surface_type" ]
63+
6364 # TODO: using the new serialization mechanism, surface.to_nurbs() should replace all this branching..
6465 # TODO: given that Plane, Sphere, Cylinder etc. all implement to_nurbs()
65- surface = value ["surface" ]
66+ surface_data = value ["surface" ]
67+ type_ = surface_data ["type" ]
68+ surface = surface_data ["value" ]
6669 if type_ == "plane" :
67- surface = self ._make_surface_from_plane_loop ( surface , boundary )
70+ surface = self ._make_surface_from_loop ( boundary )
6871 elif type_ == "sphere" :
69- surface = RhinoNurbsSurface .from_sphere (surface )
72+ surface = RhinoNurbsSurface .from_sphere (Sphere . from_data ( surface ) )
7073 elif type_ == "cylinder" :
71- surface = RhinoNurbsSurface .from_cylinder (surface )
74+ surface = RhinoNurbsSurface .from_cylinder (Cylinder .from_data (surface ))
75+ elif type_ == "nurbs" :
76+ surface = RhinoNurbsSurface .from_data (surface )
7277 elif type_ == "torus" :
7378 raise NotImplementedError ("Support for torus surface is not yet implemented!" )
7479 self ._surface = surface .rhino_surface
@@ -118,7 +123,7 @@ def _get_surface_geometry(surface):
118123 return "nurbs" , RhinoNurbsSurface .from_rhino (surface .ToNurbsSurface ())
119124
120125 @staticmethod
121- def _make_surface_from_plane_loop ( plane , loop ):
126+ def _make_surface_from_loop ( loop ):
122127 # order of corners determines the normal of the resulting surface
123128 corners = [loop .edges [i ].start_vertex .point for i in range (4 )]
124129 surface = RhinoNurbsSurface .from_corners (corners )
0 commit comments