-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: starting to wrap global registrations
- Loading branch information
Showing
7 changed files
with
650 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#! python3 | ||
|
||
import System | ||
import typing | ||
|
||
import Rhino | ||
import Rhino.Geometry as rg | ||
from ghpythonlib.componentbase import executingcomponent as component | ||
|
||
import Grasshopper as gh | ||
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML | ||
|
||
import diffCheck | ||
from diffCheck import diffcheck_bindings | ||
import diffCheck.df_cvt_bindings | ||
|
||
|
||
class DFGlobalRegistration(component): | ||
def RunScript(self, | ||
i_mesh: rg.Mesh, | ||
i_points: int) -> rg.PointCloud: | ||
""" | ||
Convert a Rhino mesh to a cloud. | ||
:param i_mesh: mesh to convert | ||
:param i_points: number of points to sample | ||
:return o_cloud: rhino cloud | ||
""" | ||
|
||
diffCheck.df_cvt_bindings.test() | ||
|
||
df_mesh = diffCheck.df_cvt_bindings.cvt_rhmesh_2_dfmesh(i_mesh) | ||
df_cloud = df_mesh.sample_points_uniformly(i_points) | ||
|
||
# convert the df_cloud to a rhino cloud | ||
rgpoints = [rg.Point3d(pt[0], pt[1], pt[2]) for pt in df_cloud.points] | ||
rh_cloud = rg.PointCloud(rgpoints) | ||
|
||
return [rh_cloud] | ||
|
||
|
||
if __name__ == "__main__": | ||
com = DFGlobalRegistration() | ||
com.RunScript(i_mesh, i_points) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"name": "DFMeshToCloud", | ||
"nickname": "Geo2Pcd", | ||
"category": "diffCheck", | ||
"subcategory": "Cloud", | ||
"description": "Sample a point cloud from a mesh.", | ||
"exposure": 4, | ||
"instanceGuid": "e8e5e122-40d0-45cd-9f93-cc756fd8b307", | ||
"ghpython": { | ||
"hideOutput": true, | ||
"hideInput": true, | ||
"isAdvancedMode": true, | ||
"marshalOutGuids": true, | ||
"iconDisplay": 2, | ||
"inputParameters": [ | ||
{ | ||
"name": "i_mesh", | ||
"nickname": "i_mesh", | ||
"description": "Mesh to sample into a point cloud.", | ||
"optional": true, | ||
"allowTreeAccess": true, | ||
"showTypeHints": true, | ||
"scriptParamAccess": "item", | ||
"wireDisplay": "default", | ||
"sourceCount": 0, | ||
"typeHintID": "mesh" | ||
}, | ||
{ | ||
"name": "i_points", | ||
"nickname": "i_points", | ||
"description": "The number of points of the created cloud.", | ||
"optional": false, | ||
"allowTreeAccess": true, | ||
"showTypeHints": true, | ||
"scriptParamAccess": "item", | ||
"wireDisplay": "default", | ||
"sourceCount": 0, | ||
"typeHintID": "int" | ||
} | ||
], | ||
"outputParameters": [ | ||
{ | ||
"name": "o_rh_cloud", | ||
"nickname": "o_rh_cloud", | ||
"description": "The output sampled cloud.", | ||
"optional": false, | ||
"sourceCount": 0, | ||
"graft": false | ||
} | ||
] | ||
} | ||
} |
Binary file modified
BIN
+0 Bytes
(100%)
src/gh/diffCheck/diffCheck/__pycache__/df_geometries.cpython-39.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
|
||
import diffCheck.df_joint_detector | ||
|
||
|
||
@dataclass | ||
class DFVertex: | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,88 @@ | ||
#! python3 | ||
|
||
import Rhino | ||
import Rhino.Geometry as rg | ||
|
||
import os | ||
import System | ||
import typing | ||
|
||
|
||
|
||
import sys | ||
|
||
# Get the directory containing the script file | ||
script_dir = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
# Construct absolute paths | ||
path1 = os.path.join(script_dir, "src", "gh", "diffCheck", "diffCheck") | ||
path2 = os.path.join(script_dir, "src", "gh", "diffCheck") | ||
|
||
# Add the paths to sys.path | ||
sys.path.append(path1) | ||
sys.path.append(path2) | ||
|
||
# for p in sys.path: | ||
# print(p) | ||
|
||
# modules = [diffCheck, diffCheck.df_cvt_bindings] | ||
# for module in modules: | ||
# importlib.reload(module) | ||
|
||
# packages_2_reload = ["diffCheck"] | ||
# for package in packages_2_reload: | ||
# for key in list(sys.modules.keys()): | ||
# if package in key: | ||
# importlib.reload(sys.modules[key]) | ||
|
||
# if packages_2_reload is not None: | ||
# if packages_2_reload.__len__() != 0: | ||
# print("Reloading packages") | ||
# for package in packages_2_reload: | ||
# for key in list(sys.modules.keys()): | ||
# if package in key: | ||
# print(sys.modules[key]) | ||
# #check that the package must have the attribute __path__ | ||
# if hasattr(sys.modules[key], '__file__'): | ||
# print(sys.modules[key]) | ||
# importlib.reload(sys.modules[key]) | ||
|
||
import Rhino | ||
import Rhino.Geometry as rg | ||
from ghpythonlib.componentbase import executingcomponent as component | ||
|
||
import Grasshopper as gh | ||
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML | ||
|
||
import diffCheck | ||
from diffCheck import diffcheck_bindings | ||
import diffCheck.df_geometries | ||
|
||
import diffCheck.df_cvt_bindings | ||
|
||
|
||
|
||
|
||
|
||
class DFMeshToCloud(component): | ||
def RunScript(self, | ||
i_mesh: rg.Mesh, | ||
i_points: int) -> rg.PointCloud: | ||
""" | ||
Convert a Rhino mesh to a cloud. | ||
:param i_mesh: mesh to convert | ||
:param i_points: number of points to sample | ||
:return o_cloud: rhino cloud | ||
""" | ||
|
||
|
||
diffCheck.df_cvt_bindings.test() | ||
# diffCheck.df_geometries.test() | ||
|
||
|
||
df_mesh = diffCheck.df_cvt_bindings.cvt_rhmesh_2_dfmesh(i_mesh) | ||
df_cloud = df_mesh.sample_points_uniformly(i_points) | ||
|
||
# convert the df_cloud to a rhino cloud | ||
rgpoints = [rg.Point3d(pt[0], pt[1], pt[2]) for pt in df_cloud.points] | ||
rh_cloud = rg.PointCloud(rgpoints) | ||
|
||
return [rh_cloud] | ||
|
||
|
||
if __name__ == "__main__": | ||
# print("Hello from diffCheck_assspp.py") | ||
# diffCheck.df_cvt_bindings.test() | ||
pass | ||
com = DFMeshToCloud() | ||
com.RunScript(i_mesh, i_points) |
Oops, something went wrong.