FEM: restult task panel, add automatic displacement factor

This commit is contained in:
Bernd Hahnebach
2019-03-15 21:06:45 +01:00
committed by Yorik van Havre
parent 5e86f6ae8a
commit 844ae7e92f
2 changed files with 30 additions and 3 deletions

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>446</width>
<height>696</height>
<height>768</height>
</rect>
</property>
<property name="windowTitle">
@@ -235,7 +235,7 @@
<bool>false</bool>
</property>
<property name="maximum">
<number>99999</number>
<number>1000000</number>
</property>
<property name="singleStep">
<number>10</number>
@@ -268,7 +268,7 @@
<bool>false</bool>
</property>
<property name="maximum">
<number>99999</number>
<number>1000000</number>
</property>
<property name="singleStep">
<number>10</number>

View File

@@ -158,6 +158,13 @@ class _TaskPanelFemResultShow:
self.restore_result_dialog()
else:
self.restore_initial_result_dialog()
# initialize scale factor for show displacement
scale_factor = get_displacement_scale_factor(self.result_obj)
self.form.sb_displacement_factor.setValue(scale_factor)
self.form.hsb_displacement_factor.setValue(scale_factor)
diggits_scale_factor = len(str(abs(int(scale_factor))))
new_max_factor = 10 ** diggits_scale_factor
self.form.sb_displacement_factor_max.setValue(new_max_factor)
def restore_result_dialog(self):
try:
@@ -507,3 +514,23 @@ def hide_parts_constraints():
if "Constraint" in acnstrmesh.TypeId:
acnstrmesh.ViewObject.Visibility = False
break
def get_displacement_scale_factor(res_obj):
node_items = res_obj.Mesh.FemMesh.Nodes.items()
displacements = res_obj.DisplacementVectors
x_max, y_max, z_max = map(max, zip(*displacements))
positions = [] # list of node vectors
for k, v in node_items:
positions.append(v)
p_x_max, p_y_max, p_z_max = map(max, zip(*positions))
p_x_min, p_y_min, p_z_min = map(min, zip(*positions))
x_span = abs(p_x_max - p_x_min)
y_span = abs(p_y_max - p_y_min)
z_span = abs(p_z_max - p_z_min)
span = max(x_span, y_span, z_span)
max_disp = max(x_max, y_max, z_max)
# FIXME - add max_allowed_disp to Preferences
max_allowed_disp = 0.01 * span
scale = max_allowed_disp / max_disp
return scale