Skip to content

Commit e8f6cd7

Browse files
committed
WIP: starting to wrap global registrations
1 parent a2f6f1a commit e8f6cd7

File tree

7 files changed

+650
-313
lines changed

7 files changed

+650
-313
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
import diffCheck.df_cvt_bindings
16+
17+
18+
class DFGlobalRegistration(component):
19+
def RunScript(self,
20+
i_mesh: rg.Mesh,
21+
i_points: int) -> rg.PointCloud:
22+
"""
23+
Convert a Rhino mesh to a cloud.
24+
25+
:param i_mesh: mesh to convert
26+
:param i_points: number of points to sample
27+
28+
:return o_cloud: rhino cloud
29+
"""
30+
31+
diffCheck.df_cvt_bindings.test()
32+
33+
df_mesh = diffCheck.df_cvt_bindings.cvt_rhmesh_2_dfmesh(i_mesh)
34+
df_cloud = df_mesh.sample_points_uniformly(i_points)
35+
36+
# convert the df_cloud to a rhino cloud
37+
rgpoints = [rg.Point3d(pt[0], pt[1], pt[2]) for pt in df_cloud.points]
38+
rh_cloud = rg.PointCloud(rgpoints)
39+
40+
return [rh_cloud]
41+
42+
43+
if __name__ == "__main__":
44+
com = DFGlobalRegistration()
45+
com.RunScript(i_mesh, i_points)
10.5 KB
Loading
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "DFMeshToCloud",
3+
"nickname": "Geo2Pcd",
4+
"category": "diffCheck",
5+
"subcategory": "Cloud",
6+
"description": "Sample a point cloud from a mesh.",
7+
"exposure": 4,
8+
"instanceGuid": "e8e5e122-40d0-45cd-9f93-cc756fd8b307",
9+
"ghpython": {
10+
"hideOutput": true,
11+
"hideInput": true,
12+
"isAdvancedMode": true,
13+
"marshalOutGuids": true,
14+
"iconDisplay": 2,
15+
"inputParameters": [
16+
{
17+
"name": "i_mesh",
18+
"nickname": "i_mesh",
19+
"description": "Mesh to sample into a point cloud.",
20+
"optional": true,
21+
"allowTreeAccess": true,
22+
"showTypeHints": true,
23+
"scriptParamAccess": "item",
24+
"wireDisplay": "default",
25+
"sourceCount": 0,
26+
"typeHintID": "mesh"
27+
},
28+
{
29+
"name": "i_points",
30+
"nickname": "i_points",
31+
"description": "The number of points of the created cloud.",
32+
"optional": false,
33+
"allowTreeAccess": true,
34+
"showTypeHints": true,
35+
"scriptParamAccess": "item",
36+
"wireDisplay": "default",
37+
"sourceCount": 0,
38+
"typeHintID": "int"
39+
}
40+
],
41+
"outputParameters": [
42+
{
43+
"name": "o_rh_cloud",
44+
"nickname": "o_rh_cloud",
45+
"description": "The output sampled cloud.",
46+
"optional": false,
47+
"sourceCount": 0,
48+
"graft": false
49+
}
50+
]
51+
}
52+
}
Binary file not shown.

src/gh/diffCheck/diffCheck/df_geometries.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
import diffCheck.df_joint_detector
1414

15-
1615
@dataclass
1716
class DFVertex:
1817
"""

src/gh/diffCheck/diffCheck_app.py

Lines changed: 75 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,88 @@
11
#! python3
22

3-
import Rhino
4-
import Rhino.Geometry as rg
5-
6-
import os
3+
import System
74
import typing
85

96

7+
8+
import sys
9+
10+
# Get the directory containing the script file
11+
script_dir = os.path.dirname(os.path.realpath(__file__))
12+
13+
# Construct absolute paths
14+
path1 = os.path.join(script_dir, "src", "gh", "diffCheck", "diffCheck")
15+
path2 = os.path.join(script_dir, "src", "gh", "diffCheck")
16+
17+
# Add the paths to sys.path
18+
sys.path.append(path1)
19+
sys.path.append(path2)
20+
21+
# for p in sys.path:
22+
# print(p)
23+
24+
# modules = [diffCheck, diffCheck.df_cvt_bindings]
25+
# for module in modules:
26+
# importlib.reload(module)
27+
1028
# packages_2_reload = ["diffCheck"]
11-
# for package in packages_2_reload:
12-
# for key in list(sys.modules.keys()):
13-
# if package in key:
14-
# importlib.reload(sys.modules[key])
29+
30+
# if packages_2_reload is not None:
31+
# if packages_2_reload.__len__() != 0:
32+
# print("Reloading packages")
33+
# for package in packages_2_reload:
34+
# for key in list(sys.modules.keys()):
35+
# if package in key:
36+
# print(sys.modules[key])
37+
# #check that the package must have the attribute __path__
38+
# if hasattr(sys.modules[key], '__file__'):
39+
# print(sys.modules[key])
40+
# importlib.reload(sys.modules[key])
41+
42+
import Rhino
43+
import Rhino.Geometry as rg
44+
from ghpythonlib.componentbase import executingcomponent as component
45+
46+
import Grasshopper as gh
47+
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
1548

1649
import diffCheck
50+
from diffCheck import diffcheck_bindings
1751
import diffCheck.df_geometries
18-
1952
import diffCheck.df_cvt_bindings
2053

2154

55+
56+
57+
58+
class DFMeshToCloud(component):
59+
def RunScript(self,
60+
i_mesh: rg.Mesh,
61+
i_points: int) -> rg.PointCloud:
62+
"""
63+
Convert a Rhino mesh to a cloud.
64+
65+
:param i_mesh: mesh to convert
66+
:param i_points: number of points to sample
67+
68+
:return o_cloud: rhino cloud
69+
"""
70+
71+
72+
diffCheck.df_cvt_bindings.test()
73+
# diffCheck.df_geometries.test()
74+
75+
76+
df_mesh = diffCheck.df_cvt_bindings.cvt_rhmesh_2_dfmesh(i_mesh)
77+
df_cloud = df_mesh.sample_points_uniformly(i_points)
78+
79+
# convert the df_cloud to a rhino cloud
80+
rgpoints = [rg.Point3d(pt[0], pt[1], pt[2]) for pt in df_cloud.points]
81+
rh_cloud = rg.PointCloud(rgpoints)
82+
83+
return [rh_cloud]
84+
85+
2286
if __name__ == "__main__":
23-
# print("Hello from diffCheck_assspp.py")
24-
# diffCheck.df_cvt_bindings.test()
25-
pass
87+
com = DFMeshToCloud()
88+
com.RunScript(i_mesh, i_points)

0 commit comments

Comments
 (0)