-
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-ADD: create component for bre2cloud conversion * FIX-UPDATE: DFMeshToCloud component returns one single point cloud * WIP: working on corrections * CAP-FIX: finsihed cleaning minor + docuemtnation --------- Co-authored-by: Andrea Settimi <[email protected]>
- Loading branch information
1 parent
07c2aef
commit 2fdef56
Showing
7 changed files
with
130 additions
and
12 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,8 @@ | ||
.. image:: ../src/gh/components/DF_brep_to_cloud/icon.png | ||
:align: left | ||
:width: 40px | ||
|
||
``DFBrepToCloud`` component | ||
=========================== | ||
|
||
.. ghcomponent_to_rst:: ../src/gh/components/DF_brep_to_cloud |
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
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,38 @@ | ||
#! python3 | ||
|
||
import Rhino | ||
from ghpythonlib.componentbase import executingcomponent as component | ||
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML | ||
|
||
from diffCheck import df_cvt_bindings | ||
import System | ||
|
||
|
||
class DFBrepToCloud(component): | ||
def RunScript(self, | ||
i_breps: System.Collections.Generic.IList[Rhino.Geometry.Brep], | ||
i_num_points: int): | ||
self.meshing_parameters = Rhino.Geometry.MeshingParameters.DefaultAnalysisMesh | ||
|
||
mesh_versions = [] | ||
|
||
if i_breps is None or i_num_points is None: | ||
return None | ||
|
||
for i_brep in i_breps: | ||
if not isinstance(i_brep, Rhino.Geometry.Brep): | ||
self.AddRuntimeMessage(RML.Warning, "Please provide a brep to convert to a cloud") | ||
return None | ||
meshes = Rhino.Geometry.Mesh.CreateFromBrep(i_brep, self.meshing_parameters) | ||
for mesh in meshes: | ||
mesh_versions.append(mesh) | ||
|
||
unified_mesh = mesh_versions[0] | ||
unified_mesh.Append(mesh_versions) | ||
unified_mesh.Faces.ConvertQuadsToTriangles() | ||
df_mesh = df_cvt_bindings.cvt_rhmesh_2_dfmesh(unified_mesh) | ||
df_cloud = df_mesh.sample_points_uniformly(i_num_points) | ||
rgpoints = [Rhino.Geometry.Point3d(pt[0], pt[1], pt[2]) for pt in df_cloud.points] | ||
rh_cloud = Rhino.Geometry.PointCloud(rgpoints) | ||
print(rh_cloud) | ||
return [rh_cloud] |
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": "DFBrepToMesh", | ||
"nickname": "DFBrepToMesh", | ||
"category": "diffCheck", | ||
"subcategory": "Cloud", | ||
"description": "Create unique point cloud from list of breps.", | ||
"exposure": 4, | ||
"instanceGuid": "0194cbfc-1a6d-44a7-ae5d-7495db20edbe", | ||
"ghpython": { | ||
"hideOutput": true, | ||
"hideInput": true, | ||
"isAdvancedMode": true, | ||
"marshalOutGuids": true, | ||
"iconDisplay": 2, | ||
"inputParameters": [ | ||
{ | ||
"name": "i_breps", | ||
"nickname": "i_breps", | ||
"description": "The breps to convert to point cloud.", | ||
"optional": false, | ||
"allowTreeAccess": false, | ||
"showTypeHints": true, | ||
"scriptParamAccess": "list", | ||
"wireDisplay": "default", | ||
"sourceCount": 0, | ||
"typeHintID": "brep" | ||
}, | ||
{ | ||
"name": "i_num_points", | ||
"nickname": "i_num_points", | ||
"description": "The number of points in the new point cloud.", | ||
"optional": false, | ||
"allowTreeAccess": false, | ||
"showTypeHints": true, | ||
"scriptParamAccess": "item", | ||
"wireDisplay": "default", | ||
"sourceCount": 0, | ||
"typeHintID": "int" | ||
} | ||
], | ||
"outputParameters": [ | ||
{ | ||
"name": "o_pointcloud", | ||
"nickname": "o_pointcloud", | ||
"description": "The generated point cloud.", | ||
"optional": false, | ||
"sourceCount": 0, | ||
"graft": false | ||
} | ||
] | ||
} | ||
} |
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
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