Skip to content

Commit ed64d49

Browse files
committed
FIX: the joint detector was not updated strange, now it's ok
1 parent 2f8e2b3 commit ed64d49

File tree

6 files changed

+55
-71
lines changed

6 files changed

+55
-71
lines changed

src/gh/components/DF_load_mesh_from_file/code.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ def RunScript(self,
4646
return rh_mesh
4747

4848

49-
# if __name__ == "__main__":
50-
# com = DFLoadMeshFromFile()
51-
# o_rh_mesh = com.RunScript(
52-
# i_path,n
53-
# i_scalef
54-
# )
49+
if __name__ == "__main__":
50+
com = DFLoadMeshFromFile()
51+
o_rh_mesh = com.RunScript(
52+
i_path,
53+
i_scalef
54+
)

src/gh/components/DF_xml_exporter/code.py

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,41 +25,48 @@ def RunScript(self,
2525
:param i_export_dir: directory to export the xml
2626
:param i_breps: list of breps
2727
"""
28-
# beams
29-
# beams: typing.List[DFBeam] = []
30-
# for brep in i_breps:
31-
# beam = DFBeam.from_brep(brep)
32-
# beams.append(beam)
33-
34-
# # assembly
35-
# assembly1 = DFAssembly(beams, i_assembly_name)
28+
o_xml = None
29+
o_joints = None
30+
o_sides = None
31+
o_debug = None
3632

37-
# # dump the xml
38-
# xml: str = assembly1.to_xml()
39-
# if i_dump:
40-
# assembly1.dump_xml(xml, i_export_dir)
41-
# o_xml = xml
42-
43-
# # show the joint/side faces
44-
# o_joints = [jf.to_brep() for jf in assembly1.all_joint_faces]
45-
# o_sides = [sf.to_brep() for sf in assembly1.all_side_faces]
33+
# beams
34+
beams: typing.List[DFBeam] = []
35+
for brep in i_breps:
36+
print(f"Processing brep {brep}")
37+
print(f"Type: {type(brep)}")
38+
beam = DFBeam.from_brep(brep)
39+
beams.append(beam)
40+
41+
# assembly
42+
assembly1 = DFAssembly(beams, i_assembly_name)
43+
44+
# dump the xml
45+
xml: str = assembly1.to_xml()
46+
if i_dump:
47+
assembly1.dump_xml(xml, i_export_dir)
48+
o_xml = xml
49+
50+
# show the joint/side faces
51+
o_joints = [jf.to_brep() for jf in assembly1.all_joint_faces]
52+
o_sides = [sf.to_brep() for sf in assembly1.all_side_faces]
4653

4754
###########################
4855

49-
faces, o_debug = diffCheck.df_joint_detector.JointDetector(i_breps[0]).run()
56+
# faces, o_debug = diffCheck.df_joint_detector.JointDetector(i_breps[0]).run()
5057

51-
# o_joints = [f.to_brep() for f in faces]
52-
# o_sides = [f.to_brep() for f in faces]
58+
# # o_joints = [f.to_brep() for f in faces]
59+
# # o_sides = [f.to_brep() for f in faces]
5360

54-
o_xml = ""
55-
o_joints = []
56-
o_sides = []
61+
# o_xml = ""
62+
# o_joints = []
63+
# o_sides = []
5764

58-
for f in faces:
59-
if f[1] != None:
60-
o_joints.append(f[0])
61-
else:
62-
o_sides.append(f[0])
65+
# for f in faces:
66+
# if f[1] != None:
67+
# o_joints.append(f[0])
68+
# else:
69+
# o_sides.append(f[0])
6370

6471

6572

Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.

src/gh/diffCheck/diffCheck/df_joint_detector.py

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
import Rhino
23
import scriptcontext as sc
34
import Rhino.Geometry as rg
@@ -10,8 +11,6 @@
1011

1112
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
1213

13-
# import numpy as np
14-
1514

1615
@dataclass
1716
class JointDetector:
@@ -31,29 +30,12 @@ def __post_init__(self):
3130
# list of DFFaces from joints and sides
3231
self._faces = []
3332

34-
# debug list of various geometries
35-
self._debug = []
36-
3733
def _compute_mass_center(self, b_face: rg.BrepFace) -> rg.Point3d:
3834
"""
39-
Compute the mass center of a brep face in 3d space
40-
35+
Compute the mass center of a brep face
4136
:param b_face: The brep face to compute the mass center from
4237
:return mass_center: The mass center of the brep face
4338
"""
44-
# vertices = b_face.DuplicateFace(False).DuplicateVertices()
45-
46-
# points_x = [v.X for v in vertices]
47-
# points_y = [v.Y for v in vertices]
48-
# points_z = [v.Z for v in vertices]
49-
# points_xyz = np.array([points_x, points_y, points_z])
50-
51-
52-
# centroid = np.mean(points_xyz, axis=1)
53-
54-
# return rg.Point3d(centroid[0], centroid[1], centroid[2])
55-
56-
5739
amp = rg.AreaMassProperties.Compute(b_face)
5840
if amp:
5941
return amp.Centroid
@@ -62,7 +44,6 @@ def _compute_mass_center(self, b_face: rg.BrepFace) -> rg.Point3d:
6244
def run(self) :
6345
"""
6446
Run the joint detector
65-
6647
:return: a list of faces from joins and faces
6748
"""
6849
############################################################################
@@ -104,6 +85,7 @@ def run(self) :
10485
if not f.IsPlanar():
10586
is_cut = False
10687
is_hole = True
88+
10789
b_faces = diffCheck.df_util.explode_brep(b)
10890
for b_face in b_faces:
10991
if b_face.Faces[0].IsPlanar():
@@ -129,7 +111,7 @@ def run(self) :
129111
is_hole = False
130112
is_cut = False
131113
is_mix = False
132-
114+
133115
# deal with mix
134116
candidate_cuts = []
135117
candidate_holes = []
@@ -152,10 +134,10 @@ def run(self) :
152134
flat_faces_b.append(f_b)
153135
else:
154136
non_flat_faces_b.append(f_b)
155-
137+
156138
# (*) cap the cylinders
157139
non_flat_faces_b = [f_b.CapPlanarHoles(sc.doc.ModelAbsoluteTolerance) for f_b in non_flat_faces_b]
158-
140+
159141
# (4) boolunion every object in both lists
160142
flat_faces_b = Rhino.Geometry.Brep.CreateBooleanUnion(flat_faces_b, sc.doc.ModelAbsoluteTolerance)
161143
non_flat_faces_b = Rhino.Geometry.Brep.CreateBooleanUnion(non_flat_faces_b, sc.doc.ModelAbsoluteTolerance)
@@ -184,17 +166,13 @@ def run(self) :
184166
# 3. Sort faces from joints and faces from sides
185167
############################################################################
186168
# retransform back everything
187-
# for b in self._holes:
188-
# b.Transform(x_form_back)
189-
# for b in self._cuts:
190-
# b.Transform(x_form_back)
191-
# for b in self._mix:
192-
# b.Transform(x_form_back)
193-
# self.brep.Transform(x_form_back)
194-
195-
# TODO: get rid debugging
196-
# bbox_b.Transform(x_form_back)
197-
self._debug.append(bbox_b)
169+
for b in self._holes:
170+
b.Transform(x_form_back)
171+
for b in self._cuts:
172+
b.Transform(x_form_back)
173+
for b in self._mix:
174+
b.Transform(x_form_back)
175+
self.brep.Transform(x_form_back)
198176

199177
# get all the medians of the faces of cuts only
200178
cuts_faces_centroids : typing.Dict[int, typing.List[rg.Point3d]] = {}
@@ -204,7 +182,6 @@ def run(self) :
204182
for f in b.Faces:
205183
centroid = self._compute_mass_center(f)
206184
temp_face_centroids.append(centroid)
207-
self._debug.append(centroid)
208185
cuts_faces_centroids[idx] = temp_face_centroids
209186

210187
# compare with the brep medians faces to get the joint/sides's faces
@@ -225,4 +202,4 @@ def run(self) :
225202
if self._faces is None or len(self._faces) == 0:
226203
ghenv.Component.AddRuntimeMessage(RML.Error, "No faces found after joint detection.")
227204

228-
return self._faces, self._debug
205+
return self._faces

0 commit comments

Comments
 (0)