@@ -1359,94 +1359,5 @@ def trace_one_direction(sign):
13591359 print ("γ rows:" , gamma_rows )
13601360 print ("points:" , len (curve_3d ))
13611361 print ("first/last:" , curve_3d [0 ], curve_3d [- 1 ])
1362- s1 = bern_to_nurbs_bezier (ts1 ,rational = False )
1363- s2 = bern_to_nurbs_bezier (ts2 ,rational = False )
1364- try :
1365-
1366- from dataclasses import dataclass , field
1367-
1368-
1369- @dataclass
1370- class PointMaterial :
1371- color : tuple [float , float , float , float ] = field (default = (1.0 , 1.0 , 1.0 , 1.0 ))
1372- size : int = 8
1373-
1374-
1375- @dataclass
1376- class ControlNetMaterial :
1377- color : tuple [float , float , float , float ] = field (default = (1.0 , 1.0 , 1.0 , 1.0 ))
1378- control_point_material : PointMaterial = field (default_factory = PointMaterial )
1379-
1380-
1381- @dataclass
1382- class CurveMaterial :
1383- color : tuple [float , float , float , float ] = field (default = (1.0 , 1.0 , 1.0 , 1.0 ))
1384- show_control_net : bool = field (default = False )
1385- control_net_material : ControlNetMaterial = field (default_factory = ControlNetMaterial )
1386-
1387-
1388- @dataclass
1389- class WiresMaterial (CurveMaterial ):
1390-
1391- u_count : int = field (default = 0 )
1392- v_count : int = field (default = 0 )
1393-
1394-
1395- @dataclass
1396- class SurfaceMaterial :
1397-
1398- color : tuple [float , float , float , float ] = field (default = (0.5 , 0.5 , 0.9 , 0.05 ))
1399- wires_material : WiresMaterial = field (
1400- default_factory = lambda : WiresMaterial ((1.0 , 1.0 , 1.0 , 1.0 ), show_control_net = False , u_count = 0 ,
1401- v_count = 0 )
1402- )
1403- show_control_net : bool = field (default = False )
1404- control_net_material : ControlNetMaterial = field (default_factory = ControlNetMaterial )
1405-
1406-
1407- # Defaults
1408- ssx_point_material = PointMaterial (color = (0.0 , 1.0 , 0.5 , 1.0 ), size = 12 )
1409- ssx_branch_material : CurveMaterial = CurveMaterial ((0.0 , 1.0 , 0.5 , 1.0 ),
1410- show_control_net = True ,
1411- control_net_material = ControlNetMaterial ((0.0 , 1.0 , 0.5 , 0.7 ),
1412-
1413- control_point_material = PointMaterial (
1414- (0.0 , 1.0 , 0.5 ,
1415- 0.4 ), size = 8 )
1416- )
1417- )
1418-
1419- surface_material : SurfaceMaterial = SurfaceMaterial ()
1420-
1421- from mmcore .extras .renderer .renderer3d import Viewer ,OrbitCamera
1422- from mmcore .geom .bvh .lbvh import AABB
1423- bb = AABB .from_points (s1 .control_points .reshape (- 1 , 3 )).merge (AABB .from_points (s2 .control_points .reshape (- 1 , 3 )))
1424- viewer = Viewer (camera = OrbitCamera (target = bb .centroid (), distance = np .linalg .norm (bb .diag ()) * 2 , near = 1.0 ))
1425-
1426- viewer .add_nurbs_surface (s1 , color = surface_material .wires_material .color , surface_color = surface_material .color ,
1427- u_count = surface_material .wires_material .u_count ,
1428- v_count = surface_material .wires_material .v_count )
1429- viewer .add_nurbs_surface (
1430- s2 , color = surface_material .wires_material .color , surface_color = surface_material .color ,
1431- u_count = surface_material .wires_material .u_count , v_count = surface_material .wires_material .v_count
1432-
1433- )
1434- from mmcore .geom ._nurbs_interp import interpolate_curve
1435- from mmcore .geom ._nurbs_eval import NURBSCurveTuple
1436-
1437- control_points ,kv = interpolate_curve (curve_3d ,min (3 ,len (curve_3d )- 1 ))
1438- branch = NURBSCurveTuple (order = min (3 ,len (curve_3d )- 1 )+ 1 ,knot = np .array (kv ),control_points = np .array (control_points ),weights = np .ones (len (control_points )) )
1439- viewer .add_nurbs_curve (branch , color = ssx_branch_material .color )
1440- if ssx_branch_material .show_control_net :
1441- for p in branch .control_points :
1442- viewer .add_point3d (p ,
1443- color = ssx_branch_material .control_net_material .control_point_material .color ,
1444- size_px = ssx_branch_material .control_net_material .control_point_material .size )
1445- viewer .run ()
1446- except Exception as e :
1447- traceback .print_exc ()
1448-
14491362
1450- print (s1 )
1451- print (s2 )
14521363 print (np .array (curve_3d ).tolist ())
0 commit comments