mirror of https://gitlab.com/pamhyr/pamhyr2
geometry: Fix profiles import.
parent
e4c07e0e3e
commit
8f183b7078
|
|
@ -15,6 +15,7 @@ class ProfileXYZ(Profile):
|
||||||
name: str = "",
|
name: str = "",
|
||||||
kp: float = 0.,
|
kp: float = 0.,
|
||||||
reach = None,
|
reach = None,
|
||||||
|
num = 0,
|
||||||
nb_point: int = 0,
|
nb_point: int = 0,
|
||||||
code1: int = 0, code2: int = 0):
|
code1: int = 0, code2: int = 0):
|
||||||
"""ProfileXYZ constructor
|
"""ProfileXYZ constructor
|
||||||
|
|
@ -30,7 +31,7 @@ class ProfileXYZ(Profile):
|
||||||
Nothing.
|
Nothing.
|
||||||
"""
|
"""
|
||||||
super(ProfileXYZ, self).__init__(
|
super(ProfileXYZ, self).__init__(
|
||||||
num = 0,
|
num = num,
|
||||||
name = name,
|
name = name,
|
||||||
kp = kp,
|
kp = kp,
|
||||||
code1 = code1, code2 = code2,
|
code1 = code1, code2 = code2,
|
||||||
|
|
|
||||||
|
|
@ -324,6 +324,7 @@ class Reach:
|
||||||
|
|
||||||
# Import/Export
|
# Import/Export
|
||||||
|
|
||||||
|
@timer
|
||||||
def import_geometry(self, file_path_name: str):
|
def import_geometry(self, file_path_name: str):
|
||||||
"""Import a geometry from file (.ST or .st)
|
"""Import a geometry from file (.ST or .st)
|
||||||
|
|
||||||
|
|
@ -338,10 +339,15 @@ class Reach:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
list_profile, list_header = self.read_file_st(str(file_path_name))
|
list_profile, list_header = self.read_file_st(str(file_path_name))
|
||||||
|
profile_header = ["num", "code1", "code2", "nb_point", "kp", "name"]
|
||||||
|
|
||||||
if list_profile and list_header:
|
if list_profile and list_header:
|
||||||
for ind, profile in enumerate(list_profile):
|
for ind, profile in enumerate(list_profile):
|
||||||
prof = ProfileXYZ(*list_header[ind], reach=self)
|
d = {}
|
||||||
|
for i, data in enumerate(list_header[ind]):
|
||||||
|
d[profile_header[i]] = data
|
||||||
|
|
||||||
|
prof = ProfileXYZ(**d, reach=self)
|
||||||
prof.import_points(profile)
|
prof.import_points(profile)
|
||||||
self._profiles.append(prof)
|
self._profiles.append(prof)
|
||||||
self._update_profile_numbers()
|
self._update_profile_numbers()
|
||||||
|
|
@ -353,6 +359,7 @@ class Reach:
|
||||||
print(e)
|
print(e)
|
||||||
e.alert()
|
e.alert()
|
||||||
|
|
||||||
|
@timer
|
||||||
def read_file_st(self, filename):
|
def read_file_st(self, filename):
|
||||||
"""Read the ST file
|
"""Read the ST file
|
||||||
|
|
||||||
|
|
@ -378,7 +385,6 @@ class Reach:
|
||||||
line.append("")
|
line.append("")
|
||||||
list_header.append(line)
|
list_header.append(line)
|
||||||
else:
|
else:
|
||||||
print(f"Point {line} invalide ==> pas pris en compte")
|
|
||||||
line_is_header = False
|
line_is_header = False
|
||||||
else:
|
else:
|
||||||
# Read until "999.9990 999.9990" as found
|
# Read until "999.9990 999.9990" as found
|
||||||
|
|
@ -402,10 +408,6 @@ class Reach:
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# if list_profile and list_header:
|
|
||||||
# raise FileFormatError(filename, f"{list_profile}, {list_header}")
|
|
||||||
|
|
||||||
print("****** Fichier {} lu et traité en {} secondes *******".format(filename, time() - t0))
|
|
||||||
return list_profile, list_header
|
return list_profile, list_header
|
||||||
|
|
||||||
# TODO: Move this function to model reach
|
# TODO: Move this function to model reach
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue