Skip to content

Commit 7eb9f3a

Browse files
ADD: DF_joint_segmentation component
1 parent 03924e4 commit 7eb9f3a

File tree

1 file changed

+38
-0
lines changed
  • src/gh/components/DF_joint_segmentator

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import Rhino
2+
import diffCheck
3+
from diffCheck import diffcheck_bindings
4+
from diffCheck import df_cvt_bindings as df_cvt
5+
import diffCheck.df_util
6+
7+
def main(pointCloud, breps):
8+
df_scan = df_cvt.cvt_rhcloud_2_dfcloud(pointCloud)
9+
meshes = []
10+
for i in range(breps.BranchCount):
11+
brep_faces = breps.Branch(i)
12+
mesh_faces = []
13+
for brep_face in brep_faces:
14+
mesh_face = Rhino.Geometry.Mesh.CreateFromBrep(brep_face)[0]
15+
mesh_face.Faces.ConvertQuadsToTriangles()
16+
mesh_faces.append(df_cvt.cvt_rhmesh_2_dfmesh(mesh_face))
17+
meshes.append(mesh_faces)
18+
associated_segments = []
19+
20+
# normal segmentation
21+
segments = diffcheck_bindings.dfb_segmentation.DFSegmentation.segment_by_normal(df_scan, 2, 50, True, 20, 10, False)
22+
23+
# for visualisation purposes
24+
rh_segments = []
25+
for segment in segments:
26+
rh_segments.append(df_cvt.cvt_dfcloud_2_rhcloud(segment))
27+
28+
association_results = []
29+
# associate clusters to pieces
30+
for piece in meshes:
31+
associated_segments = diffcheck_bindings.dfb_segmentation.DFSegmentation.associate_clusters(piece, segments)
32+
diffcheck_bindings.dfb_segmentation.DFSegmentation.clean_unassociated_clusters(segments, associated_segments, piece)
33+
association_results.append(associated_segments)
34+
35+
return association_results
36+
37+
if __name__ == "__main__":
38+
a = main(pointCloud, breps)

0 commit comments

Comments
 (0)