22
33import Rhino
44
5+ import diffCheck
56from diffCheck import diffcheck_bindings
67from diffCheck import df_cvt_bindings as df_cvt
78
1516class DFJointSegmentator (component ):
1617 def __init__ (self ):
1718 super (DFJointSegmentator , self ).__init__ ()
18- def RunScript (self ,
19- i_clusters : typing .List [Rhino .Geometry .PointCloud ],
19+ def RunScript (self ,
20+ i_clusters : typing .List [Rhino .Geometry .PointCloud ],
2021 i_assembly : diffCheck .df_geometries .DFAssembly ,
2122 i_angle_threshold : float ,
2223 i_distance_threshold : float ):
2324
24- if i_angle_threshold is None : i_angle_threshold = 0.1
25- if i_distance_threshold is None : i_distance_threshold = 0.1
26-
25+ if i_angle_threshold is None :
26+ i_angle_threshold = 0.1
27+ if i_distance_threshold is None :
28+ i_distance_threshold = 0.1
29+
2730 if len (i_clusters ) == 0 :
2831 raise ValueError ("No clusters given." )
2932 if not isinstance (i_clusters [0 ], Rhino .Geometry .PointCloud ):
3033 raise ValueError ("The input clusters must be PointClouds." )
31-
34+
3235 # get number of joints
3336 n_joints = i_assembly .total_number_joints
3437
@@ -60,13 +63,13 @@ def RunScript(self,
6063 # find the corresponding clusters and merge them
6164 df_joint_segment = diffcheck_bindings .dfb_segmentation .DFSegmentation .associate_clusters (df_joint , df_cloud_clusters , i_angle_threshold , i_distance_threshold )
6265 diffcheck_bindings .dfb_segmentation .DFSegmentation .clean_unassociated_clusters (df_cloud_clusters , [df_joint_segment ], [df_joint ], i_angle_threshold , i_distance_threshold )
63-
66+
6467 # register the merged clusters to the reference point cloud
6568 registration = diffcheck_bindings .dfb_registrations .DFRefinedRegistration .O3DICP (df_joint_segment , ref_df_joint_cloud )
6669 res = registration .transformation_matrix
6770 transforms .append (df_cvt .cvt_ndarray_2_rh_transform (res ))
6871 rh_joint_segments .append (df_cvt .cvt_dfcloud_2_rhcloud (df_joint_segment ))
69-
72+
7073 o_joint_segments = []
7174 o_transforms = []
7275 o_reference_point_clouds = []
@@ -76,6 +79,6 @@ def RunScript(self,
7679 o_transforms .append (transform )
7780 o_reference_point_clouds .append (_joint_cloud )
7881 else :
79- ghenv .Component .AddRuntimeMessage (RML .Warning , "Some joints could not be segmented and were ignored." )
82+ ghenv .Component .AddRuntimeMessage (RML .Warning , "Some joints could not be segmented and were ignored." ) # noqa: F821
8083
81- return o_joint_segments , o_transforms , o_reference_point_clouds
84+ return o_joint_segments , o_transforms , o_reference_point_clouds
0 commit comments