Skip to content

Commit 1dc468a

Browse files
committed
FIX: faster dfassembly preview
1 parent a888e99 commit 1dc468a

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

src/gh/components/DF_preview_assembly/code.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import System
44

5-
import typing
6-
75
import Rhino.Geometry as rg
86

97
from ghpythonlib.componentbase import executingcomponent as component
@@ -93,18 +91,7 @@ def DrawViewportWires(self, args):
9391
## DFBeams
9492
#######################################
9593
if len(self._dfassembly.beams) > 1:
96-
# beams' obb
97-
df_cloud = diffCheck.diffcheck_bindings.dfb_geometry.DFPointCloud()
98-
vertices_pt3d_rh : typing.List[rg.Point3d] = [vertex.to_rg_point3d() for vertex in beam.vertices]
99-
df_cloud.points = [np.array([vertex.X, vertex.Y, vertex.Z]).reshape(3, 1) for vertex in vertices_pt3d_rh]
100-
obb: rg.Brep = diffCheck.df_cvt_bindings.cvt_dfOBB_2_rhbrep(df_cloud.get_tight_bounding_box())
101-
# args.Display.DrawBrepWires(obb, System.Drawing.Color.Red) ## keep for debugging
102-
103-
# axis arrow
104-
obb_faces = obb.Faces
105-
obb_faces = sorted(obb_faces, key=lambda face: rg.AreaMassProperties.Compute(face).Area)
106-
obb_endfaces = obb_faces[:2]
107-
beam_axis = rg.Line(obb_endfaces[0].GetBoundingBox(True).Center, obb_endfaces[1].GetBoundingBox(True).Center)
94+
beam_axis = beam.axis
10895
extension_length = 0.5 * diffCheck.df_util.get_doc_2_meters_unitf()
10996
beam_axis.Extend(extension_length, extension_length)
11097
args.Display.DrawArrow(beam_axis, System.Drawing.Color.Magenta)

src/gh/diffCheck/diffCheck/df_geometries.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def __setstate__(self, state: typing.Dict):
419419
if "_center" in state and state["_center"] is not None:
420420
state["_center"] = rg.Point3d.FromJSON(state["_center"])
421421
if "_axis" in state and state["_axis"] is not None:
422-
state["_axis"] = rg.Vector3d.FromJSON(state["_axis"])
422+
state["_axis"] = rg.Line.FromJSON(state["_axis"])
423423
self.__dict__.update(state)
424424

425425
def __repr__(self):
@@ -428,13 +428,12 @@ def __repr__(self):
428428
def deepcopy(self):
429429
return DFBeam(self.name, [face.deepcopy() for face in self.faces])
430430

431-
def compute_axis(self, is_unitized: bool = True) -> rg.Vector3d:
431+
def compute_axis(self, is_unitized: bool = True) -> rg.Line:
432432
"""
433-
This is an utility function that computes the axis of the beam.
433+
This is an utility function that computes the axis of the beam as a line.
434434
The axis is calculated as the vector passing through the two most distance joint's centroids.
435435
436-
:param is_unitized: If True, the beam's axis is unitized
437-
:return axis: The axis of the beam
436+
:return axis: The axis of the beam as a line
438437
"""
439438
joints = self.joints
440439
joint1 = joints[0]
@@ -451,15 +450,12 @@ def compute_axis(self, is_unitized: bool = True) -> rg.Vector3d:
451450
joint1 = j1
452451
joint2 = j2
453452

454-
axis = rg.Vector3d(
453+
axis_ln = rg.Line(
455454
joint1.center.to_rg_point3d(),
456455
joint2.center.to_rg_point3d()
457456
)
458457

459-
if is_unitized:
460-
axis.Unitize()
461-
462-
return axis
458+
return axis_ln
463459

464460
@classmethod
465461
def from_brep_face(cls, brep, is_roundwood=False):

0 commit comments

Comments
 (0)