Skip to content

Commit 5f18290

Browse files
committed
ADD-WIP placeholders for cloud_to_cloud and cloud_to_mesh gh components
1 parent 41da968 commit 5f18290

File tree

6 files changed

+446
-0
lines changed

6 files changed

+446
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
from diffCheck import diffcheck_bindings
15+
from diffCheck import df_cvt_bindings
16+
import diffCheck.df_util
17+
18+
class CloudToMeshDistance(component):
19+
def RunScript(self,
20+
i_cloud_source: rg.PointCloud,
21+
i_cloud_target: rg.PointCloud,
22+
23+
) -> [float]:
24+
"""
25+
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.
26+
27+
:param i_cloud_source: source point cloud
28+
:param i_cloud_target: target point cloud to align to
29+
30+
:return o_distances : list of calculated distances for each point
31+
"""
32+
if i_cloud_source is None or i_cloud_target is None:
33+
ghenv.Component.AddRuntimeMessage(RML.Warning, "Please provide both objects of type point clouds to compare")
34+
return None
35+
36+
# conversion
37+
df_cloud_source = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud_source)
38+
df_cloud_target = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud_target)
39+
40+
# calculate distances
41+
o_distances = cloud_2_mesh_distance(df_cloud_source, df_cloud_target)
42+
43+
return o_distances
44+
45+
46+
if __name__ == "__main__":
47+
com = CloudToMeshDistance(component)
48+
o_distances = com.RunScript(
49+
i_cloud_source,
50+
i_cloud_target
51+
)
9.56 KB
Loading
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
{
2+
"name": "RANSACGlobalRegistration",
3+
"nickname": "RANSACGReg",
4+
"category": "diffCheck",
5+
"subcategory": "Registrations",
6+
"description": "Register two point clouds together with a feature matching based on RANSAC.",
7+
"exposure": 4,
8+
"instanceGuid": "805911b9-7ea9-4bbf-be34-00f9f225b9b3",
9+
"ghpython": {
10+
"hideOutput": true,
11+
"hideInput": true,
12+
"isAdvancedMode": true,
13+
"marshalOutGuids": true,
14+
"iconDisplay": 2,
15+
"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+
},
28+
{
29+
"name": "i_cloud_source",
30+
"nickname": "i_cloud_source",
31+
"description": "The source point cloud.",
32+
"optional": true,
33+
"allowTreeAccess": true,
34+
"showTypeHints": true,
35+
"scriptParamAccess": "item",
36+
"wireDisplay": "default",
37+
"sourceCount": 0,
38+
"typeHintID": "pointcloud"
39+
},
40+
{
41+
"name": "i_cloud_target",
42+
"nickname": "i_cloud_target",
43+
"description": "The target cloud.",
44+
"optional": false,
45+
"allowTreeAccess": true,
46+
"showTypeHints": true,
47+
"scriptParamAccess": "item",
48+
"wireDisplay": "default",
49+
"sourceCount": 0,
50+
"typeHintID": "pointcloud"
51+
},
52+
{
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.",
56+
"optional": false,
57+
"allowTreeAccess": true,
58+
"showTypeHints": true,
59+
"scriptParamAccess": "item",
60+
"wireDisplay": "default",
61+
"sourceCount": 0,
62+
"typeHintID": "float"
63+
},
64+
{
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.",
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_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.",
80+
"optional": false,
81+
"allowTreeAccess": true,
82+
"showTypeHints": true,
83+
"scriptParamAccess": "item",
84+
"wireDisplay": "default",
85+
"sourceCount": 0,
86+
"typeHintID": "float"
87+
},
88+
{
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.",
92+
"optional": false,
93+
"allowTreeAccess": true,
94+
"showTypeHints": true,
95+
"scriptParamAccess": "item",
96+
"wireDisplay": "default",
97+
"sourceCount": 0,
98+
"typeHintID": "bool"
99+
},
100+
{
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.",
104+
"optional": false,
105+
"allowTreeAccess": true,
106+
"showTypeHints": true,
107+
"scriptParamAccess": "item",
108+
"wireDisplay": "default",
109+
"sourceCount": 0,
110+
"typeHintID": "int"
111+
},
112+
{
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).",
116+
"optional": false,
117+
"allowTreeAccess": true,
118+
"showTypeHints": true,
119+
"scriptParamAccess": "item",
120+
"wireDisplay": "default",
121+
"sourceCount": 0,
122+
"typeHintID": "float"
123+
},
124+
{
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.",
128+
"optional": false,
129+
"allowTreeAccess": true,
130+
"showTypeHints": true,
131+
"scriptParamAccess": "item",
132+
"wireDisplay": "default",
133+
"sourceCount": 0,
134+
"typeHintID": "float"
135+
},
136+
{
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.",
140+
"optional": false,
141+
"allowTreeAccess": true,
142+
"showTypeHints": true,
143+
"scriptParamAccess": "item",
144+
"wireDisplay": "default",
145+
"sourceCount": 0,
146+
"typeHintID": "int"
147+
},
148+
{
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.",
166+
"optional": false,
167+
"sourceCount": 0,
168+
"graft": false
169+
}
170+
]
171+
}
172+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
from diffCheck import diffcheck_bindings
15+
from diffCheck import df_cvt_bindings
16+
import diffCheck.df_util
17+
18+
class CloudToCloudDistance(component):
19+
def RunScript(self,
20+
i_cloud_source: rg.PointCloud,
21+
i_cloud_target: rg.PointCloud,
22+
23+
) -> [float]:
24+
"""
25+
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.
26+
27+
:param i_cloud_source: source point cloud
28+
:param i_cloud_target: target point cloud to align to
29+
30+
:return o_distances : list of calculated distances for each point
31+
"""
32+
if i_cloud_source is None or i_cloud_target is None:
33+
ghenv.Component.AddRuntimeMessage(RML.Warning, "Please provide both objects of type point clouds to compare")
34+
return None
35+
36+
# conversion
37+
df_cloud_source = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud_source)
38+
df_cloud_target = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud_target)
39+
40+
# calculate distances
41+
o_distances = cloud_2_cloud_distance(df_cloud_source, df_cloud_target)
42+
43+
return o_distances
44+
45+
46+
if __name__ == "__main__":
47+
com = CloudToCloudDistance(component)
48+
o_distances = com.RunScript(
49+
i_cloud_source,
50+
i_cloud_target
51+
)
9.56 KB
Loading

0 commit comments

Comments
 (0)