Skip to content

Commit 2181ad9

Browse files
feat: add plane property to DFBeam
1 parent 3828e8e commit 2181ad9

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/gh/diffCheck/diffCheck/df_geometries.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def __post_init__(self):
101101
self._center: DFVertex = None
102102
# the normal of the face
103103
self._normal: typing.List[float] = None
104+
self._area: float = None
104105

105106
def __getstate__(self):
106107
state = self.__dict__.copy()
@@ -261,6 +262,12 @@ def normal(self):
261262
self._normal = [normal_rg.X, normal_rg.Y, normal_rg.Z]
262263
return self._normal
263264

265+
@property
266+
def area(self):
267+
if self._area is None:
268+
self._area = self.to_brep_face().ToBrep().GetArea()
269+
return self._area
270+
264271
@dataclass
265272
class DFJoint:
266273
"""
@@ -506,6 +513,27 @@ def compute_axis(self, is_unitized: bool = True) -> rg.Line:
506513

507514
return axis_ln
508515

516+
def compute_plane(self) -> rg.Plane:
517+
"""
518+
This function computes the plane of the beam based on its axis and the first joint's center.
519+
The plane is oriented along the beam's axis.
520+
521+
:return plane: The plane of the beam
522+
"""
523+
if not self.joints:
524+
raise ValueError("The beam has no joints to compute a plane")
525+
526+
#main axis as defined above
527+
main_vector = self.compute_axis().Direction
528+
529+
#secondary axis as normal to the largest face of the beam
530+
largest_face = max(self.faces, key=lambda f: f.area)
531+
secondary_axis = largest_face.normal
532+
secondary_vector = rg.Vector3d(secondary_axis[0], secondary_axis[1], secondary_axis[2])
533+
origin = self.center
534+
535+
return rg.Plane(origin, main_vector, secondary_vector)
536+
509537
def compute_joint_distances_to_midpoint(self) -> typing.List[float]:
510538
"""
511539
This function computes the distances from the center of the beam to each joint.

0 commit comments

Comments
 (0)