@@ -198,6 +198,51 @@ def is_joint(self):
198198 def id (self ):
199199 return self .__id
200200
201+ @dataclass
202+ class DFJoint :
203+ """
204+ This class represents a joint, in diffCheck, a joint is a collection of faces
205+ For convenience, this is used only as a return type from the DFBeam class's property for retrieveing joints
206+ """
207+
208+ id : int
209+ faces : typing .List [DFFace ]
210+
211+ def __post_init__ (self ):
212+ self .id = self .id
213+ self .faces = self .faces or []
214+
215+ def __repr__ (self ):
216+ return f"Joint id: { self .id } , Faces: { len (self .faces )} "
217+
218+ def to_brep (self ):
219+ """
220+ Convert the joint to a Rhino Brep object
221+ """
222+ brep = rg .Brep ()
223+ for face in self .faces :
224+ brep .Append (face .to_brep_face ())
225+ brep .Compact ()
226+ return brep
227+
228+ def to_mesh (self , max_edge_length ):
229+ """
230+ Convert the joint to a Rhino Mesh object
231+ """
232+ rhino_brep_faces = [f .to_brep_face () for f in self .faces ]
233+ mesh = rg .Mesh ()
234+
235+ new_faces = [f .DuplicateFace (True ) for f in rhino_brep_faces ]
236+
237+ for f in new_faces :
238+ param = rg .MeshingParameters ()
239+ param .MaximumEdgeLength = max_edge_length
240+ mesh_part = rg .Mesh .CreateFromBrep (f , param )[0 ]
241+ mesh .Append (mesh_part )
242+
243+ mesh .Faces .ConvertQuadsToTriangles ()
244+ mesh .Compact ()
245+ return mesh
201246
202247@dataclass
203248class DFBeam :
@@ -214,6 +259,8 @@ def __post_init__(self):
214259 self ._joint_faces = []
215260 self ._side_faces = []
216261
262+ self ._joints = []
263+
217264 self .__id = uuid .uuid4 ().int
218265
219266 @classmethod
@@ -274,6 +321,18 @@ def joint_faces(self):
274321 def side_faces (self ):
275322 return [face for face in self .faces if not face .is_joint ]
276323
324+ @property
325+ def joints (self ):
326+ joints : typing .List [DFJoint ] = []
327+ temp_faces = self .joint_faces .copy ()
328+ while len (temp_faces ) > 0 :
329+ joint_id = temp_faces [0 ].joint_id
330+ joint_faces = [face for face in temp_faces if face .joint_id == joint_id ]
331+ joint = DFJoint (joint_id , joint_faces )
332+ joints .append (joint )
333+ temp_faces = [face for face in temp_faces if face .joint_id != joint_id ]
334+ return joints
335+
277336
278337@dataclass
279338class DFAssembly :
@@ -288,9 +347,11 @@ def __post_init__(self):
288347 self .beams = self .beams
289348 self .name = self .name or "Unnamed Assembly"
290349
291- self ._all_jointfaces = []
292- self ._all_sidefaces = []
350+ self ._all_jointfaces : typing . List [ DFFace ] = []
351+ self ._all_sidefaces : typing . List [ DFFace ] = []
293352
353+ self ._all_joints : typing .List [DFJoint ] = []
354+
294355 def __repr__ (self ):
295356 return f"Assembly: { self .name } , Beams: { len (self .beams )} "
296357
@@ -370,3 +431,9 @@ def all_side_faces(self):
370431 for beam in self .beams :
371432 self ._all_sidefaces .extend (beam .side_faces )
372433 return self ._all_sidefaces
434+
435+ @property
436+ def all_joints (self ):
437+ for beam in self .beams :
438+ self ._all_joints .extend (beam .joints )
439+ return self ._all_joints
0 commit comments