Skip to content

Commit a8ad703

Browse files
committed
WIP-FIX Cloud2Cloud
1 parent 17d4982 commit a8ad703

File tree

3 files changed

+41
-33
lines changed

3 files changed

+41
-33
lines changed

src/gh/components/DF_cloud_to_cloud_distance/code.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def RunScript(self,
3232
:return o_max_deviation: the max deviation between source and target (Hausdorff Distance)
3333
:return o_min_deviation: the min deviation between source and target
3434
"""
35-
print ("yes")
3635
if i_cloud_source is None or i_cloud_target is None:
3736
ghenv.Component.AddRuntimeMessage(RML.Warning, "Please provide both objects of type point clouds to compare")
3837
return None
@@ -43,16 +42,16 @@ def RunScript(self,
4342

4443
# calculate distances
4544
o_distances = df_error_estimation.cloud_2_cloud_distance(df_cloud_source, df_cloud_target)
46-
o_mse = df_error_estimation.compute_mse(df_cloud_source, df_cloud_target)
47-
o_max_deviation = df_error_estimation.compute_max_deviation(df_cloud_source, df_cloud_target)
48-
o_min_deviation = df_error_estimation.compute_min_deviation(df_cloud_source, df_cloud_target)
45+
o_mse = df_error_estimation.compute_mse(o_distances)
46+
o_max_deviation = df_error_estimation.compute_max_deviation(o_distances)
47+
o_min_deviation = df_error_estimation.compute_min_deviation(o_distances)
4948

50-
return o_distances
49+
return o_distances, o_mse, o_max_deviation, o_min_deviation
5150

5251

5352
if __name__ == "__main__":
54-
com = CloudToCloudDistance(component)
55-
o_distances = com.RunScript(
53+
com = CloudToCloudDistance()
54+
o_distances, o_mse, o_max_deviation, o_min_deviation = com.RunScript(
5655
i_cloud_source,
5756
i_cloud_target
5857
)

src/gh/components/DF_cloud_to_mesh_distance/code.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,43 @@
1313
import diffCheck
1414
from diffCheck import diffcheck_bindings
1515
from 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+
)

src/gh/diffCheck/diffCheck/df_error_estimation.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,44 @@ def cloud_2_cloud_distance(source, target):
1414

1515
return distances
1616

17-
def compute_mse(source, target):
17+
def cloud_2_mesh_distance(source, target):
18+
19+
distances = np.ones(len(source.points), dtype=float)
20+
21+
return distances
22+
23+
def compute_mse(distances):
1824
"""
1925
Calculate mean squared distance
2026
"""
2127

22-
distances = cloud_2_cloud_distance(source, target)
2328
mse = np.sqrt(np.mean(distances ** 2))
2429

2530
return mse
2631

27-
def compute_max_deviation(source, target):
32+
def compute_max_deviation(distances):
2833
"""
2934
Calculate max deviation of distances
3035
"""
3136

32-
max_deviation = np.max(cloud_2_cloud_distance(source, target))
37+
max_deviation = np.max(distances)
3338

3439
return max_deviation
3540

36-
def compute_min_deviation(source, target):
41+
def compute_min_deviation(distances):
3742
"""
3843
Calculate min deviation of distances
3944
"""
4045

41-
min_deviation = np.min(cloud_2_cloud_distance(source, target))
46+
min_deviation = np.min(distances)
4247

4348
return min_deviation
4449

45-
def compute_standard_deviation(source, target):
50+
def compute_standard_deviation(distances):
4651
"""
4752
Calculate standard deviation of distances
4853
"""
4954

50-
standard_deviation = np.std(cloud_2_cloud_distance(source, target))
55+
standard_deviation = np.std(distances)
5156

52-
return standard_deviation
57+
return standard_deviation

0 commit comments

Comments
 (0)