Skip to content

Commit 7bd439b

Browse files
committed
set xcb plugin only on windows, some updates to export meshes
1 parent 256b00c commit 7bd439b

File tree

6 files changed

+91
-4
lines changed

6 files changed

+91
-4
lines changed

openglider/glider/ballooning/new.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ def __imul__(self, factor: float) -> BallooningBezierNeu: # TODO: Check consist
139139
self.scale(factor)
140140
self.apply_splines()
141141
return self
142+
143+
def close_trailing_edge(self, start_x: float) -> None:
144+
cp = self.controlpoints.nodes[:]
145+
cp[0][1] = 0
146+
cp[-1][1] = 0
147+
self.controlpoints = euklid.vector.PolyLine2D(cp)
148+
149+
return super().close_trailing_edge(start_x)
142150

143151
@property
144152
def controlpoints(self) -> euklid.vector.PolyLine2D:

openglider/glider/glider.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,33 @@ def get_mesh_hull(self, num_midribs: int=0, ballooning: bool=True) -> Mesh:
165165
ribs_flat = [p for rib in ribs for p in rib]
166166

167167
return Mesh.from_indexed(ribs_flat, {"hull": polygons}, boundary)
168+
169+
def get_mesh_all(self, numribs: int=10) -> Mesh:
170+
171+
mesh = Mesh()
172+
173+
for i, cell in enumerate(self.cells):
174+
cell_mesh = Mesh()
175+
for panel in cell.panels:
176+
cell_mesh += panel.get_mesh(cell, numribs=numribs)
177+
for strap in cell.straps:
178+
cell_mesh += strap.get_mesh(cell)
179+
for diagonal in cell.diagonals:
180+
cell_mesh += diagonal.get_mesh(cell)
181+
182+
if not (i == 0 and self.has_center_cell):
183+
cell_mesh += cell_mesh.copy().mirror("y")
184+
185+
mesh += cell_mesh
186+
187+
for i, rib in enumerate(self.ribs):
188+
rib_mesh = rib.get_mesh(hole_num=30, filled=True)
189+
if not (i == 0 and not self.has_center_cell):
190+
rib_mesh += rib_mesh.copy().mirror("y")
191+
192+
mesh += rib_mesh
193+
194+
return mesh
168195

169196
def return_ribs(self, num_midribs: int=0, ballooning: bool=True) -> list[list[euklid.vector.Vector3D]]:
170197
"""

openglider/glider/parametric/glider.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import copy
44
import logging
55
import math
6-
from typing import TYPE_CHECKING
6+
import random
7+
from typing import TYPE_CHECKING, Self
78
from collections.abc import Callable
89

910
import euklid
@@ -95,6 +96,55 @@ def get_geomentry_table(self) -> Table:
9596
table[1+rib_no, 10] = 0
9697

9798
return table
99+
100+
def randomize(self) -> ParametricGlider:
101+
new = self.copy()
102+
103+
def get_factor(spread: float) -> float:
104+
return 1 + 2 * spread * (-0.5 + random.random())
105+
106+
# change profiles
107+
for i, foil in enumerate(self.profiles):
108+
foil.set_camber(foil.camber * get_factor(0.1))
109+
foil.set_thickness(foil.thickness * get_factor(0.1))
110+
111+
def randomize_nodes(
112+
curve: euklid.vector.PolyLine2D,
113+
factor: float,
114+
change_first: tuple[bool, bool]=(False, True),
115+
change_last: tuple[bool, bool]=(False, True)) -> euklid.vector.PolyLine2D:
116+
assert len(curve) > 0
117+
new_curve = curve.nodes[:]
118+
119+
if change_first[0]:
120+
new_curve[0][0] *= get_factor(factor) # change x[0] for 2%
121+
if change_first[1]:
122+
new_curve[0][1] *= get_factor(factor) # change x[0] for 2%
123+
124+
for p in new_curve[1:-1]:
125+
p[0] *= get_factor(factor)
126+
p[1] *= get_factor(factor)
127+
128+
if change_last[0]:
129+
new_curve[-1][0] *= get_factor(factor) # change x[0] for 2%
130+
if change_last[1]:
131+
new_curve[-1][1] *= get_factor(factor) # change x[0] for 2%
132+
133+
return euklid.vector.PolyLine2D(new_curve)
134+
135+
136+
# change arc
137+
new.arc.curve.controlpoints = randomize_nodes(new.arc.curve.controlpoints, 0.02)
138+
139+
# change shape
140+
new.shape.front_curve.controlpoints = randomize_nodes(new.shape.front_curve.controlpoints, 0.02)
141+
new.shape.back_curve.controlpoints = randomize_nodes(new.shape.back_curve.controlpoints, 0.02)
142+
143+
new.shape.rib_dist_controlpoints = randomize_nodes(new.shape.rib_dist_controlpoints, 0.02, (True, True), (True, True)).nodes
144+
145+
new.aoa.controlpoints = randomize_nodes(new.aoa.controlpoints, 0.1, (False, True), (False, True))
146+
147+
return new
98148

99149
def get_arc_angles(self) -> list[float]:
100150
"""

openglider/glider/parametric/shape.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def rib_dist_controlpoints(self) -> euklid.vector.PolyLine2D:
102102
return euklid.vector.PolyLine2D(self.rib_distribution.controlpoints.nodes[1:-1])
103103

104104
@rib_dist_controlpoints.setter
105-
def rib_dist_controlpoints(self, arr: list[list[float]]) -> None:
105+
def rib_dist_controlpoints(self, arr: list[list[float]] | list[euklid.vector.Vector2D]) -> None:
106106

107107
self.rib_distribution.controlpoints = euklid.vector.PolyLine2D([[0., 0.]] + arr + [[1., 1.]])
108108

openglider/glider/rib/rib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def get_mesh(self, hole_num: int=10, filled: bool=False, max_area: float=None) -
240240
points = self.align_all(euklid.vector.PolyLine2D(mesh.points))
241241
boundaries = {self.name: list(range(len(mesh.points)))}
242242

243-
rib_mesh = Mesh.from_indexed(points.nodes, polygons={self.name: [(tri, {}) for tri in mesh.elements]} , boundaries=boundaries)
243+
rib_mesh = Mesh.from_indexed(points.nodes, polygons={f"ribs_{self.material}": [(tri, {}) for tri in mesh.elements]} , boundaries=boundaries)
244244

245245
for hole in self.holes:
246246
if hole_mesh := hole.get_mesh(self):

openglider/gui/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
os.environ["FORCE_QT_API"] = "pyside6"
66
os.environ["QT_API"] = "pyside6"
7-
os.environ["QT_QPA_PLATFORM"] = "xcb"
7+
8+
if sys.platform.startswith("linux"):
9+
os.environ["QT_QPA_PLATFORM"] = "xcb"
810

911

1012
def start_main_window() -> None:

0 commit comments

Comments
 (0)