Skip to content

FIX Assembly input for meshcloud Distance Calculation #66

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

Merged
merged 4 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion deps/eigen
Submodule eigen deleted from 0b646f
1 change: 0 additions & 1 deletion deps/pybind11
Submodule pybind11 deleted from 723307
31 changes: 14 additions & 17 deletions src/gh/components/DF_cloud_mesh_distance/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,35 @@
import diffCheck
from diffCheck import df_cvt_bindings
from diffCheck import df_error_estimation
from diffCheck.df_geometries import DFBeam
from diffCheck.df_geometries import DFAssembly


class CloudMeshDistance(component):
def RunScript(self,
i_cloud_source: typing.List[rg.PointCloud],
i_beams: typing.List[DFBeam],
i_assembly: DFAssembly,
i_signed_flag: bool,
i_swap: bool,
i_analysis_resolution):

"""
The cloud-to-mesh component computes the distance between a point cloud and a mesh

:param i_cloud_source: a list of point clouds
:param i_beams: a list of DF beams
:param i_signed_flag: calculate the sign of the distances
:param i_swap: swap source and target

:return o_distances : list of calculated distances for each point
:return o_rmse: the root mean square error between corresponding points of source and target
:return o_max_deviation: the max deviation between source and target
:return o_min_deviation: the min deviation between source and target
:returns o_results: the results of the comparison all in one object
"""
if i_analysis_resolution is None:
scalef = diffCheck.df_util.get_doc_2_meters_unitf()
i_analysis_resolution = 0.1 / scalef

# Based on cloud source input + beam size, decide whether to calculate joints or entire assembly and output respective message
if len(i_assembly.beams) == len(i_cloud_source):
ghenv.Component.Message = f"Per Beam"
rh_mesh_target_list = [beam.to_mesh(i_analysis_resolution) for beam in i_assembly.beams]
elif len(i_assembly.all_joints) == len(i_cloud_source):
ghenv.Component.Message= f"Per Joint"
rh_mesh_target_list = [joint.to_mesh(i_analysis_resolution) for joint in i_assembly._all_joints]
else:
ghenv.Component.AddRuntimeMessage(RML.Warning, "The input number of objects to compare matches neither the number of beams nor the number of joints")
return None, None, None, None, None, None

# conversion
df_cloud_source_list = [df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cl_s) for i_cl_s in i_cloud_source]
rh_mesh_target_list = [beam.to_mesh(i_analysis_resolution) for beam in i_beams]


# calculate distances
o_result = df_error_estimation.df_cloud_2_rh_mesh_comparison(df_cloud_source_list, rh_mesh_target_list, i_signed_flag, i_swap)
Expand Down
10 changes: 5 additions & 5 deletions src/gh/components/DF_cloud_mesh_distance/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"subcategory": "Analysis",
"description": "Computes the distance between a point cloud and a mesh",
"exposure": 4,
"instanceGuid": "534a24ba-7e32-482f-a3d7-293647185122",
"instanceGuid": "eda01e34-b89b-4e3c-a9b6-0178a05ae81b",
"ghpython": {
"hideOutput": true,
"hideInput": true,
Expand All @@ -26,13 +26,13 @@
"typeHintID": "pointcloud"
},
{
"name": "i_beams",
"nickname": "i_beams",
"description": "The target DFbeams",
"name": "i_assembly",
"nickname": "i_assembly",
"description": "The target DFAssembly",
"optional": false,
"allowTreeAccess": true,
"showTypeHints": true,
"scriptParamAccess": "list",
"scriptParamAccess": "item",
"wireDisplay": "default",
"sourceCount": 0,
"typeHintID": "ghdoc"
Expand Down
Loading