Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ply loaders ghcomponents #17

Merged
merged 4 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ If you want to use the GHEditor it's ok but everytime you modify the pakcage or
### B.3) Componentize the code
Prepare your component as explained here. You can componentize it locally and test it in Grasshopper. Here's how to componentize:
```terminal
python f:\diffCheck\src\gh\util\componentizer_cpy.py --ghio "C:\Users\andre\.nuget\packages\grasshopper\8.2.23346.13001\lib\net48\" .\src\gh\components\ .\build\gh
python .\invokes\ghcomponentize\ghcomponentizer.py --ghio "C:\Users\andre\.nuget\packages\grasshopper\8.2.23346.13001\lib\net48\" .\src\gh\components\ .\build\gh
```
> Note that you need to find the path to your GHIO folder. This is the folder where the `Grasshopper.dll` is located. E.g. You can find it in the `nuget` folder in the Rhino installation directory.

Expand Down
21 changes: 12 additions & 9 deletions src/gh/components/DF_load_cloud_from_file/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,33 @@
import Grasshopper as gh
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML

import diffCheck
from diffCheck import diffcheck_bindings
import diffCheck.df_cvt_bindings
from diffCheck import df_cvt_bindings

class DFLoadCloudFromFile(component):
def RunScript(self,
i_path: str,
i_scalef: float) -> rg.PointCloud:
"""
Import a cloud from a file and scale it if needed.
This component loads a point cloud from a .ply file.

:param i_path: path to the file
:param i_path: path to the .ply file
:param i_scalef: scale factor

:return o_out: rhino cloud
:return o_rh_cloud: Rhino PointCloud
"""
# import and convert to rhino cloud
# import and convert to Rhino Cloud
df_cloud = diffcheck_bindings.dfb_geometry.DFPointCloud()
df_cloud.load_from_PLY(i_path)
rh_cloud = diffCheck.df_cvt_bindings.cvt_dfcloud_2_rhcloud(df_cloud)
rh_cloud = df_cvt_bindings.cvt_dfcloud_2_rhcloud(df_cloud)

# scale if needed
centroid = rh_cloud.GetBoundingBox(True).Center
x_form_scale = rg.Transform.Scale(centroid, i_scalef)
rh_cloud.Transform(x_form_scale)

return [rh_cloud] # do this to output 'Rhino.Geometry.PointCloud' instead of 'Rhino.Geometry.PointCloudItem'

return [rh_cloud]

# if __name__ == "__main__":
# com = DFLoadCloudFromFile()
# o_rh_cloud = com.RunScript(i_path, i_scalef)
Binary file modified src/gh/components/DF_load_cloud_from_file/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/gh/components/DF_load_cloud_from_file/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{
"name": "i_path",
"nickname": "i_path",
"description": "Path of the file (e.g. .ply) to import",
"description": "Path to the .ply file to import",
"optional": true,
"allowTreeAccess": true,
"showTypeHints": true,
Expand All @@ -42,7 +42,7 @@
{
"name": "o_rh_cloud",
"nickname": "o_rh_cloud",
"description": "The imported cloud in rhino format.",
"description": "The imported point cloud as a Rhino object.",
"optional": false,
"sourceCount": 0,
"graft": false
Expand Down
41 changes: 14 additions & 27 deletions src/gh/components/DF_load_mesh_from_file/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,33 @@
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

from diffCheck import df_cvt_bindings

class DFLoadMeshFromFile(component):
def RunScript(self,
i_path : str,
i_scalef : float
) -> rg.PointCloud:
i_path: str,
i_scalef: float) -> rg.Mesh:
"""
This compoonent load a mesh rhino from a ply file.
This compoonent loads a Rhino mesh from a .ply file.

:param i_path: path to the ply file
:param i_path: path to the .ply file
:param i_scalef: scale factor

:return o_mesh: rhino mesh
:return o_mesh: Rhino Mesh
"""
print(f"diffCheck version: {diffCheck.__version__}")

df_cloud = diffcheck_bindings.dfb_geometry.DFPointCloud()
df_cloud.load_from_PLY(i_path)
rgpoints = [rg.Point3d(pt[0], pt[1], pt[2]) for pt in df_cloud.points]
rh_cloud = rg.PointCloud(rgpoints)
# import and convert to Rhino Mesh
df_mesh = diffcheck_bindings.dfb_geometry.DFMesh()
df_mesh.load_from_PLY(i_path)
rh_mesh = df_cvt_bindings.cvt_dfmesh_2_rhmesh(df_mesh)

# scale if needed
centroid = rh_cloud.GetBoundingBox(True).Center
centroid = rh_mesh.GetBoundingBox(True).Center
x_form_scale = rg.Transform.Scale(centroid, i_scalef)
rh_cloud.Transform(x_form_scale)


rh_mesh = rh_cloud

return rh_mesh
rh_mesh.Transform(x_form_scale)

return [rh_mesh]

# if __name__ == "__main__":
# com = DFLoadMeshFromFile()
# o_rh_mesh = com.RunScript(
# i_path,n
# i_scalef
# )
# o_rh_mesh = com.RunScript(i_path, i_scalef)
Binary file modified src/gh/components/DF_load_mesh_from_file/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/gh/components/DF_load_mesh_from_file/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{
"name": "i_path",
"nickname": "i_path",
"description": "Path of the file (e.g. .ply) to import",
"description": "Path to the .ply file to import",
"optional": true,
"allowTreeAccess": true,
"showTypeHints": true,
Expand All @@ -42,7 +42,7 @@
{
"name": "o_rh_mesh",
"nickname": "o_rh_mesh",
"description": "The imported mesh.",
"description": "The imported mesh as a Rhino object.",
"optional": false,
"sourceCount": 0,
"graft": false
Expand Down
5 changes: 2 additions & 3 deletions src/gh/diffCheck/diffCheck.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ Summary: DiffCheck is a package to check the differences between two timber stru
Home-page: https://github.com/diffCheckOrg/diffCheck
Author: Andrea Settimi, Damien Gilliard, Eleni Skevaki, Marirena Kladeftira, Julien Gamerro, Stefana Parascho, and Yves Weinand
Author-email: [email protected]
License: UNKNOWN
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Description-Content-Type: text/markdown
Requires-Dist: numpy
Requires-Dist: pybind11>=2.5.0

# DiffCheck Grasshopper Plugin

DiffCheck is a plugin for Rhino/Grasshopper that allows the user to compare a 3D model with its scan.

More information to come

Binary file modified src/gh/diffCheck/diffCheck/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified src/gh/diffCheck/diffCheck/__pycache__/df_util.cpython-39.pyc
Binary file not shown.
Loading