Compare commits

..

No commits in common. "879c1515241220daf831d1b5e06c64181d0ab5d5" and "8aa0e25da23686349fe02578187dfeb09ac893b5" have entirely different histories.

2 changed files with 12 additions and 45 deletions

View File

@ -17,7 +17,7 @@
# -*- coding: utf-8 -*-
import logging
from numpy import sign, interp
from numpy import sign
from copy import deepcopy
from tools import logger_color_red, logger_color_reset, logger_exception
@ -273,7 +273,7 @@ class InternalMeshing(AMeshingTool):
sect2.point(start2+len2).name = tag2
sect2.modified()
def update_rk(self, reach, begin_rk, end_rk,
def update_rk(self, reach,
step: float = 50,
limites=[-1, -1],
origin=0,
@ -297,25 +297,15 @@ class InternalMeshing(AMeshingTool):
# 1: up -> downstream
# 2: down -> upstream
# else: keep current orientation
old_orientation = sign(reach.profiles[-1].rk - reach.profiles[0].rk)
if orientation == 1:
sgn = 1.0
elif orientation == 2:
sgn = -1.0
else:
sgn = old_orientation
sgn = sign(reach.profiles[-1].rk - reach.profiles[0].rk)
new_rk = [0.0]*nprof
new_rk[origin] = origin_value
frictions = reach._parent.frictions
old_begin_rk = list(map(lambda x: x * old_orientation,
begin_rk))
old_end_rk = list(map(lambda x: x * old_orientation,
end_rk))
old_rk = list(map(lambda x: x * old_orientation,
reach.get_rk()))
rk = [0.0]*nprof
rk[origin] = origin_value
if origin < nprof - 1:
for i in range(origin+1, nprof):
@ -326,7 +316,7 @@ class InternalMeshing(AMeshingTool):
d2 = reach.profiles[i-1].named_point(
directrices[1]
).dist_2d(reach.profiles[i].named_point(directrices[1]))
new_rk[i] = new_rk[i-1] + (sgn * (d1 + d2) / 2)
rk[i] = rk[i-1] + (sgn * (d1 + d2) / 2)
if origin > 0:
for i in reversed(range(0, origin)):
# 2D
@ -336,11 +326,6 @@ class InternalMeshing(AMeshingTool):
d2 = reach.profiles[i+1].named_point(
directrices[1]
).dist_2d(reach.profiles[i].named_point(directrices[1]))
new_rk[i] = new_rk[i+1] - (sgn * (d1 + d2) / 2)
rk[i] = rk[i+1] - (sgn * (d1 + d2) / 2)
new_begin_rk = interp(old_begin_rk, old_rk, new_rk)
new_end_rk = interp(old_end_rk, old_rk, new_rk)
if abs(sgn - old_orientation) > 0.1: # orientation changed
return new_rk, new_end_rk, new_begin_rk
else:
return new_rk, new_begin_rk, new_end_rk
return rk

View File

@ -237,40 +237,22 @@ class UpdateRKCommand(QUndoCommand):
self._data = data
self._mesher = mesher
self._rks = reach.get_rk()
self._frictions = [f for f in reach._parent.frictions.frictions
if f.is_full_defined()]
self._begin_rk = [f.begin_rk for f in self._frictions]
self._end_rk = [f.end_rk for f in self._frictions]
self._new_rks = None
self._new_begin_rk = None
self._new_end_rk = None
def undo(self):
for rk, profile in zip(self._rks, self._reach.profiles):
profile.rk = rk
for begin_rk, end_rk, friction in zip(self._begin_rk,
self._end_rk,
self._frictions):
friction.begin_rk = begin_rk
friction.end_rk = end_rk
def redo(self):
if self._new_rks is None:
self._new_rks, self._new_begin_rk, self._new_end_rk = \
self._mesher.update_rk(
self._reach, self._begin_rk, self._end_rk,
self._new_rks = self._mesher.update_rk(
self._reach,
**self._data
)
for rk, profile in zip(self._new_rks, self._reach.profiles):
profile.rk = rk
for begin_rk, end_rk, friction in zip(self._new_begin_rk,
self._new_end_rk,
self._frictions):
friction.begin_rk = begin_rk
friction.end_rk = end_rk
class MeshingCommand(QUndoCommand):