Skip to content

Commit aa39358

Browse files
committed
Merge remote-tracking branch 'origin/fix_registration_metadata'
2 parents 2fdef56 + 14a7137 commit aa39358

File tree

7 files changed

+20
-59
lines changed

7 files changed

+20
-59
lines changed

src/gh/components/DF_fast_global_registration/code.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66

77
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
88

9-
import diffCheck
109
from diffCheck import diffcheck_bindings
1110
from diffCheck import df_cvt_bindings
12-
import diffCheck.df_util
1311

1412

1513
class DFFastGlobalRegistration(component):
@@ -22,9 +20,12 @@ def RunScript(self,
2220
i_iteration_number: int,
2321
i_max_tuple_count: int
2422
) -> rg.Transform:
23+
# preliminary checks
2524
if i_cloud_source is None or i_cloud_target is None:
2625
ghenv.Component.AddRuntimeMessage(RML.Warning, "Please provide both objects of type point clouds to align") # noqa: F821
2726
return None
27+
if not i_cloud_source.ContainsNormals or not i_cloud_target.ContainsNormals:
28+
ghenv.Component.AddRuntimeMessage(RML.Error, "Please compute cloud's normals with a component before") # noqa: F821
2829

2930
# set default values
3031
if i_radius_kd_search is None:
@@ -38,11 +39,6 @@ def RunScript(self,
3839
if i_max_tuple_count is None:
3940
i_max_tuple_count = 1000
4041

41-
# get the working unit of the Rhino document, if other than meters, set a multiplier factor
42-
scalef = diffCheck.df_util.get_doc_2_meters_unitf()
43-
i_radius_kd_search *= scalef
44-
i_max_corrspondence_dist *= scalef
45-
4642
df_cloud_source = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud_source)
4743
df_cloud_target = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud_target)
4844

src/gh/components/DF_fast_global_registration/metadata.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@
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",

src/gh/components/DF_icp_registration/code.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66

77
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
88

9-
import diffCheck
109
from diffCheck import diffcheck_bindings
1110
from diffCheck import df_cvt_bindings
12-
import diffCheck.df_util
1311

1412

1513
class DFICPRegistration(component):
@@ -25,9 +23,12 @@ def RunScript(self,
2523
is_t_estimate_pt2pt: bool, # valid only for 03dicp
2624
i_use_point_to_plane: bool # valid only for 03dicp
2725
) -> rg.Transform:
26+
# preliminary checks
2827
if i_cloud_source is None or i_cloud_target is None:
2928
ghenv.Component.AddRuntimeMessage(RML.Warning, "Please provide both objects of type point clouds to align") # noqa: F821
3029
return None
30+
if not i_cloud_source.ContainsNormals or not i_cloud_target.ContainsNormals:
31+
ghenv.Component.AddRuntimeMessage(RML.Error, "Please compute cloud's normals with a component before") # noqa: F821
3132

3233
# set default values
3334
if i_use_generalized_icp is None:
@@ -37,10 +38,6 @@ def RunScript(self,
3738
if i_max_iteration is None:
3839
i_max_iteration = 50
3940

40-
# get the working unit of the Rhino document, if other than meters, set a multiplier factor
41-
scalef = diffCheck.df_util.get_doc_2_meters_unitf()
42-
i_max_corrspondence_dist *= scalef
43-
4441
# conversion
4542
df_cloud_source = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud_source)
4643
df_cloud_target = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud_target)

src/gh/components/DF_icp_registration/metadata.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@
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_use_generalized_icp",
3018
"nickname": "i_use_generalized_icp",

src/gh/components/DF_ransac_global_registration/code.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66

77
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
88

9-
import diffCheck
109
from diffCheck import diffcheck_bindings
1110
from diffCheck import df_cvt_bindings
12-
import diffCheck.df_util
11+
1312

1413
class DFRANSACGlobalRegistration(component):
1514
def RunScript(self,
@@ -25,9 +24,12 @@ def RunScript(self,
2524
i_max_iterations: int,
2625
i_confidence_threshold: float
2726
) -> rg.Transform:
27+
# preliminary checks
2828
if i_cloud_source is None or i_cloud_target is None:
2929
ghenv.Component.AddRuntimeMessage(RML.Warning, "Please provide both objects of type point clouds to align") # noqa: F821
3030
return None
31+
if not i_cloud_source.ContainsNormals or not i_cloud_target.ContainsNormals:
32+
ghenv.Component.AddRuntimeMessage(RML.Error, "Please compute cloud's normals with a component before") # noqa: F821
3133

3234
# set default values
3335
if i_radius_kd_search is None:
@@ -49,12 +51,6 @@ def RunScript(self,
4951
if i_confidence_threshold is None:
5052
i_confidence_threshold = 0.999
5153

52-
# get the working unit of the Rhino document, if other than meters, set a multiplier factor
53-
scalef = diffCheck.df_util.get_doc_2_meters_unitf()
54-
i_radius_kd_search *= scalef
55-
i_max_corrspondence_dist *= scalef
56-
i_checker_dist *= scalef
57-
5854
# conversion
5955
df_cloud_source = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud_source)
6056
df_cloud_target = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud_target)

src/gh/components/DF_ransac_global_registration/metadata.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@
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",

src/gh/components/DF_tester/code.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,22 @@
1111

1212
class DFTester(component):
1313
def RunScript(self):
14+
# version
1415
ghenv.Component.Message = f"diffCheck v: {diffCheck.__version__}" # noqa: F821
15-
is_binding_imported = diffcheck_bindings.dfb_test.test()
1616

17+
# bindings
18+
is_binding_imported = diffcheck_bindings.dfb_test.test()
1719
if not is_binding_imported:
1820
ghenv.Component.AddRuntimeMessage(RML.Warning, "Bindings not imported.") # noqa: F821
1921
else:
2022
ghenv.Component.AddRuntimeMessage(RML.Remark, "Bindings imported.") # noqa: F821
21-
2223
print(f"diffCheck test: {diffCheck.df_cvt_bindings.test_bindings()}")
2324

25+
# workspace unit
26+
scalef = diffCheck.df_util.get_doc_2_meters_unitf()
27+
if scalef != 1.0:
28+
ghenv.Component.AddRuntimeMessage(RML.Warning, "Workspace unit is not in meters.") # noqa: F821
29+
else:
30+
ghenv.Component.AddRuntimeMessage(RML.Remark, "Workspace unit is in meters.") # noqa: F821
31+
2432
return is_binding_imported

0 commit comments

Comments
 (0)