Skip to content

Commit 304d2ba

Browse files
committed
WIP: working on example
1 parent 94bdf5a commit 304d2ba

File tree

4 files changed

+177
-17
lines changed

4 files changed

+177
-17
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#! python3
2+
3+
import System
4+
import typing
5+
6+
import Rhino
7+
import Rhino.Geometry as rg
8+
from ghpythonlib.componentbase import executingcomponent as component
9+
10+
import Grasshopper as gh
11+
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
12+
13+
import diffCheck
14+
import diffCheck.df_geometries
15+
from diffCheck.diffcheck_bindings import dfb_segmentation
16+
17+
from diffCheck import df_cvt_bindings
18+
19+
20+
class DFCADSegmentator(component):
21+
def RunScript(self,
22+
i_clouds : typing.List[rg.PointCloud],
23+
i_assembly : diffCheck.df_geometries.DFAssembly,
24+
i_angle_threshold : float,
25+
i_association_threshold : float
26+
) -> rg.PointCloud:
27+
"""
28+
@param i_meshes : the beams (to be converted)
29+
@param i_angle_threshold : from 0 to 1, it's the sin value. The closer to 0 the less permissive and viceversa to 1.
30+
@param i_association_threshold: from 0 to infinite. By default 0.5. The closer to 0 the less permissive your point
31+
inclusion will be, the higher the value the opposite.
32+
33+
@return o_clusters : the clusters of the beams
34+
"""
35+
o_clusters = []
36+
37+
df_clouds = [df_cvt_bindings.cvt_rhcloud_2_dfcloud(cloud) for cloud in i_clouds]
38+
# df_meshes = [df_cvt_bindings.cvt_rhmesh_2_dfmesh(mesh) for mesh in i_meshes]
39+
40+
# # get the point clouds corresponding to the beams
41+
# df_asssociated_clusters : List[dfCloud] = dfb_segmentation.DFSegmentation.associate_clusters(
42+
# reference_mesh=df_meshes,
43+
# unassociated_clusters=df_clouds,
44+
# angle_threshold=i_angle_threshold,
45+
# association_threshold=i_association_threshold
46+
# )
47+
48+
print("test")
49+
50+
51+
return o_clusters
52+
53+
if __name__ == "__main__":
54+
com = DFCADSegmentator()
55+
o_clusters = com.RunScript(
56+
i_clouds,
57+
i_assembly,
58+
i_angle_threshold,
59+
i_association_threshold
60+
)
10 KB
Loading
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"name": "DFNormalSegmentator",
3+
"nickname": "DFCNorSeg",
4+
"category": "diffCheck",
5+
"subcategory": "Segmentation",
6+
"description": "Cluster a point cloud based on normals.",
7+
"exposure": 4,
8+
"instanceGuid": "8f732cef-771c-41b8-acca-562211fd3a80",
9+
"ghpython": {
10+
"hideOutput": true,
11+
"hideInput": true,
12+
"isAdvancedMode": true,
13+
"marshalOutGuids": true,
14+
"iconDisplay": 2,
15+
"inputParameters": [
16+
{
17+
"name": "i_cloud",
18+
"nickname": "i_cloud",
19+
"description": "The point cloud to reduce the size.",
20+
"optional": true,
21+
"allowTreeAccess": true,
22+
"showTypeHints": true,
23+
"scriptParamAccess": "item",
24+
"wireDisplay": "default",
25+
"sourceCount": 0,
26+
"typeHintID": "pointcloud"
27+
},
28+
{
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.",
44+
"optional": false,
45+
"allowTreeAccess": true,
46+
"showTypeHints": true,
47+
"scriptParamAccess": "item",
48+
"wireDisplay": "default",
49+
"sourceCount": 0,
50+
"typeHintID": "int"
51+
},
52+
{
53+
"name": "i_use_knn_neighborhood",
54+
"nickname": "i_use_knn_neighborhood",
55+
"description": "If true use knn, otherwise radius search.",
56+
"optional": false,
57+
"allowTreeAccess": true,
58+
"showTypeHints": true,
59+
"scriptParamAccess": "item",
60+
"wireDisplay": "default",
61+
"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"
75+
},
76+
{
77+
"name": "i_radius_neighborhood_size",
78+
"nickname": "i_radius_neighborhood_size",
79+
"description": "The size of the radius.",
80+
"optional": false,
81+
"allowTreeAccess": true,
82+
"showTypeHints": true,
83+
"scriptParamAccess": "item",
84+
"wireDisplay": "default",
85+
"sourceCount": 0,
86+
"typeHintID": "float"
87+
}
88+
],
89+
"outputParameters": [
90+
{
91+
"name": "o_clusters",
92+
"nickname": "o_clusters",
93+
"description": "The segmented clouds.",
94+
"optional": false,
95+
"sourceCount": 0,
96+
"graft": false
97+
}
98+
]
99+
}
100+
}

0 commit comments

Comments
 (0)