Commit 8f183b70 authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

geometry: Fix profiles import.

Showing with 10 additions and 7 deletions
+10 -7
......@@ -15,6 +15,7 @@ class ProfileXYZ(Profile):
name: str = "",
kp: float = 0.,
reach = None,
num = 0,
nb_point: int = 0,
code1: int = 0, code2: int = 0):
"""ProfileXYZ constructor
......@@ -30,7 +31,7 @@ class ProfileXYZ(Profile):
Nothing.
"""
super(ProfileXYZ, self).__init__(
num = 0,
num = num,
name = name,
kp = kp,
code1 = code1, code2 = code2,
......
......@@ -324,6 +324,7 @@ class Reach:
# Import/Export
@timer
def import_geometry(self, file_path_name: str):
"""Import a geometry from file (.ST or .st)
......@@ -338,10 +339,15 @@ class Reach:
try:
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:
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)
self._profiles.append(prof)
self._update_profile_numbers()
......@@ -353,6 +359,7 @@ class Reach:
print(e)
e.alert()
@timer
def read_file_st(self, filename):
"""Read the ST file
......@@ -378,7 +385,6 @@ class Reach:
line.append("")
list_header.append(line)
else:
print(f"Point {line} invalide ==> pas pris en compte")
line_is_header = False
else:
# Read until "999.9990 999.9990" as found
......@@ -402,10 +408,6 @@ class Reach:
else:
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
# TODO: Move this function to model reach
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment