Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions openglider/glider/parametric/table/cell/miniribs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
from openglider.glider.rib import MiniRib

from openglider.glider.parametric.table.base import CellTable
from openglider.vector.unit import Percentage
from openglider.vector.unit import Percentage, Length

class MiniRibDTO(DTO):
y_value: Percentage
front_cut: Percentage
back_cut: Percentage
trailing_edge_cut: Length | Percentage
material_code: str

def get_object(self) -> Any:
return MiniRib(yvalue=self.y_value.si, front_cut=self.front_cut.si, back_cut=self.back_cut.si, material_code=self.material_code)
return MiniRib(yvalue=self.y_value.si, front_cut=self.front_cut.si, back_cut=self.back_cut.si, trailing_edge_cut=self.trailing_edge_cut, material_code=self.material_code)

class MiniRibTable(CellTable):
dtos = {
Expand Down
38 changes: 25 additions & 13 deletions openglider/glider/rib/minirib.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from openglider.utils.dataclass import dataclass, Field

from openglider.mesh import Mesh, triangulate
from openglider.vector.unit import Length
from openglider.vector.unit import Length, Percentage

if TYPE_CHECKING:
from openglider.glider.cell import Cell
Expand All @@ -23,12 +23,15 @@ class MiniRib:
name: str="unnamed_minirib"
material_code: str="unnamed_material"
seam_allowance: Length = Length("10mm")
trailing_edge_cut: Length = Length("20mm")
mrib_num: int = 0
function: euklid.vector.Interpolation = Field(default_factory=lambda: euklid.vector.Interpolation([]))

class Config:
arbitrary_types_allowed = True

def __post_init__(self) -> None:

p1_x = 2/3

if self.function is None or len(self.function.nodes) == 0:
Expand Down Expand Up @@ -57,17 +60,24 @@ def get_multiplier(self, x: float) -> float:
return 1.

def get_profile_3d(self, cell: Cell) -> Profile3D:
shape_with_bal = cell.basic_cell.midrib(self.yvalue, True, arc_argument=True).curve.nodes
shape_wo_bal = cell.basic_cell.midrib(self.yvalue, False).curve.nodes

points: list[euklid.vector.Vector3D] = []
for xval, with_bal, without_bal in zip(
cell.x_values, shape_with_bal, shape_wo_bal):
factor = self.get_multiplier(xval) # factor ballooned/unb. (0-1)
point = without_bal + (with_bal - without_bal) * factor
points.append(point)

return Profile3D(curve=euklid.vector.PolyLine3D(points), x_values=cell.x_values)
return cell.rib_profiles_3d[self.mrib_num+1]



def convert_to_percentage(self, value: Percentage | Length, cell:Cell) -> Percentage:
if isinstance(value, Percentage):
return value
chord = cell.rib1.chord*(1-self.yvalue) + cell.rib2.chord*self.yvalue
return Percentage(value.si/chord)

def convert_to_chordlength(self, value: Percentage | Length, cell:Cell) -> Length:
if isinstance(value, Length):
return value

chord = cell.rib1.chord*(1-self.yvalue) + cell.rib2.chord*self.yvalue

return Length(value.si*chord)

def _get_lengths(self, cell: Cell) -> tuple[float, float]:
flattened_cell = cell.get_flattened_cell()
Expand All @@ -93,10 +103,12 @@ def get_nodes(self, cell: Cell) -> tuple[euklid.vector.PolyLine2D, euklid.vector
profile_2d = profile_3d.flatten()
contour = profile_2d.curve

cutback = self.convert_to_chordlength(self.trailing_edge_cut, cell).si

start_bottom = profile_2d.get_ik(self.front_cut*profile_2d.curve.nodes[0][0])
end_bottom = profile_2d.get_ik(profile_2d.curve.nodes[0][0])
end_bottom = profile_2d.get_ik(self.back_cut*profile_2d.curve.nodes[0][0]-cutback)
start_top = profile_2d.get_ik(-self.front_cut*profile_2d.curve.nodes[0][0])
end_top = profile_2d.get_ik(-profile_2d.curve.nodes[0][0])
end_top = profile_2d.get_ik(-self.back_cut*profile_2d.curve.nodes[0][0]+cutback)

nodes_top = contour.get(end_top, start_top)
nodes_bottom = contour.get(start_bottom, end_bottom)
Expand Down
34 changes: 19 additions & 15 deletions openglider/plots/glider/minirib.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ def get_point(self, x: float | Percentage, y: float=-1.) -> euklid.vector.Vector

p = profile.profilepoint(x, y)


print("...")
print(p)
print("...")

p_temp = list(p)

p_temp[0] = p_temp[0] * profile.curve.nodes[0][0]
Expand All @@ -80,9 +75,6 @@ def add_text(self, plotpart: PlotPart) -> None:
p1 = (p1+p2)/2
p2 = p1 +euklid.vector.Vector2D([0.02,-0.005])

print(p1)
print(p2)

_text = Text(self.minirib.name, p1, p2, size=0.01, align="center", valign=0)


Expand Down Expand Up @@ -116,21 +108,33 @@ def draw_outline(self) -> euklid.vector.PolyLine2D:
middle_top = front_cuts[0][0]
middle_bot = front_cuts[1][0]

buerzl = [
outer_minirib.get(stop),
outer_minirib.get(stop) + euklid.vector.Vector2D([t_e_allowance, 0]),
outer_minirib.get(start) + euklid.vector.Vector2D([t_e_allowance, 0]),
outer_minirib.get(start)
]


#no sewing allowance front
nosew = [
outer_minirib.get(middle_top),
outer_minirib.get(middle_bot)
]


if self.minirib.trailing_edge_cut > 0:
#no sewing allowance back
end = [
outer_minirib.get(stop),
outer_minirib.get(start)
]
else:
#sewing allowance back
end = [
outer_minirib.get(stop),
outer_minirib.get(stop) + euklid.vector.Vector2D([t_e_allowance, 0]),
outer_minirib.get(start) + euklid.vector.Vector2D([t_e_allowance, 0]),
outer_minirib.get(start)
]


contour = euklid.vector.PolyLine2D(
outer_minirib.get(start, middle_top).nodes + nosew + outer_minirib.get(middle_bot, stop).nodes + buerzl
outer_minirib.get(start, middle_top).nodes + nosew + outer_minirib.get(middle_bot, stop).nodes + end
)

return contour
Expand Down
Loading