diff --git a/src/gh/diffCheck/diffCheck/df_geometries.py b/src/gh/diffCheck/diffCheck/df_geometries.py index 821a0849..6fba22ad 100644 --- a/src/gh/diffCheck/diffCheck/df_geometries.py +++ b/src/gh/diffCheck/diffCheck/df_geometries.py @@ -101,6 +101,7 @@ def __post_init__(self): self._center: DFVertex = None # the normal of the face self._normal: typing.List[float] = None + self._area: float = None def __getstate__(self): state = self.__dict__.copy() @@ -261,6 +262,12 @@ def normal(self): self._normal = [normal_rg.X, normal_rg.Y, normal_rg.Z] return self._normal + @property + def area(self): + if self._area is None: + self._area = self.to_brep_face().ToBrep().GetArea() + return self._area + @dataclass class DFJoint: """ @@ -506,6 +513,27 @@ def compute_axis(self, is_unitized: bool = True) -> rg.Line: return axis_ln + def compute_plane(self) -> rg.Plane: + """ + This function computes the plane of the beam based on its axis and the first joint's center. + The plane is oriented along the beam's axis. + + :return plane: The plane of the beam + """ + if not self.joints: + raise ValueError("The beam has no joints to compute a plane") + + #main axis as defined above + main_vector = self.compute_axis().Direction + + #secondary axis as normal to the largest face of the beam + largest_face = max(self.faces, key=lambda f: f.area) + secondary_axis = largest_face.normal + secondary_vector = rg.Vector3d(secondary_axis[0], secondary_axis[1], secondary_axis[2]) + origin = self.center + + return rg.Plane(origin, main_vector, secondary_vector) + def compute_joint_distances_to_midpoint(self) -> typing.List[float]: """ This function computes the distances from the center of the beam to each joint.