1313import diffCheck
1414from diffCheck import diffcheck_bindings
1515from diffCheck import df_cvt_bindings
16- import diffCheck . df_util
16+ from diffCheck import df_error_estimation
1717
18- class CloudToCloudDistance (component ):
18+ class CloudToMeshDistance (component ):
1919 def RunScript (self ,
2020 i_cloud_source : rg .PointCloud ,
21- i_cloud_target : rg .PointCloud ,
22-
23- ) -> [float ]:
21+ i_mesh_target : rg .PointCloud ):
2422 """
2523 The cloud-to-cloud component computes the distance between each point in the source point cloud and its nearest neighbour in thr target point cloud.
2624
2725 :param i_cloud_source: source point cloud
28- :param i_cloud_target : target point cloud to align to
26+ :param i_mesh_target : target point cloud to align to
2927
3028 :return o_distances : list of calculated distances for each point
29+ :return o_mse: the average squared difference between corresponding points of source and target
30+ :return o_max_deviation: the max deviation between source and target (Hausdorff Distance)
31+ :return o_min_deviation: the min deviation between source and target
3132 """
32- if i_cloud_source is None or i_cloud_target is None :
33- ghenv .Component .AddRuntimeMessage (RML .Warning , "Please provide both objects of type point clouds to compare" )
33+ if i_cloud_source is None or i_mesh_target is None :
34+ ghenv .Component .AddRuntimeMessage (RML .Warning , "Please provide an object of type point cloud and an object of type mesh to compare" )
3435 return None
3536
3637 # conversion
3738 df_cloud_source = df_cvt_bindings .cvt_rhcloud_2_dfcloud (i_cloud_source )
38- df_cloud_target = df_cvt_bindings .cvt_rhcloud_2_dfcloud ( i_cloud_target )
39+ df_mesh_target = df_cvt_bindings .cvt_rhmesh_2_dfmesh ( i_mesh_target )
3940
4041 # calculate distances
41- o_distances = cloud_2_cloud_distance (df_cloud_source , df_cloud_target )
42+ o_distances = df_error_estimation .cloud_2_mesh_distance (df_cloud_source , df_mesh_target )
43+ o_mse = df_error_estimation .compute_mse (o_distances )
44+ o_max_deviation = df_error_estimation .compute_max_deviation (o_distances )
45+ o_min_deviation = df_error_estimation .compute_min_deviation (o_distances )
4246
43- return o_distances
47+ return o_distances , o_mse , o_max_deviation , o_min_deviation
4448
4549
46- # if __name__ == "__main__":
47- # com = CloudToCloudDistance(component )
48- # o_distances = com.RunScript(
49- # i_cloud_source,
50- # i_cloud_target
51- # )
50+ if __name__ == "__main__" :
51+ com = CloudToMeshDistance ( )
52+ o_distances , o_mse , o_max_deviation , o_min_deviation = com .RunScript (
53+ i_cloud_source ,
54+ i_mesh_target
55+ )
0 commit comments