Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding API functions for compute distance (mesh-cloud cloud-mesh) #31

Merged
merged 5 commits into from
Jun 19, 2024

Conversation

9and3
Copy link
Contributor

@9and3 9and3 commented Jun 19, 2024

This PR introduces the 2 functions for calculating the distances for df evaluation.

Following @eleniv3d 's suggestions on slack, instead of exposing the ktrees I prefered to wrap open3d functions around two functions that returns list of distances:

  • cloud-2-cloud (*)
  • mesh-2-cloud (*)(**)

(*) both have signed distances, if the is_abs is True it's only positive
(**) for this one, it's based on raytracing (@mariklad mentioned it at one moment thanks!) and conversion to tensors, it's basically a point-to-plane. Both should be quite fast.

Here's an example file:

#! python3

import Rhino
import Rhino.Geometry as rg

import diffCheck
from diffCheck import diffcheck_bindings
import diffCheck.df_cvt_bindings
import diffCheck.df_geometries


df_mesh = diffCheck.df_cvt_bindings.cvt_rhmesh_2_dfmesh(i_rh_mesh)
df_cloud = diffCheck.df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_rh_cloud)

mesh_to_cloud_distances = df_mesh.compute_distance(target_cloud=df_cloud, is_abs=True)
print(f"Max distance mesh-to-cloud: {max(mesh_to_cloud_distances)}")
print(f"Min distance mesh-to-cloud: {min(mesh_to_cloud_distances)}")

cloud_to_cloud_distances = df_cloud.compute_distance(target_cloud=df_cloud, is_abs=True)
print(f"Max distance cloud-to-cloud: {max(cloud_to_cloud_distances)}")
print(f"Min distance cloud-to-cloud: {min(cloud_to_cloud_distances)}")

gh_snap4

@9and3 9and3 added the dev label Jun 19, 2024
@9and3 9and3 requested review from mariklad and eleniv3d June 19, 2024 09:06
@9and3 9and3 self-assigned this Jun 19, 2024
@9and3 9and3 changed the base branch from main to distance_calculation_visualisation June 19, 2024 09:06
@9and3
Copy link
Contributor Author

9and3 commented Jun 19, 2024

@DamienGilliard these are the functions you could use too in your segmentation!

@eleniv3d eleniv3d merged commit a61efff into distance_calculation_visualisation Jun 19, 2024
3 checks passed
@eleniv3d
Copy link
Collaborator

@9and3 hey! are you sure the ComputePointCloudDistance computes by default a signed distance? it is my impression that this is not the case so the is_abs toggle doesn't affect the result. :) For the Mesh it works as expected.

@9and3
Copy link
Contributor Author

9and3 commented Jun 19, 2024

it is my impression that this is not the case so the is_abs toggle doesn't affect the result.

You are completely right @eleniv3d , thanks for spotting this out! I opened a new PR fix #32 that removes the is_abs bool parameter since it makes sense to have it only on mesh-cloud comparison imo (by having an inside-out to sign on the distances).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants