Skip to content

Commit d5873d3

Browse files
committed
WIP-ADD option to swap the source and target pointcloud when calculating cloud2cloud distance and refactoring
1 parent 6e40814 commit d5873d3

File tree

3 files changed

+313
-548
lines changed

3 files changed

+313
-548
lines changed

src/gh/components/DF_cloud_to_cloud_distance/code.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
class CloudToCloudDistance(component):
2222
def RunScript(self,
2323
i_cloud_source: typing.List[rg.PointCloud],
24-
i_cloud_target: typing.List[rg.PointCloud]):
24+
i_cloud_target: typing.List[rg.PointCloud],
25+
i_swap: bool):
2526
"""
2627
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.
2728
@@ -38,7 +39,13 @@ def RunScript(self,
3839
if i_cloud_source is None or i_cloud_target is None:
3940
ghenv.Component.AddRuntimeMessage(RML.Warning, "Please provide both objects of type point clouds to compare")
4041
return None
41-
42+
43+
# swap
44+
if i_swap is True:
45+
temp = i_cloud_source
46+
i_cloud_source = i_cloud_target
47+
i_cloud_target = temp
48+
4249
# conversion
4350
df_cloud_source_list = [df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cl_s) for i_cl_s in i_cloud_source]
4451
df_cloud_target_list = [df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cl_t) for i_cl_t in i_cloud_target]
@@ -53,5 +60,6 @@ def RunScript(self,
5360
com = CloudToCloudDistance()
5461
o_distances, o_mse, o_max_deviation, o_min_deviation, o_std_deviation, o_results = com.RunScript(
5562
i_cloud_source,
56-
i_cloud_target
63+
i_cloud_target,
64+
i_swap
5765
)

src/gh/components/DF_vizualization/code.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,30 @@ def RunScript(self,
3636
# by default we color the target
3737
distances_flattened = [item for sublist in i_results.distances for item in sublist]
3838

39-
min_value = min(min(sublist) for sublist in i_results.distances)
40-
4139
if i_viz_settings.lower_threshold is not None:
4240
min_value = i_viz_settings.lower_threshold
41+
else:
42+
min_value = min(min(sublist) for sublist in i_results.distances)
4343

4444
if i_viz_settings.upper_threshold is not None:
4545
max_value = i_viz_settings.upper_threshold
4646
else:
4747
max_value = max(max(sublist) for sublist in i_results.distances)
4848

49-
o_source = [df_vizualization.color_pcd(src, dist, min_value, max_value) for src, dist in zip(o_source, i_results.distances)]
50-
51-
o_target = [df_cvt_bindings.cvt_dfcloud_2_rhcloud(trg) for trg in i_results.target]
49+
# we always color the source
50+
# check if source is a pcd
51+
o_colored_geo = [df_vizualization.color_pcd(src, dist, min_value, max_value) for src, dist in zip(o_source, i_results.distances)]
5252

5353
o_legend = df_vizualization.create_legend(min_value, max_value)
5454

5555
o_histogram = df_vizualization.create_histogram(distances_flattened, min_value, max_value)
5656

57-
return o_source, o_target, o_legend, o_histogram
57+
return o_source, o_colored_geo, o_legend, o_histogram
5858

5959

6060
if __name__ == "__main__":
6161
com = Vizualization()
62-
o_source, o_target, o_legend, o_histogram = com.RunScript(
62+
o_source, o_colored_geo, o_legend, o_histogram = com.RunScript(
6363
i_results,
6464
i_viz_settings
6565
)

0 commit comments

Comments
 (0)