DFCloudNormalSegmentator
component#
Inputs:
|
The point cloud to reduce the size. |
|
The normal threshold in degrees (under that it consider to the same cluster). |
|
The smallest cluster allowed. |
|
If true use knn, otherwise radius search. |
|
The knn size. |
|
The size of the radius. |
Outputs:
o_clouds |
The segmented clouds. |
Code:
#! python3
import Rhino
from ghpythonlib.componentbase import executingcomponent as component
from diffCheck.diffcheck_bindings import dfb_segmentation
from diffCheck import df_cvt_bindings
class DFCloudNormalSegmentator(component):
def RunScript(self,
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
) -> Rhino.Geometry.PointCloud:
if i_cloud is None:
return None
o_clusters = []
df_cloud = df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cloud)
if i_normal_threshold_degree is None:
i_normal_threshold_degree = 20
if i_min_cluster_size is None:
i_min_cluster_size = 10
if i_use_knn_neighborhood is None:
i_use_knn_neighborhood = True
if i_knn_neighborhood_size is None:
i_knn_neighborhood_size = 30
if i_radius_neighborhood_size is None:
i_radius_neighborhood_size = 0.1
o_clusters = dfb_segmentation.DFSegmentation.segment_by_normal(
point_cloud=df_cloud,
normal_threshold_degree=i_normal_threshold_degree,
min_cluster_size=i_min_cluster_size,
use_knn_neighborhood=i_use_knn_neighborhood,
knn_neighborhood_size=i_knn_neighborhood_size,
radius_neighborhood_size=i_radius_neighborhood_size
)
return [df_cvt_bindings.cvt_dfcloud_2_rhcloud(cluster) for cluster in o_clusters]