Skip to content

Commit d2c61ca

Browse files
committed
WIP-FIX metadata to bake components
1 parent 99b4a89 commit d2c61ca

File tree

15 files changed

+14902
-1226
lines changed

15 files changed

+14902
-1226
lines changed

src/gh/components/DF_cloud_cloud_distance/code.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ def RunScript(self,
5656
return o_results.distances, o_results.distances_mse, o_results.distances_max_deviation, o_results.distances_min_deviation, o_results.distances_sd_deviation, o_results
5757

5858

59-
if __name__ == "__main__":
60-
com = CloudCloudDistance()
61-
o_distances, o_mse, o_max_deviation, o_min_deviation, o_std_deviation, o_results = com.RunScript(
62-
i_cloud_source,
63-
i_cloud_target,
64-
i_swap
65-
)
59+
# if __name__ == "__main__":
60+
# com = CloudCloudDistance()
61+
# o_distances, o_mse, o_max_deviation, o_min_deviation, o_std_deviation, o_results = com.RunScript(
62+
# i_cloud_source,
63+
# i_cloud_target,
64+
# i_swap
65+
# )

src/gh/components/DF_cloud_cloud_distance/metadata.json

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"name": "CloudToCloudDistance",
3-
"nickname": "C2CDistance",
2+
"name": "DFCloudCloudDistance",
3+
"nickname": "DFC2CDistance",
44
"category": "diffCheck",
55
"subcategory": "Analysis",
6-
"description": "Computes the distance between each point in the source point cloud and its nearest neighbour in thr target point cloud.",
6+
"description": "Computes the distance between 2 point clouds",
77
"exposure": 4,
8-
"instanceGuid": "ad21f438-b953-464b-8332-04f4074f3bd0",
8+
"instanceGuid": "5e90284b-f932-4617-8740-e9c26a95410c",
99
"ghpython": {
1010
"hideOutput": true,
1111
"hideInput": true,
@@ -20,7 +20,7 @@
2020
"optional": true,
2121
"allowTreeAccess": true,
2222
"showTypeHints": true,
23-
"scriptParamAccess": "item",
23+
"scriptParamAccess": "list",
2424
"wireDisplay": "default",
2525
"sourceCount": 0,
2626
"typeHintID": "pointcloud"
@@ -32,28 +32,28 @@
3232
"optional": false,
3333
"allowTreeAccess": true,
3434
"showTypeHints": true,
35-
"scriptParamAccess": "item",
35+
"scriptParamAccess": "list",
3636
"wireDisplay": "default",
3737
"sourceCount": 0,
3838
"typeHintID": "pointcloud"
3939
},
4040
{
41-
"name": "i_signed_flag",
42-
"nickname": "i_signed_flag",
43-
"description": "whether to take normals into account",
41+
"name": "i_swap",
42+
"nickname": "i_swap",
43+
"description": "whether to swap source and target",
4444
"optional": false,
4545
"allowTreeAccess": false,
4646
"showTypeHints": true,
4747
"scriptParamAccess": "item",
4848
"wireDisplay": "default",
4949
"sourceCount": 0,
50-
"typeHintID": "float"
50+
"typeHintID": "bool"
5151
}
5252
],
5353
"outputParameters": [
5454
{
55-
"name": "o_distance",
56-
"nickname": "o_distance",
55+
"name": "o_distances",
56+
"nickname": "o_distances",
5757
"description": "list of calculated distances for each point of the source.",
5858
"optional": false,
5959
"sourceCount": 0,
@@ -90,6 +90,14 @@
9090
"optional": false,
9191
"sourceCount": 0,
9292
"graft": false
93+
},
94+
{
95+
"name": "o_results",
96+
"nickname": "o_results",
97+
"description": "The result of the distance calculation.",
98+
"optional": false,
99+
"sourceCount": 0,
100+
"graft": false
93101
}
94102
]
95103
}

src/gh/components/DF_cloud_mesh_distance/code.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ def RunScript(self,
2121
i_cloud_source: typing.List[rg.PointCloud],
2222
i_beam: typing.List[DFBeam],
2323
i_signed_flag: bool,
24-
i_swap: bool):
24+
i_swap: bool,
25+
i_analysis_resolution):
2526

2627
"""
2728
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.
@@ -37,25 +38,26 @@ def RunScript(self,
3738
:return o_min_deviation: the min deviation between source and target
3839
:returns o_resluts: the results of the comparison all in one object
3940
"""
40-
if i_cloud_source is None or i_beam is None:
41-
ghenv.Component.AddRuntimeMessage(RML.Warning, "Please provide an object of type point cloud and an object of type mesh to compare")
42-
return None
41+
if i_analysis_resolution is None:
42+
scalef = diffCheck.df_util.get_doc_2_meters_unitf()
43+
i_analysis_resolution = 0.1 / scalef
4344

4445
# conversion
4546
df_cloud_source_list = [df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cl_s) for i_cl_s in i_cloud_source]
46-
df_mesh_target_list = [beam.to_mesh() for beam in i_beam]
47+
df_mesh_target_list = [beam.to_mesh(i_analysis_resolution) for beam in i_beam]
4748

4849
# calculate distances
4950
o_results = df_error_estimation.cloud_2_rhino_mesh_comparison(df_cloud_source_list, df_mesh_target_list, i_signed_flag, i_swap)
5051

5152
return o_results.distances, o_results.distances_mse, o_results.distances_max_deviation, o_results.distances_min_deviation, o_results.distances_sd_deviation, o_results
5253

5354

54-
if __name__ == "__main__":
55-
com = CloudMeshDistance()
56-
o_distances, o_mse, o_max_deviation, o_min_deviation, o_std_deviation, o_results = com.RunScript(
57-
i_cloud_source,
58-
i_beam,
59-
i_signed_flag,
60-
i_swap
61-
)
55+
# if __name__ == "__main__":
56+
# com = CloudMeshDistance()
57+
# o_distances, o_mse, o_max_deviation, o_min_deviation, o_std_deviation, o_results = com.RunScript(
58+
# i_cloud_source,
59+
# i_beam,
60+
# i_signed_flag,
61+
# i_swap,
62+
# i_analysis_resolution
63+
# )

src/gh/components/DF_cloud_mesh_distance/metadata.json

Lines changed: 51 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,168 +1,124 @@
11
{
2-
"name": "RANSACGlobalRegistration",
3-
"nickname": "RANSACGReg",
2+
"name": "DFCloudMeshDistance",
3+
"nickname": "DFC2MDistance",
44
"category": "diffCheck",
5-
"subcategory": "Registrations",
6-
"description": "Register two point clouds together with a feature matching based on RANSAC.",
5+
"subcategory": "Analysis",
6+
"description": "Computes the distance between a point cloud and a mesh",
77
"exposure": 4,
8-
"instanceGuid": "805911b9-7ea9-4bbf-be34-00f9f225b9b3",
8+
"instanceGuid": "534a24ba-7e32-482f-a3d7-293647185122",
99
"ghpython": {
1010
"hideOutput": true,
1111
"hideInput": true,
1212
"isAdvancedMode": true,
1313
"marshalOutGuids": true,
1414
"iconDisplay": 2,
1515
"inputParameters": [
16-
{
17-
"name": "i_recompute",
18-
"nickname": "i_recompute",
19-
"description": "Connect a button to recompute the registration.",
20-
"optional": true,
21-
"allowTreeAccess": true,
22-
"showTypeHints": true,
23-
"scriptParamAccess": "item",
24-
"wireDisplay": "default",
25-
"sourceCount": 0,
26-
"typeHintID": "bool"
27-
},
2816
{
2917
"name": "i_cloud_source",
3018
"nickname": "i_cloud_source",
3119
"description": "The source point cloud.",
3220
"optional": true,
3321
"allowTreeAccess": true,
3422
"showTypeHints": true,
35-
"scriptParamAccess": "item",
23+
"scriptParamAccess": "list",
3624
"wireDisplay": "default",
3725
"sourceCount": 0,
3826
"typeHintID": "pointcloud"
3927
},
4028
{
41-
"name": "i_cloud_target",
42-
"nickname": "i_cloud_target",
43-
"description": "The target cloud.",
29+
"name": "i_beam",
30+
"nickname": "i_beam",
31+
"description": "The target DFbeam",
4432
"optional": false,
4533
"allowTreeAccess": true,
4634
"showTypeHints": true,
47-
"scriptParamAccess": "item",
35+
"scriptParamAccess": "list",
4836
"wireDisplay": "default",
4937
"sourceCount": 0,
50-
"typeHintID": "pointcloud"
38+
"typeHintID": "ghdoc"
5139
},
5240
{
53-
"name": "i_radius_kd_search",
54-
"nickname": "i_radius_kd_search",
55-
"description": "The radius used to search for neighbors in the KDTree.it is expressed relative to the point cloud size (0.01 means radiusKDTreeSearch = 1% of maxSize(pointCloud). It is used for the calculation of FPFHFeatures.",
41+
"name": "i_signed_flag",
42+
"nickname": "i_signed_flag",
43+
"description": "whether to consider the sign of the distances",
5644
"optional": false,
57-
"allowTreeAccess": true,
45+
"allowTreeAccess": false,
5846
"showTypeHints": true,
5947
"scriptParamAccess": "item",
6048
"wireDisplay": "default",
6149
"sourceCount": 0,
62-
"typeHintID": "float"
50+
"typeHintID": "bool"
6351
},
6452
{
65-
"name": "i_neighbours_kd_search",
66-
"nickname": "i_neighbours_kd_search",
67-
"description": "The maximum number of neighbors to search for in the KDTree. It is used for the calculation of FPFHFeatures. A higher value will result in heavier computation but potentially more precise.",
53+
"name": "i_swap",
54+
"nickname": "i_swap",
55+
"description": "whether to swap source and target",
6856
"optional": false,
69-
"allowTreeAccess": true,
57+
"allowTreeAccess": false,
7058
"showTypeHints": true,
7159
"scriptParamAccess": "item",
7260
"wireDisplay": "default",
7361
"sourceCount": 0,
74-
"typeHintID": "int"
62+
"typeHintID": "bool"
7563
},
7664
{
77-
"name": "i_max_corrspondence_dist",
78-
"nickname": "i_max_corrspondence_dist",
79-
"description": "The maximum distance between correspondences. A higher value will result in more correspondences, but potentially include wrong ones.",
65+
"name": "i_analysis_resolution",
66+
"nickname": "i_analysis_resolution",
67+
"description": "the maximum edge length of the mesh that is used for the distance calculation",
8068
"optional": false,
81-
"allowTreeAccess": true,
69+
"allowTreeAccess": false,
8270
"showTypeHints": true,
8371
"scriptParamAccess": "item",
8472
"wireDisplay": "default",
8573
"sourceCount": 0,
8674
"typeHintID": "float"
87-
},
75+
}
76+
],
77+
"outputParameters": [
8878
{
89-
"name": "is_t_estimate_pt2pt",
90-
"nickname": "is_t_estimate_pt2pt",
91-
"description": "If true it deforms the cloud to match. The transformation estimation method to use. By default, it uses a point to point transformation estimation. If true it will scale and deform the cloud.",
79+
"name": "o_distances",
80+
"nickname": "o_distances",
81+
"description": "list of calculated distances for each point of the source.",
9282
"optional": false,
93-
"allowTreeAccess": true,
94-
"showTypeHints": true,
95-
"scriptParamAccess": "item",
96-
"wireDisplay": "default",
9783
"sourceCount": 0,
98-
"typeHintID": "bool"
84+
"graft": false
9985
},
10086
{
101-
"name": "i_ransac_n",
102-
"nickname": "i_ransac_n",
103-
"description": "The number of points to sample in the source point cloud. A higher value can result in a more precise transformation, but will take more time to compute.",
87+
"name": "o_mse",
88+
"nickname": "o_mse",
89+
"description": "average squared difference between source and target.",
10490
"optional": false,
105-
"allowTreeAccess": true,
106-
"showTypeHints": true,
107-
"scriptParamAccess": "item",
108-
"wireDisplay": "default",
10991
"sourceCount": 0,
110-
"typeHintID": "int"
92+
"graft": false
11193
},
11294
{
113-
"name": "i_checker_dist",
114-
"nickname": "i_checker_dist",
115-
"description": "The maximum distance between correspondances in the FPFH space before testing a RanSaC model. It is exprimed in relative values (it is scaled by the size of the bounding box of the poinnt cloud).",
95+
"name": "o_max_deviation",
96+
"nickname": "o_max_deviation",
97+
"description": "max deviation between source and target",
11698
"optional": false,
117-
"allowTreeAccess": true,
118-
"showTypeHints": true,
119-
"scriptParamAccess": "item",
120-
"wireDisplay": "default",
12199
"sourceCount": 0,
122-
"typeHintID": "float"
100+
"graft": false
123101
},
124102
{
125-
"name": "i_similarity_threshold",
126-
"nickname": "i_similarity_threshold",
127-
"description": "The threshold for the ransac check based on edge length to consider a model as inlier. A higher value will be stricter, discarding more ransac models.",
103+
"name": "o_min_deviation",
104+
"nickname": "o_min_deviation",
105+
"description": "min deviation between source and target",
128106
"optional": false,
129-
"allowTreeAccess": true,
130-
"showTypeHints": true,
131-
"scriptParamAccess": "item",
132-
"wireDisplay": "default",
133107
"sourceCount": 0,
134-
"typeHintID": "float"
108+
"graft": false
135109
},
136110
{
137-
"name": "i_max_iterations",
138-
"nickname": "i_max_iterations",
139-
"description": "The maximum number of iterations to run the Ransac algorithm. A higher value will take more time to compute but increases the chances of finding a good transformation.",
111+
"name": "o_std_deviation",
112+
"nickname": "o_std_deviation",
113+
"description": "standard deviation between source and target.",
140114
"optional": false,
141-
"allowTreeAccess": true,
142-
"showTypeHints": true,
143-
"scriptParamAccess": "item",
144-
"wireDisplay": "default",
145115
"sourceCount": 0,
146-
"typeHintID": "int"
116+
"graft": false
147117
},
148118
{
149-
"name": "i_confidence_threshold",
150-
"nickname": "i_confidence_threshold",
151-
"description": "The threshold for the convergence criteria of the ransac models. A higher value will be stricter, discarding more ransac models.",
152-
"optional": false,
153-
"allowTreeAccess": true,
154-
"showTypeHints": true,
155-
"scriptParamAccess": "item",
156-
"wireDisplay": "default",
157-
"sourceCount": 0,
158-
"typeHintID": "float"
159-
}
160-
],
161-
"outputParameters": [
162-
{
163-
"name": "o_x_form",
164-
"nickname": "o_x_form",
165-
"description": "The computed transformation.",
119+
"name": "o_results",
120+
"nickname": "o_results",
121+
"description": "The result of the distance calculation.",
166122
"optional": false,
167123
"sourceCount": 0,
168124
"graft": false

src/gh/components/DF_cvs_exporter/code.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,16 @@ def RunScript(self,
3838
writer = csv.writer(file)
3939
for list_of_values in i_results.distances:
4040
writer.writerow([list_of_values])
41-
42-
43-
if __name__ == "__main__":
44-
com = CsvExporter()
45-
o_cvs = com.RunScript(
46-
i_dump,
47-
i_export_dir,
48-
i_results
49-
)
41+
42+
o_success = "Successfully exported the values"
43+
44+
return o_success
45+
46+
47+
# if __name__ == "__main__":
48+
# com = CsvExporter()
49+
# o_cvs = com.RunScript(
50+
# i_dump,
51+
# i_export_dir,
52+
# i_results
53+
# )

0 commit comments

Comments
 (0)