Skip to content

Commit 21eea67

Browse files
committed
WIP FIX distance calculations
1 parent 1f316fc commit 21eea67

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

src/gh/components/DF_cloud_to_cloud_distance/code.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@
2121
class CloudToCloudDistance(component):
2222
def RunScript(self,
2323
i_cloud_source: rg.PointCloud,
24-
i_cloud_target: rg.PointCloud,
25-
i_signed_flag: bool):
24+
i_cloud_target: rg.PointCloud):
2625
"""
2726
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.
2827
2928
:param i_cloud_source: source point cloud
3029
:param i_cloud_target: target point cloud to align to
31-
:param i_signed_flag: whether to take normals into account
3230
3331
:return o_distances : list of calculated distances for each point
3432
:return o_mse: the average squared difference between corresponding points of source and target
@@ -39,17 +37,13 @@ def RunScript(self,
3937
if i_cloud_source is None or i_cloud_target is None:
4038
ghenv.Component.AddRuntimeMessage(RML.Warning, "Please provide both objects of type point clouds to compare")
4139
return None
42-
43-
if i_signed_flag and not i_cloud_target.ContainsNormals:
44-
ghenv.Component.AddRuntimeMessage(RML.Warning, "Please provide a target point cloud with normals or assign false to i_signed_flag")
45-
return None
4640

4741
# conversion
4842
df_cloud_source = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud_source)
4943
df_cloud_target = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud_target)
5044

5145
# calculate distances
52-
o_distances = df_error_estimation.cloud_2_cloud_distance(df_cloud_source, df_cloud_target, i_signed_flag)
46+
o_distances = df_error_estimation.cloud_2_cloud_distance(df_cloud_source, df_cloud_target)
5347
o_mse = df_error_estimation.compute_mse(o_distances)
5448
o_max_deviation = df_error_estimation.compute_max_deviation(o_distances)
5549
o_min_deviation = df_error_estimation.compute_min_deviation(o_distances)
@@ -62,6 +56,5 @@ def RunScript(self,
6256
com = CloudToCloudDistance()
6357
o_distances, o_mse, o_max_deviation, o_min_deviation, o_std_deviation = com.RunScript(
6458
i_cloud_source,
65-
i_cloud_target,
66-
i_signed_flag
59+
i_cloud_target
6760
)

src/gh/components/DF_cloud_to_mesh_distance/code.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,22 @@ def RunScript(self,
3939
# conversion
4040
df_cloud_source = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud_source)
4141
i_mesh_target = i_beam.to_mesh()
42-
df_mesh_target = df_cvt_bindings.cvt_rhmesh_2_dfmesh(i_mesh_target)
42+
#df_mesh_target = df_cvt_bindings.cvt_rhmesh_2_dfmesh(i_mesh_target)
4343

4444
# calculate distances
45-
o_distances = df_error_estimation.cloud_2_mesh_distance(df_cloud_source, df_mesh_target, i_signed_flag)
46-
o_mse = df_error_estimation.compute_mse(o_distances)
47-
o_max_deviation = df_error_estimation.compute_max_deviation(o_distances)
48-
o_min_deviation = df_error_estimation.compute_min_deviation(o_distances)
45+
#o_distances = df_error_estimation.cloud_2_mesh_distance(df_cloud_source, df_mesh_target, i_signed_flag)
46+
#o_mse = df_error_estimation.compute_mse(o_distances)
47+
#o_max_deviation = df_error_estimation.compute_max_deviation(o_distances)
48+
#o_min_deviation = df_error_estimation.compute_min_deviation(o_distances)
4949

50-
return o_distances.tolist(), o_mse, o_max_deviation, o_min_deviation
50+
o_mesh = i_mesh_target
51+
#return o_distances.tolist(), o_mse, o_max_deviation, o_min_deviation, o_mesh
52+
return 0, 0, 0, 0, o_mesh
5153

5254

5355
if __name__ == "__main__":
5456
com = CloudToMeshDistance()
55-
o_distances, o_mse, o_max_deviation, o_min_deviation = com.RunScript(
57+
o_distances, o_mse, o_max_deviation, o_min_deviation, o_mesh = com.RunScript(
5658
i_cloud_source,
5759
i_mesh_target,
5860
i_signed_flag

src/gh/diffCheck/diffCheck/df_error_estimation.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ def cloud_2_cloud_distance(source, target, signed=False):
1111
"""
1212
Compute the Euclidean distance for every point of a source pcd to its closest point on a target pointcloud
1313
"""
14-
if signed:
15-
distances = np.asarray(source.compute_distance(target, is_abs=False))
16-
else:
17-
distances = np.asarray(source.compute_distance(target, is_abs=True))
14+
distances = np.asarray(source.compute_distance(target))
1815

1916
return distances
2017

src/gh/diffCheck/diffCheck/df_geometries.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def to_brep(self):
233233
"""
234234
brep = rg.Brep()
235235
for face in self.faces:
236-
brep.Append(face.to_brep_face())
236+
brep.Append(face.to_brep_face().ToBrep())
237237
brep.Compact()
238238

239239
return brep
@@ -242,13 +242,21 @@ def to_mesh(self):
242242
"""
243243
Convert the beam to a Rhino Mesh object
244244
"""
245-
mesh = rg.Mesh()
246-
for face in self.faces:
247-
mesh_part = face.to_mesh()
248-
mesh.Append(mesh_part)
249-
mesh.Compact()
245+
# mesh = rg.Mesh()
246+
o_side_faces = [f.to_brep_face() for f in self.side_faces]
247+
o_joint_faces = [f.to_brep_face() for f in self.joint_faces]
248+
rhino_brep_faces = o_side_faces + o_joint_faces
250249

251-
return mesh
250+
brep = rg.Brep()
251+
252+
for f in rhino_brep_faces:
253+
#from dfbeam face to mesh
254+
brep.Faces.Add(f)
255+
#mesh_part = rg.CreateFromBrep(face.ToBrep(), rg.MeshingParameters.Coarse)
256+
#mesh.Append(mesh_part)
257+
#mesh.Compact()
258+
259+
return rhino_brep_faces
252260

253261
def __repr__(self):
254262
return f"Beam: {self.name}, Faces: {len(self.faces)}"

0 commit comments

Comments
 (0)