|
8 | 8 | from diffCheck import diffcheck_bindings |
9 | 9 | import Rhino.Geometry as rg |
10 | 10 |
|
11 | | -def cloud_2_cloud_distance(source, target, signed=False): |
| 11 | + |
| 12 | +def cloud_2_cloud_distance(source, target, invert=False): |
12 | 13 | """ |
13 | | - Compute the Euclidean distance for every point of a source pcd to its closest point on a target pointcloud |
| 14 | + Compute the Euclidean distance for every point of a source pcd to its |
| 15 | + closest point on a target pointcloud |
14 | 16 | """ |
15 | | - distances_to_target = np.asarray(source.compute_distance(target)) |
16 | | - distances_to_source = np.asarray(target.compute_distance(source)) |
| 17 | + if invert: |
| 18 | + distances = np.asarray(target.compute_distance(source)) |
| 19 | + else: |
| 20 | + distances = np.asarray(source.compute_distance(target)) |
17 | 21 |
|
18 | | - return DFVizResults(source, target, distances_to_target, distances_to_source) |
| 22 | + return distances |
| 23 | + |
| 24 | + |
| 25 | +def cloud_2_cloud_comparison(source_list, target_list, invert=False): |
| 26 | + """ |
| 27 | + Compute the Euclidean distance for every point of a source pcd to its |
| 28 | + closest point on a target pointcloud |
| 29 | + """ |
| 30 | + results = DFVizResults() |
| 31 | + for source, target in zip(source_list, target_list): |
| 32 | + distances = cloud_2_cloud_distance(source, target, invert) |
| 33 | + results.add(source, target, distances) |
| 34 | + |
| 35 | + return results |
19 | 36 |
|
20 | 37 |
|
21 | 38 | def cloud_2_mesh_distance(source, target, signed=False): |
@@ -102,20 +119,24 @@ class DFVizResults: |
102 | 119 | This class compiles the resluts of the error estimation into one object |
103 | 120 | """ |
104 | 121 |
|
105 | | - def __init__(self, source, target, distances_to_target, distances_to_source): |
| 122 | + def __init__(self): |
| 123 | + |
| 124 | + self.source = [] |
| 125 | + self.target = [] |
106 | 126 |
|
107 | | - self.source = source |
108 | | - self.target = target |
| 127 | + self.distances_mse = [] |
| 128 | + self.distances_max_deviation = [] |
| 129 | + self.distances_min_deviation = [] |
| 130 | + self.distances_sd_deviation = [] |
| 131 | + self.distances = [] |
109 | 132 |
|
110 | | - self.distances_to_target_mse = np.sqrt(np.mean(distances_to_target ** 2)) |
111 | | - self.distances_to_target_max_deviation = np.max(distances_to_target) |
112 | | - self.distances_to_target_min_deviation = np.min(distances_to_target) |
113 | | - self.distances_to_target_sd_deviation = np.std(distances_to_target) |
114 | | - self.distances_to_target = distances_to_target.tolist() |
| 133 | + def add(self, source, target, distances): |
115 | 134 |
|
116 | | - self.distances_to_source_mse = np.sqrt(np.mean(distances_to_source ** 2)) |
117 | | - self.distances_to_source_max_deviation = np.max(distances_to_source) |
118 | | - self.distances_to_source_min_deviation = np.min(distances_to_source) |
119 | | - self.distances_to_source_sd_deviation = np.std(distances_to_source) |
120 | | - self.distances_to_source = distances_to_source.tolist() |
| 135 | + self.source.append(source) |
| 136 | + self.target.append(target) |
121 | 137 |
|
| 138 | + self.distances_mse.append(np.sqrt(np.mean(distances ** 2))) |
| 139 | + self.distances_max_deviation.append(np.max(distances)) |
| 140 | + self.distances_min_deviation.append(np.min(distances)) |
| 141 | + self.distances_sd_deviation.append(np.std(distances)) |
| 142 | + self.distances.append(distances.tolist()) |
0 commit comments