mirror of https://gitlab.com/pamhyr/pamhyr2
purge + pep8
parent
5dcbc6b4e1
commit
f6e08f203c
|
|
@ -44,9 +44,9 @@ class InternalMeshing(AMeshingTool):
|
|||
return reach
|
||||
|
||||
if limites[0] > limites[1]:
|
||||
l = limites[1]
|
||||
lim = limites[1]
|
||||
limites[1] = limites[0]
|
||||
limites[0] = l
|
||||
limites[0] = lim
|
||||
elif limites[0] == limites[1]:
|
||||
return reach
|
||||
|
||||
|
|
@ -54,6 +54,8 @@ class InternalMeshing(AMeshingTool):
|
|||
self.interpolate_transversal_step(reach,
|
||||
limites,
|
||||
step)
|
||||
self.purge_aligned_points(reach)
|
||||
|
||||
return reach
|
||||
|
||||
def st_to_m(self, reach, limites):
|
||||
|
|
@ -110,11 +112,11 @@ class InternalMeshing(AMeshingTool):
|
|||
# calcul number of intermediate profiles
|
||||
np = []
|
||||
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:
|
||||
np[-1] = 0
|
||||
|
||||
|
||||
d = [] # ratios
|
||||
p = [] # new profiles
|
||||
ptr = int(limites[0])
|
||||
|
|
@ -122,23 +124,22 @@ class InternalMeshing(AMeshingTool):
|
|||
d = 1.0/float(np[i]+1)
|
||||
ptr0 = ptr
|
||||
for j in range(np[i]):
|
||||
#p = reach.profiles[ptr0].copy()
|
||||
p = reach.profiles[ptr0].copy()
|
||||
# RATIO entre les deux sections initiales
|
||||
dj = float(j+1)*d
|
||||
ptr += 1 # next profile, original
|
||||
for k in range(len(reach.profiles[ptr0].points)):
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
p.rk = reach.profiles[ptr0].rk + \
|
||||
dj*(reach.profiles[ptr].rk - \
|
||||
dj*(reach.profiles[ptr].rk -
|
||||
reach.profiles[ptr0].rk)
|
||||
p.name = f'interpol{p.rk}'
|
||||
reach.insert_profile(ptr, p)
|
||||
|
|
@ -324,3 +325,7 @@ class InternalMeshing(AMeshingTool):
|
|||
).dist_2d(reach.profiles[i].named_point(directrices[1]))
|
||||
reach.profiles[i].rk = reach.profiles[i+1].rk \
|
||||
- (sgn * (d1 + d2) / 2)
|
||||
|
||||
def purge_aligned_points(self, reach):
|
||||
for p in reach.profiles:
|
||||
p.purge_aligned_points()
|
||||
|
|
|
|||
|
|
@ -229,6 +229,18 @@ class PointXYZ(Point, SQLSubModel):
|
|||
s = (a + b + c) / 2
|
||||
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):
|
||||
p = PointXYZ(self.x,
|
||||
self.y,
|
||||
|
|
|
|||
|
|
@ -912,3 +912,16 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
p.insert_point(i, k.copy())
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ solver_long_name = {
|
|||
# "mage_fake7": "Mage fake v7",
|
||||
"adistswc": "Adis-TS_WC",
|
||||
# "rubarbe": "RubarBE",
|
||||
# "rubar3": "Rubar3",
|
||||
"rubar3": "Rubar3",
|
||||
}
|
||||
|
||||
solver_type_list = {
|
||||
|
|
@ -44,5 +44,5 @@ solver_type_list = {
|
|||
# "mage_fake7": MageFake7,
|
||||
"adistswc": AdisTSwc,
|
||||
# "rubarbe": RubarBE,
|
||||
# "rubar3": Rubar3,
|
||||
"rubar3": Rubar3,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue