Skip to content

Commit 2385589

Browse files
committed
ADD: metadata for cad segmentator added
1 parent 6c3dda2 commit 2385589

File tree

2 files changed

+59
-73
lines changed

2 files changed

+59
-73
lines changed

src/gh/components/DF_CAD_segmentator/code.py

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,41 +34,51 @@ def RunScript(self,
3434
3535
@return o_clusters : the clusters of the beams
3636
"""
37+
# the final rhino cloud clusters associated to the beams
3738
o_clusters = []
38-
39-
df_clouds = [df_cvt_bindings.cvt_rhcloud_2_dfcloud(cloud) for cloud in i_clouds]
40-
# df_meshes = [df_cvt_bindings.cvt_rhmesh_2_dfmesh(mesh) for mesh in i_meshes]
39+
# the df cloud clusters
40+
df_clusters = []
41+
# we make a deepcopy of the input clouds because
42+
df_clouds = [df_cvt_bindings.cvt_rhcloud_2_dfcloud(cloud.Duplicate()) for cloud in i_clouds]
4143

4244
df_beams = i_assembly.beams
43-
rh_beams_meshes = []
45+
df_beams_meshes = []
46+
4447
for df_b in df_beams:
45-
#TODO: check this function to have a better triangluation of the mesh with the parameters
4648
rh_b_mesh_faces = [df_b_f.to_mesh() for df_b_f in df_b.side_faces]
47-
# rh_b_mesh_faces = [df_b_f.to_brep_face() for df_b_f in df_b.side_faces]
48-
49-
# df_b_mesh_faces = [df_cvt_bindings.cvt_rhmesh_2_dfmesh(rh_b_mesh_face) for rh_b_mesh_face in rh_b_mesh_faces]
50-
51-
52-
# _ = [rh_beams_meshes.append(m) for m in rh_b_mesh_faces]
53-
54-
for m in rh_b_mesh_faces:
55-
# print(type(m))
56-
rh_beams_meshes.append(m)
57-
58-
# # convert df_b_mesh_faces to numpy array
59-
# # get the point clouds corresponding to the beams
60-
# df_asssociated_clusters : List[dfCloud] = dfb_segmentation.DFSegmentation.associate_clusters(
61-
# reference_mesh=df_b_mesh_faces,
62-
# unassociated_clusters=df_clouds,
63-
# angle_threshold=i_angle_threshold,
64-
# association_threshold=i_association_threshold
65-
# )
66-
67-
# break
68-
69-
print("test2")
70-
71-
return rh_beams_meshes
49+
df_b_mesh_faces = [df_cvt_bindings.cvt_rhmesh_2_dfmesh(rh_b_mesh_face) for rh_b_mesh_face in rh_b_mesh_faces]
50+
df_beams_meshes.append(df_b_mesh_faces)
51+
52+
df_asssociated_cluster = dfb_segmentation.DFSegmentation.associate_clusters(
53+
reference_mesh=df_b_mesh_faces,
54+
unassociated_clusters=df_clouds,
55+
angle_threshold=i_angle_threshold,
56+
association_threshold=i_association_threshold
57+
)
58+
59+
# TODO: get rid, this is for debugging
60+
# nbr_total_df_clouds_pts = 0
61+
# for df_cloud in df_clouds:
62+
# nbr_total_df_clouds_pts += df_cloud.get_num_points()
63+
# print("Total number of points in all clouds: ", nbr_total_df_clouds_pts)
64+
65+
# FIXME: this is returing empty clusters
66+
# print(df_asssociated_cluster.has_points())
67+
if df_asssociated_cluster.has_points():
68+
df_clusters.append(df_asssociated_cluster)
69+
70+
# FIXME: the refiner is crashing the script
71+
# dfb_segmentation.DFSegmentation.clean_unassociated_clusters(
72+
# unassociated_clusters=df_clouds,
73+
# associated_clusters=df_clusters,
74+
# reference_mesh=df_beams_meshes,
75+
# angle_threshold=i_angle_threshold,
76+
# association_threshold=i_association_threshold
77+
# )
78+
79+
o_clusters = [df_cvt_bindings.cvt_dfcloud_2_rhcloud(cluster) for cluster in df_clusters]
80+
81+
return o_clusters
7282

7383
if __name__ == "__main__":
7484
com = DFCADSegmentator()

src/gh/components/DF_CAD_segmentator/metadata.json

Lines changed: 19 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"name": "DFNormalSegmentator",
3-
"nickname": "DFCNorSeg",
2+
"name": "DFCADSegmentator",
3+
"nickname": "DFCADSeg",
44
"category": "diffCheck",
55
"subcategory": "Segmentation",
66
"description": "Cluster a point cloud based on normals.",
77
"exposure": 4,
8-
"instanceGuid": "8f732cef-771c-41b8-acca-562211fd3a80",
8+
"instanceGuid": "e8b77b13-e441-4fbe-ae07-44dfe5cc3768",
99
"ghpython": {
1010
"hideOutput": true,
1111
"hideInput": true,
@@ -14,69 +14,45 @@
1414
"iconDisplay": 2,
1515
"inputParameters": [
1616
{
17-
"name": "i_cloud",
18-
"nickname": "i_cloud",
19-
"description": "The point cloud to reduce the size.",
17+
"name": "i_clouds",
18+
"nickname": "i_clouds",
19+
"description": "The point cloud clusters already segmented by normals.",
2020
"optional": true,
2121
"allowTreeAccess": true,
2222
"showTypeHints": true,
23-
"scriptParamAccess": "item",
23+
"scriptParamAccess": "list",
2424
"wireDisplay": "default",
2525
"sourceCount": 0,
2626
"typeHintID": "pointcloud"
2727
},
2828
{
29-
"name": "i_normal_threshold_degree",
30-
"nickname": "i_normal_threshold_degree",
31-
"description": "The normal threshold in degrees (under that it consider to the same cluster).",
32-
"optional": false,
33-
"allowTreeAccess": true,
34-
"showTypeHints": true,
35-
"scriptParamAccess": "item",
36-
"wireDisplay": "default",
37-
"sourceCount": 0,
38-
"typeHintID": "float"
39-
},
40-
{
41-
"name": "i_min_cluster_size",
42-
"nickname": "i_min_cluster_size",
43-
"description": "The smallest cluster allowed.",
29+
"name": "i_assembly",
30+
"nickname": "i_assembly",
31+
"description": "The DFAssembly object.",
4432
"optional": false,
4533
"allowTreeAccess": true,
4634
"showTypeHints": true,
4735
"scriptParamAccess": "item",
4836
"wireDisplay": "default",
4937
"sourceCount": 0,
50-
"typeHintID": "int"
38+
"typeHintID": "ghdoc"
5139
},
5240
{
53-
"name": "i_use_knn_neighborhood",
54-
"nickname": "i_use_knn_neighborhood",
55-
"description": "If true use knn, otherwise radius search.",
41+
"name": "i_angle_threshold",
42+
"nickname": "i_angle_threshold",
43+
"description": "From 0 to 1, it's the sin value. The closer to 0 the less permissive and viceversa to 1.",
5644
"optional": false,
5745
"allowTreeAccess": true,
5846
"showTypeHints": true,
5947
"scriptParamAccess": "item",
6048
"wireDisplay": "default",
6149
"sourceCount": 0,
62-
"typeHintID": "bool"
63-
},
64-
{
65-
"name": "i_knn_neighborhood_size",
66-
"nickname": "i_knn_neighborhood_size",
67-
"description": "The knn size.",
68-
"optional": false,
69-
"allowTreeAccess": true,
70-
"showTypeHints": true,
71-
"scriptParamAccess": "item",
72-
"wireDisplay": "default",
73-
"sourceCount": 0,
74-
"typeHintID": "int"
50+
"typeHintID": "float"
7551
},
7652
{
77-
"name": "i_radius_neighborhood_size",
78-
"nickname": "i_radius_neighborhood_size",
79-
"description": "The size of the radius.",
53+
"name": "i_association_threshold",
54+
"nickname": "i_association_threshold",
55+
"description": "From 0 to infinite. By default 0.5. The closer to 0 the less permissive your point.",
8056
"optional": false,
8157
"allowTreeAccess": true,
8258
"showTypeHints": true,
@@ -90,7 +66,7 @@
9066
{
9167
"name": "o_clusters",
9268
"nickname": "o_clusters",
93-
"description": "The segmented clouds.",
69+
"description": "The clouds associated to each beam.",
9470
"optional": false,
9571
"sourceCount": 0,
9672
"graft": false

0 commit comments

Comments
 (0)