diff --git a/src/gh/components/DF_CAD_segmentator/code.py b/src/gh/components/DF_CAD_segmentator/code.py index 49ab985b..2e57ca65 100644 --- a/src/gh/components/DF_CAD_segmentator/code.py +++ b/src/gh/components/DF_CAD_segmentator/code.py @@ -1,13 +1,12 @@ #! python3 -import typing +import System -import Rhino.Geometry as rg +import Rhino from ghpythonlib.componentbase import executingcomponent as component +from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML -import diffCheck -import diffCheck.df_geometries from diffCheck.diffcheck_bindings import dfb_segmentation from diffCheck import df_cvt_bindings @@ -16,11 +15,19 @@ class DFCADSegmentator(component): def RunScript(self, - i_clouds : typing.List[rg.PointCloud], - i_assembly : diffCheck.df_geometries.DFAssembly, - i_angle_threshold : float, - i_association_threshold : float - ) -> rg.PointCloud: + i_clouds: System.Collections.Generic.IList[Rhino.Geometry.PointCloud], + i_assembly, + i_angle_threshold: float = 0.1, + i_association_threshold: float = 0.1) -> rg.PointCloud: + + if i_clouds is None or i_assembly is None: + self.AddRuntimeMessage(RML.Warning, "Please provide a cloud and an assembly to segmentate") + return None + if i_angle_threshold is None: + i_angle_threshold = 0.1 + if i_association_threshold is None: + i_association_threshold = 0.1 + o_clusters = [] df_clusters = [] # we make a deepcopy of the input clouds diff --git a/src/gh/components/DF_CAD_segmentator/metadata.json b/src/gh/components/DF_CAD_segmentator/metadata.json index 51de3ad2..415dc571 100644 --- a/src/gh/components/DF_CAD_segmentator/metadata.json +++ b/src/gh/components/DF_CAD_segmentator/metadata.json @@ -40,7 +40,7 @@ { "name": "i_angle_threshold", "nickname": "i_angle_threshold", - "description": "From 0 to 1, it's the sin value. The closer to 0 the less permissive and viceversa to 1.", + "description": "From 0 to 1, it's the sin value. By default 0.1. The closer to 0 the less permissive and viceversa to 1.", "optional": false, "allowTreeAccess": true, "showTypeHints": true, @@ -52,7 +52,7 @@ { "name": "i_association_threshold", "nickname": "i_association_threshold", - "description": "From 0 to infinite. By default 0.5. The closer to 0 the less permissive your point.", + "description": "From 0 to infinite. By default 0.1. The closer to 0 the less permissive your point.", "optional": false, "allowTreeAccess": true, "showTypeHints": true, diff --git a/src/gh/components/DF_cloud_cloud_distance/code.py b/src/gh/components/DF_cloud_cloud_distance/code.py index b5f85217..f42cb471 100644 --- a/src/gh/components/DF_cloud_cloud_distance/code.py +++ b/src/gh/components/DF_cloud_cloud_distance/code.py @@ -1,8 +1,8 @@ #! python3 -import typing +import System -import Rhino.Geometry as rg +import Rhino from ghpythonlib.componentbase import executingcomponent as component from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML @@ -14,8 +14,8 @@ class DFCloudCloudDistance(component): def RunScript(self, - i_cloud_source: typing.List[rg.PointCloud], - i_cloud_target: typing.List[rg.PointCloud], + i_cloud_source: System.Collections.Generic.List[Rhino.Geometry.PointCloud], + i_cloud_target: System.Collections.Generic.List[Rhino.Geometry.PointCloud], i_swap: bool): if i_cloud_source is None or i_cloud_target is None: ghenv.Component.AddRuntimeMessage(RML.Warning, "Please provide both objects of type point clouds to compare") # noqa: F821 diff --git a/src/gh/components/DF_cloud_mesh_distance/code.py b/src/gh/components/DF_cloud_mesh_distance/code.py index fbd46531..c466a8ff 100644 --- a/src/gh/components/DF_cloud_mesh_distance/code.py +++ b/src/gh/components/DF_cloud_mesh_distance/code.py @@ -1,24 +1,23 @@ #! python3 -import typing +import System -import Rhino.Geometry as rg +import Rhino from ghpythonlib.componentbase import executingcomponent as component from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML import diffCheck from diffCheck import df_cvt_bindings from diffCheck import df_error_estimation -from diffCheck.df_geometries import DFAssembly class DFCloudMeshDistance(component): def RunScript(self, - i_cloud_source: typing.List[rg.PointCloud], - i_assembly: DFAssembly, - i_signed_flag: bool, - i_swap: bool, - i_analysis_resolution): + i_cloud_source: System.Collections.Generic.List[Rhino.Geometry.PointCloud], + i_assembly, + i_signed_flag: bool, + i_swap: bool, + i_analysis_resolution: float): if i_analysis_resolution is None: scalef = diffCheck.df_util.get_doc_2_meters_unitf() diff --git a/src/gh/components/DF_cloud_normal_estimator/code.py b/src/gh/components/DF_cloud_normal_estimator/code.py index 8c888685..09bf1ea6 100644 --- a/src/gh/components/DF_cloud_normal_estimator/code.py +++ b/src/gh/components/DF_cloud_normal_estimator/code.py @@ -1,19 +1,17 @@ #! python3 - -import Rhino.Geometry as rg +import Rhino from ghpythonlib.componentbase import executingcomponent as component from diffCheck import df_cvt_bindings class DFCloudNormalEstimator(component): def RunScript(self, - i_cloud : rg.PointCloud = None, - i_knn : int = None, - i_radius : float = None, - i_switch_mode : bool = True - ): - o_cloud = rg.PointCloud() + i_cloud: Rhino.Geometry.PointCloud, + i_knn: int, + i_radius: int, + i_switch_mode: bool): + o_cloud = Rhino.Geometry.PointCloud() df_cloud = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud) diff --git a/src/gh/components/DF_cloud_size_downsample/code.py b/src/gh/components/DF_cloud_size_downsample/code.py index be261d4c..57eabccc 100644 --- a/src/gh/components/DF_cloud_size_downsample/code.py +++ b/src/gh/components/DF_cloud_size_downsample/code.py @@ -1,17 +1,14 @@ #! python3 -import Rhino.Geometry as rg +import Rhino from ghpythonlib.componentbase import executingcomponent as component from diffCheck import df_cvt_bindings class DFCloudSizeDownsample(component): - def RunScript(self, - i_cloud: rg.PointCloud, - i_size: int, - ) -> rg.PointCloud: + def RunScript(self, i_cloud: Rhino.Geometry.PointCloud, i_size: float) -> Rhino.Geometry.PointCloud: df_cloud = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud) df_cloud.downsample_by_size(i_size) o_cloud = df_cvt_bindings.cvt_dfcloud_2_rhcloud(df_cloud) diff --git a/src/gh/components/DF_cloud_uniform_downsample/code.py b/src/gh/components/DF_cloud_uniform_downsample/code.py index 0b07e5b1..ec0cfdc4 100644 --- a/src/gh/components/DF_cloud_uniform_downsample/code.py +++ b/src/gh/components/DF_cloud_uniform_downsample/code.py @@ -1,17 +1,14 @@ #! python3 -import Rhino.Geometry as rg +import Rhino from ghpythonlib.componentbase import executingcomponent as component from diffCheck import df_cvt_bindings class DFCloudUniformDownsample(component): - def RunScript(self, - i_cloud: rg.PointCloud, - i_every_k_points: int, - ) -> rg.PointCloud: + def RunScript(self, i_cloud: Rhino.Geometry.PointCloud, i_every_k_points: int) -> Rhino.Geometry.PointCloud: df_cloud = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud) df_cloud.uniform_downsample(i_every_k_points) o_cloud = df_cvt_bindings.cvt_dfcloud_2_rhcloud(df_cloud) diff --git a/src/gh/components/DF_cloud_voxel_downsample/code.py b/src/gh/components/DF_cloud_voxel_downsample/code.py index bd4b04c6..2544ba62 100644 --- a/src/gh/components/DF_cloud_voxel_downsample/code.py +++ b/src/gh/components/DF_cloud_voxel_downsample/code.py @@ -1,17 +1,14 @@ #! python3 -import Rhino.Geometry as rg +import Rhino from ghpythonlib.componentbase import executingcomponent as component from diffCheck import df_cvt_bindings class DFCloudVoxelDownsample(component): - def RunScript(self, - i_cloud: rg.PointCloud, - i_voxel_size: float, - ) -> rg.PointCloud: + def RunScript(self, i_cloud: Rhino.Geometry.PointCloud, i_voxel_size: float) -> Rhino.Geometry.PointCloud: df_cloud = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud) df_cloud.voxel_downsample(i_voxel_size) o_cloud = df_cvt_bindings.cvt_dfcloud_2_rhcloud(df_cloud) diff --git a/src/gh/components/DF_csv_exporter/metadata.json b/src/gh/components/DF_csv_exporter/metadata.json index cd4fe62c..c3ec7e9d 100644 --- a/src/gh/components/DF_csv_exporter/metadata.json +++ b/src/gh/components/DF_csv_exporter/metadata.json @@ -51,7 +51,7 @@ }, { "name": "i_export_seperate_files", - "nickname": "i_export_seperate_file", + "nickname": "i_export_seperate_files", "description": "Whether to export one single file or seperate files per element.", "optional": true, "allowTreeAccess": true, diff --git a/src/gh/components/DF_deconstruct_beam/code.py b/src/gh/components/DF_deconstruct_beam/code.py index d714dde6..407a2b1b 100644 --- a/src/gh/components/DF_deconstruct_beam/code.py +++ b/src/gh/components/DF_deconstruct_beam/code.py @@ -1,16 +1,12 @@ #! python3 -import typing - +import System from ghpythonlib.componentbase import executingcomponent as component -from diffCheck.df_geometries import DFBeam - class DFDeconstructBeam(component): - def RunScript(self, - i_beams : typing.List[DFBeam]): + def RunScript(self, i_beams: System.Collections.Generic.List[object]): o_side_faces, o_joint_faces, o_joint_ids = [], [], [] for i_b in i_beams: diff --git a/src/gh/components/DF_fast_global_registration/code.py b/src/gh/components/DF_fast_global_registration/code.py index c2dab7ed..79c990fb 100644 --- a/src/gh/components/DF_fast_global_registration/code.py +++ b/src/gh/components/DF_fast_global_registration/code.py @@ -1,7 +1,7 @@ #! python3 -import Rhino.Geometry as rg +import Rhino from ghpythonlib.componentbase import executingcomponent as component from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML @@ -12,15 +12,13 @@ class DFFastGlobalRegistration(component): def RunScript(self, - i_cloud_source: rg.PointCloud, - i_cloud_target: rg.PointCloud, - i_radius_kd_search: float, - i_neighbours_kd_search: int, - i_max_corrspondence_dist: float, - i_iteration_number: int, - i_max_tuple_count: int - ) -> rg.Transform: - # preliminary checks + i_cloud_source: Rhino.Geometry.PointCloud, + i_cloud_target: Rhino.Geometry.PointCloud, + i_radius_kd_search: float, + i_neighbours_kd_search: int, + i_max_corrspondence_dist: float, + i_iteration_number: int, + i_max_tuple_count: int) -> Rhino.Geometry.Transform: if i_cloud_source is None or i_cloud_target is None: ghenv.Component.AddRuntimeMessage(RML.Warning, "Please provide both objects of type point clouds to align") # noqa: F821 return None @@ -60,11 +58,11 @@ def RunScript(self, # cvt df xform to rhino xform df_xform_matrix = df_xform.transformation_matrix - rh_form = rg.Transform() + rh_form = Rhino.Geometry.Transform() for i in range(4): for j in range(4): rh_form[i, j] = df_xform_matrix[i, j] - if rh_form == rg.Transform.Identity: + if rh_form == Rhino.Geometry.Transform.Identity: ghenv.Component.AddRuntimeMessage(RML.Warning, "The transformation matrix is identity, no transformation is applied") # noqa: F821 return None diff --git a/src/gh/components/DF_icp_registration/code.py b/src/gh/components/DF_icp_registration/code.py index 09043e75..b196572e 100644 --- a/src/gh/components/DF_icp_registration/code.py +++ b/src/gh/components/DF_icp_registration/code.py @@ -1,7 +1,7 @@ #! python3 -import Rhino.Geometry as rg +import Rhino from ghpythonlib.componentbase import executingcomponent as component from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML @@ -12,18 +12,13 @@ class DFICPRegistration(component): def RunScript(self, - i_cloud_source: rg.PointCloud, - i_cloud_target: rg.PointCloud, - - i_use_generalized_icp: bool, - - i_max_corrspondence_dist: float, - i_max_iteration: int, - - is_t_estimate_pt2pt: bool, # valid only for 03dicp - i_use_point_to_plane: bool # valid only for 03dicp - ) -> rg.Transform: - # preliminary checks + i_use_generalized_icp: bool, + i_cloud_source: Rhino.Geometry.PointCloud, + i_cloud_target: Rhino.Geometry.PointCloud, + i_max_corrspondence_dist: float, + i_max_iteration: int, + is_t_estimate_pt2pt: bool, + i_use_point_to_plane: bool) -> Rhino.Geometry.Transform: if i_cloud_source is None or i_cloud_target is None: ghenv.Component.AddRuntimeMessage(RML.Warning, "Please provide both objects of type point clouds to align") # noqa: F821 return None @@ -75,11 +70,11 @@ def RunScript(self, # cvt df xform to rhino xform df_xform_matrix = df_xform.transformation_matrix - rh_form = rg.Transform() + rh_form = Rhino.Geometry.Transform() for i in range(4): for j in range(4): rh_form[i, j] = df_xform_matrix[i, j] - if rh_form == rg.Transform.Identity: + if rh_form == Rhino.Geometry.Transform.Identity: ghenv.Component.AddRuntimeMessage(RML.Warning, "The transformation matrix is identity, no transformation is applied") # noqa: F821 return None diff --git a/src/gh/components/DF_joint_segmentator/code.py b/src/gh/components/DF_joint_segmentator/code.py index f7baf46a..c981706b 100644 --- a/src/gh/components/DF_joint_segmentator/code.py +++ b/src/gh/components/DF_joint_segmentator/code.py @@ -9,7 +9,7 @@ from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML from ghpythonlib.componentbase import executingcomponent as component -import typing +import System ABSTOL = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance @@ -17,7 +17,7 @@ class DFJointSegmentator(component): def __init__(self): super(DFJointSegmentator, self).__init__() def RunScript(self, - i_clusters: typing.List[Rhino.Geometry.PointCloud], + i_clusters: System.Collections.Generic.List[Rhino.Geometry.PointCloud], i_assembly: diffCheck.df_geometries.DFAssembly, i_angle_threshold: float, i_distance_threshold: float): diff --git a/src/gh/components/DF_mesh_to_cloud/code.py b/src/gh/components/DF_mesh_to_cloud/code.py index 1aa2cf47..f3087d84 100644 --- a/src/gh/components/DF_mesh_to_cloud/code.py +++ b/src/gh/components/DF_mesh_to_cloud/code.py @@ -12,15 +12,9 @@ class DFMeshToCloud(component): - def RunScript(self, - i_meshes:System.Collections.Generic.IList[Rhino.Geometry.Mesh], - i_points: int) -> Rhino.Geometry.PointCloud: - - if i_meshes is None: - return None - - if i_points is None: - i_points = 1000 + def RunScript(self, i_mesh: Rhino.Geometry.Mesh, i_points: int) -> Rhino.Geometry.PointCloud: + df_mesh = diffCheck.df_cvt_bindings.cvt_rhmesh_2_dfmesh(i_mesh) + df_cloud = df_mesh.sample_points_uniformly(i_points) rh_mesh = i_meshes[0] for i in range(1, len(i_meshes)): @@ -33,6 +27,8 @@ def RunScript(self, df_cloud = df_mesh.sample_points_uniformly(i_points) rgpoints = [Rhino.Geometry.Point3d(p[0], p[1], p[2]) for p in df_cloud.points] # convert the df_cloud to a rhino cloud + + rgpoints = [Rhino.Geometry.Point3d(pt[0], pt[1], pt[2]) for pt in df_cloud.points] rh_cloud = Rhino.Geometry.PointCloud(rgpoints) return [rh_cloud] diff --git a/src/gh/components/DF_normal_segmentator/code.py b/src/gh/components/DF_normal_segmentator/code.py index 9c096abf..a63c6dda 100644 --- a/src/gh/components/DF_normal_segmentator/code.py +++ b/src/gh/components/DF_normal_segmentator/code.py @@ -1,7 +1,7 @@ #! python3 -import Rhino.Geometry as rg +import Rhino from ghpythonlib.componentbase import executingcomponent as component @@ -12,13 +12,13 @@ class DFCloudNormalSegmentator(component): def RunScript(self, - i_cloud, + i_cloud: Rhino.Geometry.PointCloud, i_normal_threshold_degree=None, i_min_cluster_size=None, i_use_knn_neighborhood=None, i_knn_neighborhood_size=None, i_radius_neighborhood_size=None - ) -> rg.PointCloud: + ) -> Rhino.Geometry.PointCloud: o_clusters = [] df_cloud = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud) diff --git a/src/gh/components/DF_normal_segmentator/metadata.json b/src/gh/components/DF_normal_segmentator/metadata.json index da03f461..900ccf6b 100644 --- a/src/gh/components/DF_normal_segmentator/metadata.json +++ b/src/gh/components/DF_normal_segmentator/metadata.json @@ -88,8 +88,8 @@ ], "outputParameters": [ { - "name": "o_clusters", - "nickname": "o_clusters", + "name": "o_clouds", + "nickname": "o_clouds", "description": "The segmented clouds.", "optional": false, "sourceCount": 0, diff --git a/src/gh/components/DF_ransac_global_registration/code.py b/src/gh/components/DF_ransac_global_registration/code.py index bd8cdf78..58488da3 100644 --- a/src/gh/components/DF_ransac_global_registration/code.py +++ b/src/gh/components/DF_ransac_global_registration/code.py @@ -1,7 +1,7 @@ #! python3 -import Rhino.Geometry as rg +import Rhino from ghpythonlib.componentbase import executingcomponent as component from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML @@ -12,8 +12,8 @@ class DFRANSACGlobalRegistration(component): def RunScript(self, - i_cloud_source: rg.PointCloud, - i_cloud_target: rg.PointCloud, + i_cloud_source: Rhino.Geometry.PointCloud, + i_cloud_target: Rhino.Geometry.PointCloud, i_radius_kd_search: float, i_neighbours_kd_search: int, i_max_corrspondence_dist: float, @@ -23,8 +23,7 @@ def RunScript(self, i_similarity_threshold: float, i_max_iterations: int, i_confidence_threshold: float - ) -> rg.Transform: - # preliminary checks + ) -> Rhino.Geometry.Transform: if i_cloud_source is None or i_cloud_target is None: ghenv.Component.AddRuntimeMessage(RML.Warning, "Please provide both objects of type point clouds to align") # noqa: F821 return None @@ -78,11 +77,11 @@ def RunScript(self, # cvt df xform to rhino xform df_xform_matrix = df_xform.transformation_matrix - rh_form = rg.Transform() + rh_form = Rhino.Geometry.Transform() for i in range(4): for j in range(4): rh_form[i, j] = df_xform_matrix[i, j] - if rh_form == rg.Transform.Identity: + if rh_form == Rhino.Geometry.Transform.Identity: ghenv.Component.AddRuntimeMessage(RML.Warning, "The transformation matrix is identity, no transformation is applied") # noqa: F821 return None diff --git a/src/gh/components/DF_remove_beam/code.py b/src/gh/components/DF_remove_beam/code.py index c95a0418..8f914d5e 100644 --- a/src/gh/components/DF_remove_beam/code.py +++ b/src/gh/components/DF_remove_beam/code.py @@ -1,19 +1,14 @@ #! python3 -import typing +import System from ghpythonlib.componentbase import executingcomponent as component -import diffCheck -import diffCheck.df_geometries -import diffCheck.diffcheck_bindings -import diffCheck.df_util - class DFRemoveBeam(component): def RunScript(self, - i_assembly : diffCheck.df_geometries.DFAssembly=None, - i_idx_2_remove : typing.List[int]=None): + i_assembly, + i_idx_2_remove: System.Collections.Generic.List[int]): if i_assembly is None or i_idx_2_remove is None: return None diff --git a/src/gh/components/DF_visualization_settings/code.py b/src/gh/components/DF_visualization_settings/code.py index a388bdd6..a8cb4352 100644 --- a/src/gh/components/DF_visualization_settings/code.py +++ b/src/gh/components/DF_visualization_settings/code.py @@ -3,7 +3,7 @@ import System import typing -import Rhino.Geometry as rg +import Rhino from ghpythonlib.componentbase import executingcomponent as component import Grasshopper as gh @@ -181,7 +181,7 @@ def RunScript(self, i_lower_threshold: float, i_legend_height: float, i_legend_width: float, - i_legend_plane: rg.Plane, + i_legend_plane: Rhino.Geometry.Plane, i_histogram_scale_factor: float): # set default values if i_value_type is not None: @@ -201,7 +201,7 @@ def RunScript(self, if i_legend_width is None: i_legend_width = 0.5 if i_legend_plane is None: - i_legend_plane = rg.Plane.WorldXY + i_legend_plane = Rhino.Geometry.Plane.WorldXY if i_histogram_scale_factor is None: i_histogram_scale_factor = 0.01