An error occurred while loading the file. Please try again.
-
Grand Francois authored4c77a704
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from typing import List
from Model.Geometry.Profile import Profile
class ProfileXYZ(Profile):
def __init__(self, num: int = 0, code1: int = 0, code2: int = 0,
kp: float = 0., name: str = ""):
"""ProfileXYZ constructor
Args:
num: The number of this profile
code1: The interpolation code 1
code2: The interpolation code 2
nb_points: Number of points
kp: Kilometer point
name: The name of profile
Returns:
Nothing.
"""
super(ProfileXYZ, self).__init__(
num = num,
name = name
kp = kp,
)
self._code1 = int(code1)
self._code2 = int(code2)
self._nb_points = int(nb_points)
self._list_points: List[PointXYZ] = []
def __repr__(self):
df = pd.DataFrame(columns=["X", "Y", "Z", "Name"],
data=[[p.x, p.y, p.z, p.name] for p in self._list_points])
return f"\n{self.header}\n{df}"
@property
def code1(self):
"""
Returns:
Interpolation code 1.
"""
return self._code1
@code1.setter
def code1(self, value: int):
self._code1 = int(value)
@property
def code2(self):
"""
Returns:
Interpolation code 2.
"""
return self._code2
@code2.setter
def code2(self, value: int):
self._code2 = int(value)
@property
def nb_points(self):
return self._nb_points
@property
def header(self):
"""
Returns:
Profile header.
"""
return np.array([self._num, self._code1, self._code2, self._nb_points, self._kp, self._name])
def import_points(self, list_points: list):
"""Import a list of points to profile
Args:
list_points: Liste of PointXYZ
Returns:
Nothing.
"""
for point in list_points:
pt = PointXYZ(*point)
self._list_points.append(pt)
def get_point_i(self, index: int) -> PointXYZ:
"""Get point at index.
Args:
index: Index of point.
Returns:
The point.
"""
try:
return self._list_points[index]
except IndexError:
raise IndexError(f"Le profil a moins de {index} points !")
def add(self):
"""Add a new PointXYZ to profile.
Returns:
Nothing.
"""
point_xyz = PointXYZ(0., 0., 0.)
self._list_points.append(point_xyz)
def delete(self, index: int):
"""Delete the point at index
Args:
index: Index of point.
Returns:
Nothing.
"""
try:
self._list_points.pop(index)
except IndexError:
raise IndexError(f"Suppression échouée, l'indice {index} n'existe pas !")
def insert(self, index: int):
"""Insert a new profile at index.
Args:
index: The index of new profile.
Returns:
Nothing.
"""
profile = ProfileXYZ()
self._list_points.insert(index, profile)
def delete1(self, list_index: list):
"""Delete a list of points
Args:
list_index: Indexes list.
Returns:
Nothing.
"""
try:
if list_index:
indices = sorted(list(set(list_index)), reverse=True)
for idx in indices:
# if idx < len(self._list_profiles) :
try:
self._list_points.pop(idx)
except IndexError:
print("Liste vide, rien à supprimer !")
except TypeError:
if isinstance(list_index, int):
self._list_points.pop(list_index)
print(f"\nSuppression --> attention !!!!\nL'argument {list_index} doit être une liste!\n")
else:
raise TypeError(f"L'argument {list_index} fourni est de type incorrect")