Refactor ChangeExtrusionXAngle to support obtuse x_angle for slabs.

To support obtuse x_angle a refactoring had to be made, which helped
improve the general code for slab addition. This is challenging because
there are a few features that interact with each other to create slabs,
like `depth`, `direction_sense`, `offset` and `x_angle`. In addition,
these interactions can happen in different parts of the code. This
commit addresses `ChangeExtrusionXAngle` in `model/wall.py`.
See e8e88c25fdcef55826443fe6b000aec1baa6f25a for more information.
This commit is contained in:
Bruno Perdigão
2025-02-28 11:46:02 -03:00
parent 1855ac421c
commit 0eb32ed7b7
2 changed files with 50 additions and 36 deletions
+5 -4
View File
@@ -304,16 +304,17 @@ class DumbSlabPlaner:
perpendicular_offset = layer_params["offset"] * abs(1 / cos(existing_x_angle)) / self.unit_scale
# Check angle and z direction to determine whether the extrusion direction is positive or negative
if (existing_x_angle < (pi / 2) and direction_ratios.z > 0) or (
existing_x_angle > (pi / 2) and direction_ratios.z < 0
if (abs(existing_x_angle) < (pi / 2) and direction_ratios.z > 0) or (
abs(existing_x_angle) > (pi / 2) and direction_ratios.z < 0
):
# The extrusion direction is positive. If the layer_parameter is set to negative,
# then the we change the extrusion direction.
# The offset direction must always be positive, so we keep it.
if layer_params["direction_sense"] == "NEGATIVE":
direction_ratios *= -1
elif (existing_x_angle > (pi / 2) and direction_ratios.z > 0) or (
existing_x_angle < (pi / 2) and direction_ratios.z < 0
# offset_direction *= -1
elif (abs(existing_x_angle )> (pi / 2) and direction_ratios.z > 0) or (
abs(existing_x_angle )< (pi / 2) and direction_ratios.z < 0
):
# The extrusion direction is negative. If the layer_parameter is set to positive,
# then the we change the extrusion direction.