.
This commit is contained in:
parent
635d8e29e9
commit
377fb1422f
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,7 +1,6 @@
|
||||
/.idea
|
||||
/__pycache__/
|
||||
*ARCHIV*
|
||||
*BAK*
|
||||
*BACKUP*
|
||||
out
|
||||
cfg_inlay_PUTx.xlsx
|
||||
|
||||
47
BAK/241031_def.yml
Normal file
47
BAK/241031_def.yml
Normal file
@ -0,0 +1,47 @@
|
||||
general:
|
||||
yolovar: int
|
||||
initpic_name: puppy.png
|
||||
|
||||
groups:
|
||||
inlay:
|
||||
parameter:
|
||||
x_num: int
|
||||
x_offset: double
|
||||
y_num: int
|
||||
y_offset: double
|
||||
kos: str
|
||||
cfg:
|
||||
picture_name: img_inlay.png
|
||||
wp_raw:
|
||||
parameter:
|
||||
x_wpraw: double
|
||||
y_wpraw: double
|
||||
z_wpraw: double
|
||||
h_grp_wpraw: double
|
||||
cfg:
|
||||
picture_name: img_wpraw.png
|
||||
wp_fin:
|
||||
parameter:
|
||||
x_wpfin: double
|
||||
y_wpfin: double
|
||||
z_wpfin: double
|
||||
l_wpfin: double
|
||||
h_grp_wpfin: double
|
||||
cfg:
|
||||
picture_name: img_wpfin.png
|
||||
clp:
|
||||
parameter:
|
||||
clp_offset: double
|
||||
y_prb_floor1: double
|
||||
z_prb_floor1: double
|
||||
y_prb_floor2: double
|
||||
z_prb_floor2: double
|
||||
x_prb_backen: double
|
||||
z_prb_backen: double
|
||||
l_prb_backen: double
|
||||
y_prb_seite: double
|
||||
z_prb_seite: double
|
||||
|
||||
|
||||
cfg:
|
||||
picture_name: img_clp.png
|
||||
@ -1,12 +0,0 @@
|
||||
'2':
|
||||
kos: '4'
|
||||
x_num: '5'
|
||||
x_offset: '5'
|
||||
y_num: '5'
|
||||
y_offset: '5'
|
||||
inlay1:
|
||||
kos: '4'
|
||||
x_num: '6'
|
||||
x_offset: '120'
|
||||
y_num: '5'
|
||||
y_offset: '250'
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 91 KiB |
9
def.yml
9
def.yml
@ -5,11 +5,10 @@ general:
|
||||
groups:
|
||||
inlay:
|
||||
parameter:
|
||||
x_num: int
|
||||
x_offset: double
|
||||
y_num: int
|
||||
y_offset: double
|
||||
kos: str
|
||||
INL_X_NUM: int
|
||||
INL_X_OFFSET: double
|
||||
INL_Y_NUM: int
|
||||
INL_Y_OFFSET: double
|
||||
cfg:
|
||||
picture_name: img_inlay.png
|
||||
wp_raw:
|
||||
|
||||
@ -66,10 +66,10 @@ def generate_config_spf_custom1(folder_output, input_vars, selected_params, file
|
||||
xlsx_path = "cfg_inlay_PUTx.xlsx"
|
||||
|
||||
# Extract grid parameters
|
||||
x_num = int(input_vars['inlay']['x_num'].get()) # Number of columns
|
||||
y_num = int(input_vars['inlay']['y_num'].get()) # Number of rows
|
||||
x_offset = float(input_vars['inlay']['x_offset'].get()) # X offset
|
||||
y_offset = float(input_vars['inlay']['y_offset'].get()) # Y offset
|
||||
x_num = int(input_vars['inlay']['INL_X_NUM'].get()) # Number of columns
|
||||
y_num = int(input_vars['inlay']['INL_Y_NUM'].get()) # Number of rows
|
||||
x_offset = float(input_vars['inlay']['INL_X_OFFSET'].get()) # X offset
|
||||
y_offset = float(input_vars['inlay']['INL_Y_OFFSET'].get()) # Y offset
|
||||
|
||||
# Check if Excel file exists, if not create it with 'x' values
|
||||
if not os.path.exists(xlsx_path):
|
||||
|
||||
@ -4,49 +4,56 @@ import numpy as np
|
||||
def generate_picture_inlay(all_group_vars, picture_path, DEBUG=False):
|
||||
try:
|
||||
vars = all_group_vars['inlay']
|
||||
x_num, y_num = int(vars['x_num']), int(vars['y_num'])
|
||||
x_offset_mm, y_offset_mm = float(vars['x_offset']), float(vars['y_offset'])
|
||||
canvas_width_mm, canvas_height_mm = 800, 1200
|
||||
x_num, y_num = int(vars['INL_X_NUM']), int(vars['INL_Y_NUM'])
|
||||
x_offset_mm, y_offset_mm = float(vars['INL_X_OFFSET']), float(vars['INL_Y_OFFSET'])
|
||||
|
||||
if x_num <= 0 or y_num <= 0:
|
||||
raise ValueError("INL_X_NUM and INL_Y_NUM must be positive integers.")
|
||||
|
||||
|
||||
rect_realsize_factor = 0.90
|
||||
canvas_height_mm = x_num * x_offset_mm - x_offset_mm * (1-rect_realsize_factor)
|
||||
canvas_width_mm = y_num * y_offset_mm - y_offset_mm * (1-rect_realsize_factor)
|
||||
|
||||
x_offset = x_offset_mm / canvas_height_mm # Swapping due to axis swap
|
||||
y_offset = y_offset_mm / canvas_width_mm # Swapping due to axis swap
|
||||
|
||||
if x_num <= 0 or y_num <= 0:
|
||||
raise ValueError("x_num and y_num must be positive integers.")
|
||||
|
||||
x_wide = x_offset * rect_realsize_factor
|
||||
y_wide = y_offset * rect_realsize_factor
|
||||
|
||||
|
||||
fig, ax = plt.subplots(figsize=(12, 8))
|
||||
ax.set_facecolor('black')
|
||||
|
||||
total_x_offset = x_offset * (y_num + 1)
|
||||
total_y_offset = y_offset * (x_num + 1)
|
||||
rect_width = (1 - total_y_offset) / x_num
|
||||
rect_height = (1 - total_x_offset) / y_num
|
||||
|
||||
for j in range(x_num):
|
||||
for i in range(y_num):
|
||||
for xxx in range(x_num):
|
||||
for yyy in range(y_num):
|
||||
# Mirroring horizontally
|
||||
x_start = 1 - (y_offset + i * (rect_height + y_offset) + rect_height)
|
||||
y_start = x_offset + j * (rect_width + x_offset)
|
||||
x_start = xxx * x_offset
|
||||
y_start = ((yyy) * y_offset) # Corrected vertical mirroring
|
||||
|
||||
rect = plt.Rectangle((x_start, y_start), rect_height, rect_width, color='white')
|
||||
rect = plt.Rectangle((y_start, x_start), y_wide, x_wide, color='white')
|
||||
ax.add_patch(rect)
|
||||
|
||||
triangle_sizefactor = 0.2
|
||||
triangle = plt.Polygon([
|
||||
(x_start + rect_height, y_start), # Bottom right of the rectangle
|
||||
(x_start + rect_height - 0.05 * rect_height, y_start), # Left along the bottom
|
||||
(x_start + rect_height, y_start + 0.05 * rect_width) # Up from the bottom right
|
||||
(y_start+y_wide, x_start), # Bottom right of the rectangle
|
||||
(y_start+y_wide, x_start + triangle_sizefactor * y_wide), # Left along the bottom
|
||||
(y_start+y_wide - triangle_sizefactor * y_wide, x_start ) # Up from the bottom right
|
||||
], color='black')
|
||||
ax.add_patch(triangle)
|
||||
|
||||
# Arrows with adjusted margins
|
||||
ax.arrow(0.98, 0.02, -0.9, 0, head_width=0.03, head_length=0.02, fc='green', ec='green', linewidth=2, edgecolor='white')
|
||||
ax.arrow(0.98, 0.02, 0, 0.9, head_width=0.02, head_length=0.03, fc='red', ec='red', linewidth=2, edgecolor='white')
|
||||
ax.arrow(1.0, 0.0, -0.3, 0, head_width=0.03, head_length=0.02, fc='green', ec='green', linewidth=2, edgecolor='white')
|
||||
ax.arrow(1.0, 0.0, 0, 0.3, head_width=0.02, head_length=0.03, fc='red', ec='red', linewidth=2, edgecolor='white')
|
||||
|
||||
ax.set_xlim(0, 1)
|
||||
ax.set_ylim(0, 1)
|
||||
margin = 0.03
|
||||
ax.set_xlim(0-margin, 1+margin)
|
||||
ax.set_ylim(0-margin, 1+margin)
|
||||
ax.set_xticks([]), ax.set_yticks([])
|
||||
plt.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.1) # Adjusting the margins
|
||||
ax.set_xlim(1, 0) # Flipping the x-axis
|
||||
ax.set_ylim(1, 0) # Flipping the y-axis
|
||||
# plt.subplots_adjust(left=0.01, right=0.99, top=0.99, bottom=0.01) # Adjusting the margins
|
||||
# ax.set_xlim(1, 0) # Flipping the x-axis
|
||||
# ax.set_ylim(1, 0) # Flipping the y-axis
|
||||
|
||||
if DEBUG:
|
||||
plt.show()
|
||||
@ -60,6 +67,6 @@ def generate_picture_inlay(all_group_vars, picture_path, DEBUG=False):
|
||||
print(f"Error generating matrix: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
vars = {'x_num': 5, 'y_num': 3, 'x_offset': 20, 'y_offset': 20}
|
||||
vars = {'INL_X_NUM': 8, 'INL_Y_NUM': 12, 'INL_X_OFFSET': 100, 'INL_Y_OFFSET': 125}
|
||||
picture_path = "cfg_picture/TEST_inlay.jpg"
|
||||
generate_picture_inlay({'inlay': vars}, picture_path, DEBUG=True)
|
||||
|
||||
55
funct_wp.py
55
funct_wp.py
@ -3,6 +3,61 @@ from mpl_toolkits.mplot3d.art3d import Poly3DCollection
|
||||
import numpy as np
|
||||
|
||||
|
||||
def generate_picture_wp(all_group_vars, picture_path, DEBUG=False):
|
||||
try:
|
||||
# --- wpraw
|
||||
vars = all_group_vars['wp_raw']
|
||||
x, y, z = float(vars['x_wpraw']), float(vars['y_wpraw']), float(vars['z_wpraw'])
|
||||
if min(x, y, z) <= 0:
|
||||
raise ValueError("Dimensions must be positive.")
|
||||
|
||||
fig, ax = plt.subplots(subplot_kw={'projection': '3d'})
|
||||
x_cube, y_cube = 2 * x, 2 * y
|
||||
vertices = np.array([[0, 0, 0], [x_cube, 0, 0], [x_cube, y_cube, 0], [0, y_cube, 0],
|
||||
[0, 0, z], [x_cube, 0, z], [x_cube, y_cube, z], [0, y_cube, z]])
|
||||
faces = [vertices[[0, 1, 2, 3]], vertices[[4, 5, 6, 7]], vertices[[0, 3, 7, 4]],
|
||||
vertices[[1, 2, 6, 5]], vertices[[0, 1, 5, 4]], vertices[[2, 3, 7, 6]]]
|
||||
|
||||
ax.add_collection3d(Poly3DCollection(faces, facecolors='k', linewidths=1, edgecolors='k', alpha=.15))
|
||||
ax.set_box_aspect([x_cube, y_cube, z])
|
||||
ax.set_xticks([]);
|
||||
ax.set_yticks([]);
|
||||
ax.set_zticks([])
|
||||
ball_radius = min(x, y, z) * 0.1
|
||||
u, v = np.linspace(0, 2 * np.pi, 20), np.linspace(0, np.pi, 20)
|
||||
x_sphere = x + ball_radius * np.outer(np.cos(u), np.sin(v))
|
||||
y_sphere = y + ball_radius * np.outer(np.sin(u), np.sin(v))
|
||||
z_sphere = z + ball_radius * np.outer(np.ones_like(u), np.cos(v))
|
||||
ax.plot_surface(x_sphere, y_sphere, z_sphere, color='r', alpha=1)
|
||||
|
||||
max_size = max(x_cube, y_cube, z) * 0.3
|
||||
ax.quiver(0, 0, 0, max_size, 0, 0, color='r', linewidth=5)
|
||||
ax.quiver(0, 0, 0, 0, max_size, 0, color='g', linewidth=5)
|
||||
ax.quiver(0, 0, 0, 0, 0, max_size, color='b', linewidth=5)
|
||||
|
||||
block_depth = y * 0.4
|
||||
ax.bar3d(-max_size, (y_cube - block_depth) * 0.5, z * 0.8, max_size, block_depth, z * 0.8, color='k', alpha=.25)
|
||||
ax.bar3d(x_cube, (y_cube - block_depth) * 0.5, z * 0.8, max_size, block_depth, z * 0.8, color='k', alpha=.25)
|
||||
|
||||
|
||||
|
||||
ax.view_init(elev=18, azim=-130)
|
||||
ax.set_xlim([0, x_cube]); ax.set_ylim([0, y_cube]); ax.set_zlim([0, z])
|
||||
ax.set_aspect('auto')
|
||||
|
||||
if not DEBUG:
|
||||
fig.savefig(picture_path, bbox_inches='tight', dpi=300, transparent=True)
|
||||
else:
|
||||
plt.show()
|
||||
plt.close()
|
||||
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
|
||||
|
||||
|
||||
|
||||
# --------------- OLD ------------------------
|
||||
def generate_picture_wpraw(all_group_vars, picture_path, DEBUG=False):
|
||||
try:
|
||||
# --- wpraw
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user