1515ABSTOL = Rhino .RhinoDoc .ActiveDoc .ModelAbsoluteTolerance
1616
1717class DFJointSegmentator (component ):
18- # def __init__(self):
19- # super(DFJointSegmentator, self).__init__()
18+ def __init__ (self ):
19+ super (DFJointSegmentator , self ).__init__ ()
2020 def RunScript (self ,
2121 i_clusters : typing .List [Rhino .Geometry .PointCloud ],
2222 i_assembly : diffCheck .df_geometries .DFAssembly ,
2323 i_angle_threshold : float ,
2424 i_distance_threshold : float ):
25- """
26- Amongst clusters, associates the clusters to the individual joints,
27- creates a reference point cloud for each joint,
28- and returns the joint segments, the reference point clouds, and the ICP transformations from the first to the second.
29-
30- :param i_clusters: The clusters to be associated to the joints.
31- :param i_assembly: The DFAssembly containing the joints we want to segment.
32- :param i_angle_threshold: The angle threshold for the association of the clusters to the joints.
33- :param i_distance_threshold: The distance threshold for the association of the clusters to the joints.
34- """
25+
3526 if i_angle_threshold is None : i_angle_threshold = 0.1
3627 if i_distance_threshold is None : i_distance_threshold = 0.1
3728
@@ -45,44 +36,44 @@ def RunScript(self,
4536 n_joints = i_assembly .total_number_joints
4637
4738 # prepping the reference meshes
48- joints = [[] for _ in range (n_joints )]
39+ df_joints = [[] for _ in range (n_joints )]
4940 for joint in i_assembly .all_joints :
5041 for face in joint .faces :
5142 face = face .to_mesh ()
5243 face .Subdivide ()
5344 face .Faces .ConvertQuadsToTriangles ()
54- joints [joint .id ].append (df_cvt .cvt_rhmesh_2_dfmesh (face ))
45+ df_joints [joint .id ].append (df_cvt .cvt_rhmesh_2_dfmesh (face ))
5546
56- joint_clouds = []
47+ ref_rh_joint_clouds = []
5748 transforms = []
58- joint_segments = []
59- df_clouds = [df_cvt .cvt_rhcloud_2_dfcloud (cluster ) for cluster in i_clusters ]
49+ rh_joint_segments = []
50+ df_cloud_clusters = [df_cvt .cvt_rhcloud_2_dfcloud (cluster ) for cluster in i_clusters ]
6051
6152 # for each joint, find the corresponding clusters and merge them, generate a reference point cloud, and register the merged clusters to the reference point cloud
62- for joint in joints :
53+ for df_joint in df_joints :
6354 # create the reference point cloud
64- joint_cloud = diffcheck_bindings .dfb_geometry .DFPointCloud ()
55+ ref_df_joint_cloud = diffcheck_bindings .dfb_geometry .DFPointCloud ()
6556
66- for face in joint :
67- face_cloud = face .sample_points_uniformly (1000 )
68- joint_cloud .add_points (face_cloud )
57+ for face in df_joint :
58+ ref_face_cloud = face .sample_points_uniformly (1000 )
59+ ref_df_joint_cloud .add_points (ref_face_cloud )
6960
70- joint_clouds .append (df_cvt .cvt_dfcloud_2_rhcloud (joint_cloud ))
61+ ref_rh_joint_clouds .append (df_cvt .cvt_dfcloud_2_rhcloud (ref_df_joint_cloud ))
7162
7263 # find the corresponding clusters and merge them
73- segment = diffcheck_bindings .dfb_segmentation .DFSegmentation .associate_clusters (joint , df_clouds , i_angle_threshold , i_distance_threshold )
74- diffcheck_bindings .dfb_segmentation .DFSegmentation .clean_unassociated_clusters (df_clouds , [segment ], [joint ], i_angle_threshold , i_distance_threshold )
64+ df_joint_segment = diffcheck_bindings .dfb_segmentation .DFSegmentation .associate_clusters (df_joint , df_cloud_clusters , i_angle_threshold , i_distance_threshold )
65+ diffcheck_bindings .dfb_segmentation .DFSegmentation .clean_unassociated_clusters (df_cloud_clusters , [df_joint_segment ], [df_joint ], i_angle_threshold , i_distance_threshold )
7566
7667 # register the merged clusters to the reference point cloud
77- registration = diffcheck_bindings .dfb_registrations .DFRefinedRegistration .O3DICP (segment , joint_cloud )
68+ registration = diffcheck_bindings .dfb_registrations .DFRefinedRegistration .O3DICP (df_joint_segment , ref_df_joint_cloud )
7869 res = registration .transformation_matrix
7970 transforms .append (df_cvt .cvt_ndarray_2_rh_transform (res ))
80- joint_segments .append (df_cvt .cvt_dfcloud_2_rhcloud (segment ))
71+ rh_joint_segments .append (df_cvt .cvt_dfcloud_2_rhcloud (df_joint_segment ))
8172
8273 o_joint_segments = []
8374 o_transforms = []
8475 o_reference_point_clouds = []
85- for joint_segment , transform , _joint_cloud in zip (joint_segments , transforms , joint_clouds ):
76+ for joint_segment , transform , _joint_cloud in zip (rh_joint_segments , transforms , ref_rh_joint_clouds ):
8677 if joint_segment .IsValid :
8778 o_joint_segments .append (joint_segment )
8879 o_transforms .append (transform )
0 commit comments