mirror of https://gitlab.com/pamhyr/pamhyr2
debug internal mesher
parent
97762756f8
commit
ceff5f3083
|
|
@ -40,20 +40,20 @@ class InternalMeshing(AMeshingTool):
|
||||||
step: float = 50,
|
step: float = 50,
|
||||||
limites=[-1, -1],
|
limites=[-1, -1],
|
||||||
linear: bool = True):
|
linear: bool = True):
|
||||||
if reach is None or len(reach.profiles) == 0:
|
|
||||||
return reach
|
|
||||||
|
|
||||||
if limites[0] > limites[1]:
|
# pre process
|
||||||
lim = limites[1]
|
|
||||||
limites[1] = limites[0]
|
|
||||||
limites[0] = lim
|
|
||||||
elif limites[0] == limites[1]:
|
|
||||||
return reach
|
|
||||||
|
|
||||||
# we never modify original profiles, we work on copies
|
profiles = self.get_profiles(reach, limites)
|
||||||
m_profiles = self.st_to_m(reach, limites)
|
if profiles is None:
|
||||||
new_profiles = self.interpolate_transversal_step(m_profiles,
|
return []
|
||||||
step)
|
|
||||||
|
guide_list = self.get_guide_list(reach, profiles)
|
||||||
|
if guide_list is None:
|
||||||
|
return []
|
||||||
|
|
||||||
|
# we never modify original profiles, we work on the copies
|
||||||
|
m_profiles = self.st_to_m(profiles, guide_list)
|
||||||
|
new_profiles = self.interpolate_transversal_step(m_profiles, step)
|
||||||
|
|
||||||
for new_profiles2 in new_profiles:
|
for new_profiles2 in new_profiles:
|
||||||
for p in new_profiles2:
|
for p in new_profiles2:
|
||||||
|
|
@ -61,19 +61,7 @@ class InternalMeshing(AMeshingTool):
|
||||||
|
|
||||||
return new_profiles
|
return new_profiles
|
||||||
|
|
||||||
def st_to_m(self, reach, limites):
|
def st_to_m(self, profiles, guide_list):
|
||||||
|
|
||||||
gl = reach.compute_guidelines()
|
|
||||||
profiles = [reach.profile(i).copy()
|
|
||||||
for i in range(limites[0], limites[1]+1)
|
|
||||||
]
|
|
||||||
|
|
||||||
# we make sure that the lines are in the left-to-right order
|
|
||||||
guide_list = [
|
|
||||||
x.name
|
|
||||||
for x in profiles[0].named_points()
|
|
||||||
if x.name in gl[0]
|
|
||||||
]
|
|
||||||
|
|
||||||
gl1 = [""] + guide_list
|
gl1 = [""] + guide_list
|
||||||
gl2 = guide_list + [""]
|
gl2 = guide_list + [""]
|
||||||
|
|
@ -193,23 +181,25 @@ class InternalMeshing(AMeshingTool):
|
||||||
for i in range(len2):
|
for i in range(len2):
|
||||||
ltot2 += sect2.point(start2+i).dist(sect2.point(start2+i+1))
|
ltot2 += sect2.point(start2+i).dist(sect2.point(start2+i+1))
|
||||||
beta.append(ltot2)
|
beta.append(ltot2)
|
||||||
beta = list(map(lambda x: x/ltot2, beta)) # current ratios
|
|
||||||
for i in range(len1 - len2):
|
|
||||||
beta.append(1.0)
|
|
||||||
beta.append(0.0) # beta[-1]
|
|
||||||
if len2 < 1 or ltot2 < 0.0001:
|
if len2 < 1 or ltot2 < 0.0001:
|
||||||
# unique point (copy len1 times)
|
# unique point (copy len1 times)
|
||||||
# we are at an edge of the profile
|
# we are at an edge of the profile
|
||||||
for i in range(len1-len2):
|
for i in range(len1-len2):
|
||||||
p = sect2.point(start2).copy()
|
p = sect2.point(start2).copy()
|
||||||
sect2.insert_point(start2, p)
|
sect2.insert_point(start2, p)
|
||||||
|
len2 += 1
|
||||||
if tag1 == '': # left end point
|
if tag1 == '': # left end point
|
||||||
sect2.point(start2).name = ''
|
sect2.point(start2).name = ''
|
||||||
if tag2 == '': # left end point
|
if tag2 == '': # left end point
|
||||||
sect2.point(start2+1).name = ''
|
sect2.point(start2+1).name = ''
|
||||||
elif ltot1 < 0.0001:
|
elif ltot1 < 0.0001:
|
||||||
sect2.add_npoints(len1-len2)
|
sect2.add_npoints(len1-len2)
|
||||||
|
len2 = len1
|
||||||
else: # regular case
|
else: # regular case
|
||||||
|
beta = list(map(lambda x: x/ltot2, beta)) # current ratios
|
||||||
|
for i in range(len1 - len2):
|
||||||
|
beta.append(1.0)
|
||||||
|
beta.append(0.0) # beta[-1]
|
||||||
# loop on the points to insert
|
# loop on the points to insert
|
||||||
for k in range(len1-len2):
|
for k in range(len1-len2):
|
||||||
trouve = False
|
trouve = False
|
||||||
|
|
@ -343,3 +333,42 @@ class InternalMeshing(AMeshingTool):
|
||||||
return new_rk, new_end_rk, new_begin_rk
|
return new_rk, new_end_rk, new_begin_rk
|
||||||
else:
|
else:
|
||||||
return new_rk, new_begin_rk, new_end_rk
|
return new_rk, new_begin_rk, new_end_rk
|
||||||
|
|
||||||
|
def get_guide_list(self, reach, profiles):
|
||||||
|
|
||||||
|
gl = reach.compute_guidelines()
|
||||||
|
|
||||||
|
# we make sure that the lines are in the left-to-right order
|
||||||
|
guide_list = [
|
||||||
|
[
|
||||||
|
x.name
|
||||||
|
for x in p.named_points()
|
||||||
|
if x.name in gl[0]
|
||||||
|
]
|
||||||
|
for p in profiles]
|
||||||
|
|
||||||
|
# we make sure the lines never cross
|
||||||
|
for gl in guide_list:
|
||||||
|
for i in range(len(guide_list[0])):
|
||||||
|
if gl[i] != guide_list[0][i]:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return guide_list[0]
|
||||||
|
|
||||||
|
def get_profiles(self, reach, limites):
|
||||||
|
|
||||||
|
if reach is None or len(reach.profiles) == 0:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if limites[0] > limites[1]:
|
||||||
|
lim = limites[1]
|
||||||
|
limites[1] = limites[0]
|
||||||
|
limites[0] = lim
|
||||||
|
elif limites[0] == limites[1]:
|
||||||
|
return None
|
||||||
|
|
||||||
|
profiles = [reach.profile(i).copy()
|
||||||
|
for i in range(limites[0], limites[1]+1)
|
||||||
|
]
|
||||||
|
|
||||||
|
return profiles
|
||||||
|
|
|
||||||
|
|
@ -251,11 +251,23 @@ class GeometryReachTableModel(PamhyrTableModel):
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def meshing(self, mesher, data, tableView):
|
def meshing(self, mesher, data, tableView):
|
||||||
|
|
||||||
|
new_profiles = mesher.meshing(
|
||||||
|
self._data,
|
||||||
|
**data
|
||||||
|
)
|
||||||
|
|
||||||
|
if new_profiles is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
if len(new_profiles) == 0:
|
||||||
|
return
|
||||||
|
|
||||||
self.layoutAboutToBeChanged.emit()
|
self.layoutAboutToBeChanged.emit()
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
MeshingCommand(
|
MeshingCommand(
|
||||||
self._data, mesher, data, tableView
|
self._data, new_profiles, data, tableView
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -274,15 +274,14 @@ class UpdateRKCommand(QUndoCommand):
|
||||||
|
|
||||||
|
|
||||||
class MeshingCommand(QUndoCommand):
|
class MeshingCommand(QUndoCommand):
|
||||||
def __init__(self, reach, mesher, data, tableView):
|
def __init__(self, reach, new_profiles, data, tableView):
|
||||||
QUndoCommand.__init__(self)
|
QUndoCommand.__init__(self)
|
||||||
|
|
||||||
self._reach = reach
|
self._reach = reach
|
||||||
self._data = data
|
self._data = data
|
||||||
self._limites = data["limites"]
|
self._limites = data["limites"]
|
||||||
self._mesher = mesher
|
|
||||||
|
|
||||||
self._new_profiles = None
|
self._new_profiles = new_profiles
|
||||||
self._new_profiles_indexes = None
|
self._new_profiles_indexes = None
|
||||||
self._tableView = tableView
|
self._tableView = tableView
|
||||||
self._indexes = tableView.selectionModel().selection()
|
self._indexes = tableView.selectionModel().selection()
|
||||||
|
|
@ -308,12 +307,6 @@ class MeshingCommand(QUndoCommand):
|
||||||
)
|
)
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
if self._new_profiles is None:
|
|
||||||
self._new_profiles = self._mesher.meshing(
|
|
||||||
self._reach,
|
|
||||||
**self._data
|
|
||||||
)
|
|
||||||
|
|
||||||
if self._new_profiles_indexes is None:
|
if self._new_profiles_indexes is None:
|
||||||
k = self._limites[0]
|
k = self._limites[0]
|
||||||
self._new_profiles_indexes = []
|
self._new_profiles_indexes = []
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue