mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
add purge
This commit is contained in:
1 parent
cc3649fcb8
commit
5164891928
2 files changed
+41
No files matched your search
@@ -530,3 +530,36 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
pt_right = self.point(self.number_points - 1)
|
||||
|
||||
return pt_left, pt_right
|
||||
|
||||
def purge(self, np_purge):
|
||||
"""
|
||||
Remove points to keep at most np_purge points.
|
||||
"""
|
||||
|
||||
if (self.nb_points <= np_purge): return
|
||||
|
||||
nb_named = 2 # we consider the first and last point as named
|
||||
area = [0.0]
|
||||
for i in range(1, self.nb_points-1):
|
||||
if self.point(i).point_is_named():
|
||||
area.append(9999999.999)
|
||||
nb_named += 1
|
||||
print(self.point(i).name.strip())
|
||||
else:
|
||||
area.append(PointXYZ.areatriangle3d(self.point(i-1),self.point(i),self.point(i+1)))
|
||||
area.append(0.0)
|
||||
print(area)
|
||||
|
||||
while (self.nb_points > max(np_purge, nb_named)):
|
||||
to_rm = np.argmin(area[1:self.nb_points-1])+1
|
||||
print('to rm = ', to_rm)
|
||||
self.delete_i([to_rm])
|
||||
area.pop(to_rm)
|
||||
for i in [to_rm-1, to_rm]:
|
||||
if (i == 0): continue
|
||||
if (i == self.nb_points - 1): continue
|
||||
if self.point(i).point_is_named():
|
||||
area[i] = 9999999.999
|
||||
else:
|
||||
area[i] = PointXYZ.areatriangle3d(self.point(i-1),self.point(i),self.point(i+1))
|
||||
#self._study.river.edges()[0].reach.profile(0).purge(5)
|
||||
Reference in new issue
Block a user