purge + pep8

master
Theophile Terraz 2025-10-07 15:28:36 +02:00
parent 5dcbc6b4e1
commit f6e08f203c
5 changed files with 60 additions and 30 deletions

View File

@ -44,9 +44,9 @@ class InternalMeshing(AMeshingTool):
return reach return reach
if limites[0] > limites[1]: if limites[0] > limites[1]:
l = limites[1] lim = limites[1]
limites[1] = limites[0] limites[1] = limites[0]
limites[0] = l limites[0] = lim
elif limites[0] == limites[1]: elif limites[0] == limites[1]:
return reach return reach
@ -54,6 +54,8 @@ class InternalMeshing(AMeshingTool):
self.interpolate_transversal_step(reach, self.interpolate_transversal_step(reach,
limites, limites,
step) step)
self.purge_aligned_points(reach)
return reach return reach
def st_to_m(self, reach, limites): def st_to_m(self, reach, limites):
@ -110,11 +112,11 @@ class InternalMeshing(AMeshingTool):
# calcul number of intermediate profiles # calcul number of intermediate profiles
np = [] np = []
for i in range(limites[0], limites[1]): for i in range(limites[0], limites[1]):
np.append(int((reach.profiles[i+1].rk - reach.profiles[i].rk)/step) -1) np.append(int((reach.profiles[i+1].rk -
reach.profiles[i].rk) / step) - 1)
if np[-1] < 0: if np[-1] < 0:
np[-1] = 0 np[-1] = 0
d = [] # ratios d = [] # ratios
p = [] # new profiles p = [] # new profiles
ptr = int(limites[0]) ptr = int(limites[0])
@ -122,23 +124,22 @@ class InternalMeshing(AMeshingTool):
d = 1.0/float(np[i]+1) d = 1.0/float(np[i]+1)
ptr0 = ptr ptr0 = ptr
for j in range(np[i]): for j in range(np[i]):
#p = reach.profiles[ptr0].copy()
p = reach.profiles[ptr0].copy() p = reach.profiles[ptr0].copy()
# RATIO entre les deux sections initiales # RATIO entre les deux sections initiales
dj = float(j+1)*d dj = float(j+1)*d
ptr += 1 # next profile, original ptr += 1 # next profile, original
for k in range(len(reach.profiles[ptr0].points)): for k in range(len(reach.profiles[ptr0].points)):
p.points[k].x = reach.profiles[ptr0].points[k].x + \ p.points[k].x = reach.profiles[ptr0].points[k].x + \
dj*(reach.profiles[ptr].points[k].x - \ dj*(reach.profiles[ptr].points[k].x -
reach.profiles[ptr0].points[k].x) reach.profiles[ptr0].points[k].x)
p.points[k].y = reach.profiles[ptr0].points[k].y + \ p.points[k].y = reach.profiles[ptr0].points[k].y + \
dj*(reach.profiles[ptr].points[k].y - \ dj*(reach.profiles[ptr].points[k].y -
reach.profiles[ptr0].points[k].y) reach.profiles[ptr0].points[k].y)
p.points[k].z = reach.profiles[ptr0].points[k].z + \ p.points[k].z = reach.profiles[ptr0].points[k].z + \
dj*(reach.profiles[ptr].points[k].z - \ dj*(reach.profiles[ptr].points[k].z -
reach.profiles[ptr0].points[k].z) reach.profiles[ptr0].points[k].z)
p.rk = reach.profiles[ptr0].rk + \ p.rk = reach.profiles[ptr0].rk + \
dj*(reach.profiles[ptr].rk - \ dj*(reach.profiles[ptr].rk -
reach.profiles[ptr0].rk) reach.profiles[ptr0].rk)
p.name = f'interpol{p.rk}' p.name = f'interpol{p.rk}'
reach.insert_profile(ptr, p) reach.insert_profile(ptr, p)
@ -324,3 +325,7 @@ class InternalMeshing(AMeshingTool):
).dist_2d(reach.profiles[i].named_point(directrices[1])) ).dist_2d(reach.profiles[i].named_point(directrices[1]))
reach.profiles[i].rk = reach.profiles[i+1].rk \ reach.profiles[i].rk = reach.profiles[i+1].rk \
- (sgn * (d1 + d2) / 2) - (sgn * (d1 + d2) / 2)
def purge_aligned_points(self, reach):
for p in reach.profiles:
p.purge_aligned_points()

View File

@ -229,6 +229,18 @@ class PointXYZ(Point, SQLSubModel):
s = (a + b + c) / 2 s = (a + b + c) / 2
return (s*(s-a) * (s-b)*(s-c)) ** 0.5 return (s*(s-a) * (s-b)*(s-c)) ** 0.5
def dist_from_seg(self, p1, p2):
a2 = pow(PointXYZ.distance(self, p1), 2)
b2 = pow(PointXYZ.distance(self, p2), 2)
c2 = pow(PointXYZ.distance(p1, p2), 2)
if c2 < 0.00000001:
# si les deux points sont confondus
d = 0.0
else:
d = np.sqrt(abs(a2 - pow((c2 - b2 + a2) / (2*np.sqrt(c2)), 2)))
return d
def copy(self): def copy(self):
p = PointXYZ(self.x, p = PointXYZ(self.x,
self.y, self.y,

View File

@ -912,3 +912,16 @@ class ProfileXYZ(Profile, SQLSubModel):
p.insert_point(i, k.copy()) p.insert_point(i, k.copy())
return p return p
def purge_aligned_points(self):
align = True
while (align):
align = False
for i in range(1, self.number_points - 1):
d = self.point(i).dist_from_seg(self.point(i-1),
self.point(i+1))
if d < 0.00001 and self.point(i).name == "":
align = True
self.delete_i([i])
break

View File

@ -34,7 +34,7 @@ solver_long_name = {
# "mage_fake7": "Mage fake v7", # "mage_fake7": "Mage fake v7",
"adistswc": "Adis-TS_WC", "adistswc": "Adis-TS_WC",
# "rubarbe": "RubarBE", # "rubarbe": "RubarBE",
# "rubar3": "Rubar3", "rubar3": "Rubar3",
} }
solver_type_list = { solver_type_list = {
@ -44,5 +44,5 @@ solver_type_list = {
# "mage_fake7": MageFake7, # "mage_fake7": MageFake7,
"adistswc": AdisTSwc, "adistswc": AdisTSwc,
# "rubarbe": RubarBE, # "rubarbe": RubarBE,
# "rubar3": Rubar3, "rubar3": Rubar3,
} }