diff --git a/src/Model/Geometry/ProfileXYZ.py b/src/Model/Geometry/ProfileXYZ.py index 5edff60dfc3b3aa8f43e65efeaf9f991b19f5f58..d32000755dd2a92a42b03098b49605bc78fb53cc 100644 --- a/src/Model/Geometry/ProfileXYZ.py +++ b/src/Model/Geometry/ProfileXYZ.py @@ -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, diff --git a/src/Model/Geometry/Reach.py b/src/Model/Geometry/Reach.py index afd6b23b1c241960e4377c99b29c7e82dad2639d..7c8ebcd5292ea9723c7fa495fae6a1c0afc08f0c 100644 --- a/src/Model/Geometry/Reach.py +++ b/src/Model/Geometry/Reach.py @@ -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