wolfhece 2.2.32__py3-none-any.whl → 2.2.34__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wolfhece/PyConfig.py +26 -3
- wolfhece/PyDraw.py +329 -4
- wolfhece/PyGui.py +35 -1
- wolfhece/PyPictures.py +420 -3
- wolfhece/PyVertexvectors.py +153 -11
- wolfhece/Results2DGPU.py +10 -1
- wolfhece/apps/version.py +1 -1
- wolfhece/pydownloader.py +82 -0
- wolfhece/textpillow.py +1 -1
- wolfhece/wolf_texture.py +81 -13
- wolfhece/wolf_zi_db.py +586 -2
- {wolfhece-2.2.32.dist-info → wolfhece-2.2.34.dist-info}/METADATA +1 -1
- {wolfhece-2.2.32.dist-info → wolfhece-2.2.34.dist-info}/RECORD +16 -16
- {wolfhece-2.2.32.dist-info → wolfhece-2.2.34.dist-info}/WHEEL +0 -0
- {wolfhece-2.2.32.dist-info → wolfhece-2.2.34.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.2.32.dist-info → wolfhece-2.2.34.dist-info}/top_level.txt +0 -0
wolfhece/PyVertexvectors.py
CHANGED
@@ -705,10 +705,17 @@ class vectorproperties:
|
|
705
705
|
self.attachedimage = None
|
706
706
|
self.imagevisible = False
|
707
707
|
self.textureimage:genericImagetexture = None
|
708
|
+
self.image_scale = 1.0
|
709
|
+
self.image_relative_posx = 0.0
|
710
|
+
self.image_relative_posy = 0.0
|
711
|
+
self.image_attached_pointx = -99999.
|
712
|
+
self.image_attached_pointy = -99999.
|
708
713
|
|
709
714
|
self.plot_indices = False
|
710
715
|
|
711
|
-
|
716
|
+
self._cached_offset = None
|
717
|
+
|
718
|
+
def get_extra(self) -> list[float,float,int,float,str,bool, float, float, float, float, float]:
|
712
719
|
""" Return extra properties """
|
713
720
|
return [self.legendlength,
|
714
721
|
self.legendheight,
|
@@ -716,9 +723,15 @@ class vectorproperties:
|
|
716
723
|
self.legendorientation,
|
717
724
|
str(self.attachedimage),
|
718
725
|
self.imagevisible,
|
719
|
-
self.plot_indices
|
720
|
-
|
721
|
-
|
726
|
+
self.plot_indices,
|
727
|
+
self.image_scale,
|
728
|
+
self.image_relative_posx,
|
729
|
+
self.image_relative_posy,
|
730
|
+
self.image_attached_pointx,
|
731
|
+
self.image_attached_pointy
|
732
|
+
]
|
733
|
+
|
734
|
+
def set_extra(self, linesextra:list[float,float,int,float,str,bool, float, float, float, float, float] = None):
|
722
735
|
""" Set extra properties """
|
723
736
|
|
724
737
|
if linesextra is None:
|
@@ -728,7 +741,7 @@ class vectorproperties:
|
|
728
741
|
|
729
742
|
self.legendlength = float(linesextra[0])
|
730
743
|
self.legendheight = float(linesextra[1])
|
731
|
-
self.legendpriority =
|
744
|
+
self.legendpriority = int(linesextra[2])
|
732
745
|
self.legendorientation = float(linesextra[3])
|
733
746
|
|
734
747
|
if len(linesextra)>4:
|
@@ -738,6 +751,13 @@ class vectorproperties:
|
|
738
751
|
if len(linesextra)>6:
|
739
752
|
self.plot_indices = linesextra[6].lower() == 'true'
|
740
753
|
|
754
|
+
if len(linesextra)>7:
|
755
|
+
self.image_scale = float(linesextra[7])
|
756
|
+
self.image_relative_posx = float(linesextra[8])
|
757
|
+
self.image_relative_posy = float(linesextra[9])
|
758
|
+
self.image_attached_pointx = float(linesextra[10])
|
759
|
+
self.image_attached_pointy = float(linesextra[11])
|
760
|
+
|
741
761
|
def load_extra(self, lines:list[str]) -> int:
|
742
762
|
""" Load extra properties from lines """
|
743
763
|
|
@@ -802,6 +822,18 @@ class vectorproperties:
|
|
802
822
|
|
803
823
|
(xmin,xmax),(ymin,ymax) = self.parent.get_bounds_xx_yy()
|
804
824
|
|
825
|
+
if self.textureimage is not None:
|
826
|
+
if self.textureimage.imageFile == self.attachedimage:
|
827
|
+
self.textureimage.drawing_scale = self.image_scale
|
828
|
+
self.textureimage.offset = (self.image_relative_posx, self.image_relative_posy)
|
829
|
+
self.textureimage.xmin = xmin
|
830
|
+
self.textureimage.xmax = xmax
|
831
|
+
self.textureimage.ymin = ymin
|
832
|
+
self.textureimage.ymax = ymax
|
833
|
+
return
|
834
|
+
else:
|
835
|
+
self.textureimage.unload()
|
836
|
+
|
805
837
|
self.textureimage = genericImagetexture(which = 'attachedfile',
|
806
838
|
label=self.parent.myname,
|
807
839
|
mapviewer= self.parent.get_mapviewer(),
|
@@ -809,8 +841,9 @@ class vectorproperties:
|
|
809
841
|
xmin=xmin,
|
810
842
|
xmax=xmax,
|
811
843
|
ymin=ymin,
|
812
|
-
ymax=ymax
|
813
|
-
|
844
|
+
ymax=ymax,
|
845
|
+
drawing_scale= self.image_scale,
|
846
|
+
offset = (self.image_relative_posx, self.image_relative_posy))
|
814
847
|
else:
|
815
848
|
logging.warning('Image not found : {}'.format(self.attachedimage))
|
816
849
|
else:
|
@@ -865,6 +898,11 @@ class vectorproperties:
|
|
865
898
|
|
866
899
|
self.attachedimage = Path(props[('Image','Attached image')])
|
867
900
|
self.imagevisible = props[('Image','To show')]
|
901
|
+
self.image_scale = props[('Image','Scale')]
|
902
|
+
self.image_relative_posx = props[('Image','Relative position X')]
|
903
|
+
self.image_relative_posy = props[('Image','Relative position Y')]
|
904
|
+
self.image_attached_pointx = props[('Image','Attached point X')]
|
905
|
+
self.image_attached_pointy = props[('Image','Attached point Y')]
|
868
906
|
|
869
907
|
posx = props[('Move','Start X')]
|
870
908
|
posy = props[('Move','Start Y')]
|
@@ -1008,6 +1046,11 @@ if :\n \
|
|
1008
1046
|
|
1009
1047
|
self.myprops.addparam('Image','Attached image','',Type_Param.File, '', whichdict='Default')
|
1010
1048
|
self.myprops.addparam('Image','To show',False,Type_Param.Logical,'',whichdict='Default')
|
1049
|
+
self.myprops.addparam('Image','Scale',1.0,Type_Param.Float,'',whichdict='Default')
|
1050
|
+
self.myprops.addparam('Image','Relative position X',0.0,Type_Param.Float,'',whichdict='Default')
|
1051
|
+
self.myprops.addparam('Image','Relative position Y',0.0,Type_Param.Float,'',whichdict='Default')
|
1052
|
+
self.myprops.addparam('Image','Attached point X',-99999.,Type_Param.Float,'',whichdict='Default')
|
1053
|
+
self.myprops.addparam('Image','Attached point Y',-99999.,Type_Param.Float,'',whichdict='Default')
|
1011
1054
|
|
1012
1055
|
def destroyprop(self):
|
1013
1056
|
"""
|
@@ -1113,6 +1156,11 @@ if :\n \
|
|
1113
1156
|
|
1114
1157
|
self.myprops[('Image','Attached image')] = str(self.attachedimage)
|
1115
1158
|
self.myprops[('Image','To show')] = self.imagevisible
|
1159
|
+
self.myprops[('Image','Scale')] = self.image_scale
|
1160
|
+
self.myprops[('Image','Relative position X')] = self.image_relative_posx
|
1161
|
+
self.myprops[('Image','Relative position Y')] = self.image_relative_posy
|
1162
|
+
self.myprops[('Image','Attached point X')] = self.image_attached_pointx
|
1163
|
+
self.myprops[('Image','Attached point Y')] = self.image_attached_pointy
|
1116
1164
|
|
1117
1165
|
if self.parent._rotation_center is not None:
|
1118
1166
|
self.myprops[('Rotation','center X')] = self.parent._rotation_center[0]
|
@@ -1144,6 +1192,31 @@ if :\n \
|
|
1144
1192
|
self.myprops[('Move','Delta Y')] = 0.
|
1145
1193
|
|
1146
1194
|
self.myprops.Populate()
|
1195
|
+
|
1196
|
+
def update_image_texture(self):
|
1197
|
+
""" Update the image texture if it exists """
|
1198
|
+
if self.textureimage is not None:
|
1199
|
+
(xmin, xmax), (ymin, ymax) = self.parent.get_bounds_xx_yy()
|
1200
|
+
self.textureimage.xmin = xmin
|
1201
|
+
self.textureimage.xmax = xmax
|
1202
|
+
self.textureimage.ymin = ymin
|
1203
|
+
self.textureimage.ymax = ymax
|
1204
|
+
self.textureimage.drawing_scale = self.image_scale
|
1205
|
+
self.textureimage.offset = (self.image_relative_posx, self.image_relative_posy)
|
1206
|
+
|
1207
|
+
def _offset_image_texture(self, delta_x:float, delta_y:float):
|
1208
|
+
""" Offset the image texture by a delta in x and y direction """
|
1209
|
+
|
1210
|
+
if self._cached_offset is None:
|
1211
|
+
self._cached_offset = (self.image_relative_posx, self.image_relative_posy)
|
1212
|
+
|
1213
|
+
self.image_relative_posx = self._cached_offset[0] + delta_x
|
1214
|
+
self.image_relative_posy = self._cached_offset[1] + delta_y
|
1215
|
+
|
1216
|
+
def _reset_cached_offset(self):
|
1217
|
+
""" Reset the cached offset for the image texture """
|
1218
|
+
self._cached_offset = None
|
1219
|
+
|
1147
1220
|
class vector:
|
1148
1221
|
"""
|
1149
1222
|
Objet de gestion d'informations vectorielles
|
@@ -1419,11 +1492,13 @@ class vector:
|
|
1419
1492
|
""" Set the cache for the vertices """
|
1420
1493
|
|
1421
1494
|
self._cache_vertices = self.asnparray3d()
|
1495
|
+
self._cache_bounds = np.array([[self.xmin, self.xmax], [self.ymin, self.ymax]])
|
1422
1496
|
|
1423
1497
|
def clear_cache(self):
|
1424
1498
|
""" Clear the cache for the vertices """
|
1425
1499
|
|
1426
1500
|
self._cache_vertices = None
|
1501
|
+
self._cache_bounds = None
|
1427
1502
|
|
1428
1503
|
def move(self, deltax:float, deltay:float, use_cache:bool = True, inplace:bool = True):
|
1429
1504
|
"""
|
@@ -1445,10 +1520,26 @@ class vector:
|
|
1445
1520
|
|
1446
1521
|
if use_cache:
|
1447
1522
|
self.xy = self._cache_vertices[:,:2] + np.array([deltax, deltay])
|
1523
|
+
self.xmin = self._cache_bounds[0,0] + deltax
|
1524
|
+
self.xmax = self._cache_bounds[0,1] + deltax
|
1525
|
+
self.ymin = self._cache_bounds[1,0] + deltay
|
1526
|
+
self.ymax = self._cache_bounds[1,1] + deltay
|
1448
1527
|
else:
|
1449
1528
|
for curvert in self.myvertices:
|
1450
1529
|
curvert.x += deltax
|
1451
1530
|
curvert.y += deltay
|
1531
|
+
# update the bounds
|
1532
|
+
self.xmin += deltax
|
1533
|
+
self.xmax += deltax
|
1534
|
+
self.ymin += deltay
|
1535
|
+
self.ymax += deltay
|
1536
|
+
|
1537
|
+
# update the texture image position if it exists
|
1538
|
+
if self.myprop.textureimage is not None:
|
1539
|
+
self.myprop.textureimage.xmin = self.xmin
|
1540
|
+
self.myprop.textureimage.xmax = self.xmax
|
1541
|
+
self.myprop.textureimage.ymin = self.ymin
|
1542
|
+
self.myprop.textureimage.ymax = self.ymax
|
1452
1543
|
|
1453
1544
|
return self
|
1454
1545
|
else:
|
@@ -1482,6 +1573,14 @@ class vector:
|
|
1482
1573
|
for curvert in self.myvertices:
|
1483
1574
|
curvert.rotate(angle, center)
|
1484
1575
|
|
1576
|
+
self.find_minmax()
|
1577
|
+
|
1578
|
+
if self.myprop.textureimage is not None:
|
1579
|
+
self.myprop.textureimage.xmin = self.xmin
|
1580
|
+
self.myprop.textureimage.xmax = self.xmax
|
1581
|
+
self.myprop.textureimage.ymin = self.ymin
|
1582
|
+
self.myprop.textureimage.ymax = self.ymax
|
1583
|
+
|
1485
1584
|
return self
|
1486
1585
|
else:
|
1487
1586
|
new_vector = self.deepcopy_vector(self.myname + '_rotated')
|
@@ -2071,6 +2170,13 @@ class vector:
|
|
2071
2170
|
|
2072
2171
|
return self.myvertices[indexmp]
|
2073
2172
|
|
2173
|
+
def update_image_texture(self):
|
2174
|
+
"""
|
2175
|
+
Met à jour la texture de l'image si elle existe
|
2176
|
+
"""
|
2177
|
+
|
2178
|
+
self.myprop.update_image_texture()
|
2179
|
+
|
2074
2180
|
def find_minmax(self, only_firstlast:bool=False):
|
2075
2181
|
"""
|
2076
2182
|
Recherche l'extension spatiale du vecteur
|
@@ -2090,6 +2196,8 @@ class vector:
|
|
2090
2196
|
self.ymin=min(vert.y for vert in self.myvertices)
|
2091
2197
|
self.xmax=max(vert.x for vert in self.myvertices)
|
2092
2198
|
self.ymax=max(vert.y for vert in self.myvertices)
|
2199
|
+
|
2200
|
+
self.update_image_texture()
|
2093
2201
|
else:
|
2094
2202
|
self.xmin=-99999.
|
2095
2203
|
self.ymin=-99999.
|
@@ -3589,6 +3697,32 @@ class vector:
|
|
3589
3697
|
""" Alias for surface """
|
3590
3698
|
return self.surface
|
3591
3699
|
|
3700
|
+
def interpolate_coordinates(self):
|
3701
|
+
"""
|
3702
|
+
Interpole les valeurs Z des vertices sur base des seules valeurs connues,
|
3703
|
+
càd autre que infinity ou -99999 ou 99999.
|
3704
|
+
"""
|
3705
|
+
|
3706
|
+
sz = self.get_sz()
|
3707
|
+
s = sz[0]
|
3708
|
+
z = sz[1]
|
3709
|
+
|
3710
|
+
# Remove -99999 and empty values
|
3711
|
+
valid_indices = np.where((z != -99999.) & (z != 99999.) & (z != '') & (np.isfinite(z)))[0]
|
3712
|
+
if len(valid_indices) == 0:
|
3713
|
+
logging.warning(_('No valid z values to interpolate'))
|
3714
|
+
return
|
3715
|
+
|
3716
|
+
f = interp1d(s[valid_indices], z[valid_indices])
|
3717
|
+
|
3718
|
+
for k in range(self.nbvertices):
|
3719
|
+
if k not in valid_indices:
|
3720
|
+
z = f(s[k])
|
3721
|
+
self.myvertices[k].z = z
|
3722
|
+
|
3723
|
+
self.update_lengths()
|
3724
|
+
self._reset_listogl()
|
3725
|
+
|
3592
3726
|
class zone:
|
3593
3727
|
"""
|
3594
3728
|
Objet de gestion d'informations vectorielles
|
@@ -4109,14 +4243,14 @@ class zone:
|
|
4109
4243
|
self.has_legend |= curvect.myprop.legendvisible
|
4110
4244
|
self.has_image |= curvect.myprop.imagevisible
|
4111
4245
|
|
4112
|
-
if self.has_legend:
|
4113
|
-
for curvect in self.myvectors:
|
4114
|
-
curvect.plot_legend(sx, sy, xmin, ymin, xmax, ymax, size)
|
4115
|
-
|
4116
4246
|
if self.has_image:
|
4117
4247
|
for curvect in self.myvectors:
|
4118
4248
|
curvect.plot_image(sx, sy, xmin, ymin, xmax, ymax, size)
|
4119
4249
|
|
4250
|
+
if self.has_legend:
|
4251
|
+
for curvect in self.myvectors:
|
4252
|
+
curvect.plot_legend(sx, sy, xmin, ymin, xmax, ymax, size)
|
4253
|
+
|
4120
4254
|
def plot_matplotlib(self, ax:plt.Axes):
|
4121
4255
|
"""
|
4122
4256
|
Plot the zone using matplotlib
|
@@ -6699,6 +6833,14 @@ class Zones(wx.Frame, Element_To_Draw):
|
|
6699
6833
|
|
6700
6834
|
return minvec
|
6701
6835
|
|
6836
|
+
def find_vector_containing_point(self, x:float, y:float) -> vector:
|
6837
|
+
""" Trouve le prmier vecteur contenant le point (x,y) """
|
6838
|
+
xy = Point(x, y)
|
6839
|
+
for curzone in self.myzones:
|
6840
|
+
for curvect in curzone.myvectors:
|
6841
|
+
if curvect.polygon.contains(xy):
|
6842
|
+
return curvect
|
6843
|
+
|
6702
6844
|
def reset_listogl(self):
|
6703
6845
|
"""
|
6704
6846
|
Reset des listes OpenGL pour toutes les zones
|
wolfhece/Results2DGPU.py
CHANGED
@@ -274,9 +274,18 @@ class wolfres2DGPU(Wolfresults_2D):
|
|
274
274
|
idx: str = '',
|
275
275
|
plotted: bool = True,
|
276
276
|
mapviewer=None,
|
277
|
-
store = None
|
277
|
+
store = None,
|
278
|
+
load_from_cache:bool = True) -> None:
|
278
279
|
|
279
280
|
fname = Path(fname)
|
281
|
+
|
282
|
+
# Test if fname is an url
|
283
|
+
if str(fname).startswith('http:') or str(fname).startswith('https:'):
|
284
|
+
from .pydownloader import download_gpu_simulation, DATADIR
|
285
|
+
ret = download_gpu_simulation(fname, DATADIR / fname.name, load_from_cache = load_from_cache)
|
286
|
+
assert isinstance(ret, ResultsStore), _("Download failed or did not return a ResultsStore instance")
|
287
|
+
fname = DATADIR / fname.name
|
288
|
+
|
280
289
|
self._nap = None
|
281
290
|
|
282
291
|
if not fname.name.lower() == 'simul_gpu_results':
|
wolfhece/apps/version.py
CHANGED
wolfhece/pydownloader.py
CHANGED
@@ -36,6 +36,11 @@ class DownloadFiles(Enum):
|
|
36
36
|
VECFILES = ('vec', 'vec.extra')
|
37
37
|
VECZFILES = ('vecz', 'vecz.extra')
|
38
38
|
PROJECTFILES = ('proj',)
|
39
|
+
NUMPYFILES = ('npy',)
|
40
|
+
NPZFILES = ('npz',)
|
41
|
+
JSONFILES = ('json',)
|
42
|
+
TXTFILES = ('txt',)
|
43
|
+
CSVFILES = ('csv',)
|
39
44
|
|
40
45
|
class DonwloadDirectories(Enum):
|
41
46
|
""" Enum to define the directories for downloads. """
|
@@ -43,6 +48,7 @@ class DonwloadDirectories(Enum):
|
|
43
48
|
|
44
49
|
|
45
50
|
GITLAB_EXAMPLE = 'https://gitlab.uliege.be/HECE/wolf_examples/-/raw/main'
|
51
|
+
GITLAB_EXAMPLE_GPU = 'https://gitlab.uliege.be/HECE/wolfgpu_examples/-/raw/main'
|
46
52
|
DATADIR = Path(__file__).parent / 'data' / 'downloads'
|
47
53
|
|
48
54
|
def clean_url(url: str) -> str:
|
@@ -63,6 +69,10 @@ def clean_url(url: str) -> str:
|
|
63
69
|
cleaned_url = re.sub(r'(?<!:)//+', '/', cleaned_url)
|
64
70
|
# Convert Backslashes to forward slashes
|
65
71
|
cleaned_url = cleaned_url.replace('\\', '/')
|
72
|
+
|
73
|
+
cleaned_url = cleaned_url.replace(':/', '://')
|
74
|
+
cleaned_url = cleaned_url.replace(':///', '://')
|
75
|
+
|
66
76
|
# Ensure the URL starts with http:// or https://
|
67
77
|
if not cleaned_url.startswith(('http://', 'https://', 'ftp://')):
|
68
78
|
raise ValueError(f"Invalid URL: {url}. Must start with http://, https://, or ftp://")
|
@@ -171,6 +181,77 @@ def toys_dataset(dir:str, file:str, load_from_cache:bool = True):
|
|
171
181
|
destination = DATADIR / dir / file
|
172
182
|
return download_file(url, destination, load_from_cache=load_from_cache)
|
173
183
|
|
184
|
+
def download_gpu_simulation(url:str, destination:str | Path, load_from_cache:bool = True):
|
185
|
+
""" Download a GPU simulation file from the WOLFHECE dataset.
|
186
|
+
|
187
|
+
:param url: The URL of the GPU simulation file to download.
|
188
|
+
:param destination: The path where the file will be saved.
|
189
|
+
:param load_from_cache: If True, will not download the file if it already exists.
|
190
|
+
:type url: str
|
191
|
+
:type destination: str | Path
|
192
|
+
:type load_from_cache: bool
|
193
|
+
"""
|
194
|
+
|
195
|
+
url = str(url).strip()
|
196
|
+
url = clean_url(url)
|
197
|
+
destination = Path(destination)
|
198
|
+
|
199
|
+
files = ['NAP.npy', 'bathymetry.npy', 'bridge_roof.npy', 'bridge_deck.npy', 'h.npy', 'manning.npy', 'qx.npy', 'qy.npy', 'parameters.json']
|
200
|
+
dir_res = 'simul_gpu_results'
|
201
|
+
res_files = ['metadata.json', 'nap.npz', 'nb_results.txt', 'sim_times.csv']
|
202
|
+
|
203
|
+
try:
|
204
|
+
for file in files:
|
205
|
+
try:
|
206
|
+
download_file(f"{url}/{file}", destination / file, load_from_cache=load_from_cache)
|
207
|
+
except Exception as e:
|
208
|
+
logging.error(f"Error downloading file {file} from {url}: {e}")
|
209
|
+
|
210
|
+
url = url + '/' + dir_res
|
211
|
+
destination = destination / dir_res
|
212
|
+
for file in res_files:
|
213
|
+
try:
|
214
|
+
download_file(f"{url}/{file}", destination / file, load_from_cache=load_from_cache)
|
215
|
+
except Exception as e:
|
216
|
+
logging.error(f"Error downloading result file {file} from {url}: {e}")
|
217
|
+
|
218
|
+
with open(destination / 'nb_results.txt', 'r') as f:
|
219
|
+
nb_results = int(f.read().strip())
|
220
|
+
|
221
|
+
for i in range(1,nb_results+1):
|
222
|
+
# h_0000001.npz
|
223
|
+
# qx_0000001.npz
|
224
|
+
# qy_0000001.npz
|
225
|
+
for file in ['h', 'qx', 'qy']:
|
226
|
+
try:
|
227
|
+
download_file(f"{url}/{file}_{i:07d}.npz", destination / f'{file}_{i:07d}.npz', load_from_cache=load_from_cache)
|
228
|
+
except Exception as e:
|
229
|
+
logging.error(f"Error downloading result file {file}_{i:07d}.npz from {url}: {e}")
|
230
|
+
|
231
|
+
from wolfgpu.results_store import ResultsStore
|
232
|
+
rs = ResultsStore(destination)
|
233
|
+
|
234
|
+
except Exception as e:
|
235
|
+
logging.error(f"Error downloading GPU dataset {dir}: {e}")
|
236
|
+
rs = None
|
237
|
+
|
238
|
+
return rs
|
239
|
+
|
240
|
+
def toys_gpu_dataset(dir:str, dirweb:str = None, load_from_cache:bool = True):
|
241
|
+
""" Download toy simulatoin files from the WOLFHECE dataset for GPU.
|
242
|
+
|
243
|
+
:param dir: The directory where the file will be saved.
|
244
|
+
:param dirweb: The directory of the files to download.
|
245
|
+
:type dir: str
|
246
|
+
:type dirweb: str
|
247
|
+
:return: The path to the downloaded file.
|
248
|
+
"""
|
249
|
+
|
250
|
+
if dirweb is None:
|
251
|
+
dirweb = dir
|
252
|
+
|
253
|
+
return download_gpu_simulation(f"{GITLAB_EXAMPLE_GPU}/{dirweb}", DATADIR / dir, load_from_cache=load_from_cache)
|
254
|
+
|
174
255
|
if __name__ == "__main__":
|
175
256
|
# Example usage
|
176
257
|
print(download_file(r'https:\\gitlab.uliege.be\HECE\wolf_examples\-\raw\main\Extract_part_array\extraction.vec'))
|
@@ -180,3 +261,4 @@ if __name__ == "__main__":
|
|
180
261
|
print(download_file('https://gitlab.uliege.be/HECE/wolf_examples/-/raw/main/Array_Theux_Pepinster/mnt.tif'))
|
181
262
|
print(download_file('https://gitlab.uliege.be/HECE/wolf_examples/-/raw/main/PICC/PICC_Vesdre.shp'))
|
182
263
|
print(toys_dataset('Extract_part_array', 'extraction.vec'))
|
264
|
+
rs = toys_gpu_dataset('channel_w_archbridge_fully_man004')
|
wolfhece/textpillow.py
CHANGED
wolfhece/wolf_texture.py
CHANGED
@@ -48,12 +48,32 @@ class genericImagetexture(Element_To_Draw):
|
|
48
48
|
which: str,
|
49
49
|
label: str,
|
50
50
|
mapviewer,
|
51
|
-
xmin, xmax, ymin, ymax,
|
52
|
-
imageFile="",
|
53
|
-
imageObj=None,
|
51
|
+
xmin:float, xmax:float, ymin:float, ymax:float,
|
52
|
+
imageFile:str = "",
|
53
|
+
imageObj = None,
|
54
54
|
transparent_color = None,
|
55
55
|
tolerance:int = 3,
|
56
|
-
replace_color = None
|
56
|
+
replace_color = None,
|
57
|
+
drawing_scale:float = 1.0,
|
58
|
+
offset:list[float, float] = [0.,0.]) -> None:
|
59
|
+
|
60
|
+
""" Initialize the image texture
|
61
|
+
|
62
|
+
:param which: Type of image (e.g., 'satellite', 'map', etc.)
|
63
|
+
:param label: Label for the texture
|
64
|
+
:param mapviewer: The map viewer object to which this texture belongs
|
65
|
+
:param xmin: Minimum X coordinate for the texture
|
66
|
+
:param xmax: Maximum X coordinate for the texture
|
67
|
+
:param ymin: Minimum Y coordinate for the texture
|
68
|
+
:param ymax: Maximum Y coordinate for the texture
|
69
|
+
:param imageFile: Optional file path to load the image from
|
70
|
+
:param imageObj: Optional PIL Image object to use instead of loading from file
|
71
|
+
:param transparent_color: Color to treat as transparent in the image
|
72
|
+
:param tolerance: Tolerance for color matching when replacing transparent color
|
73
|
+
:param replace_color: Color to replace the transparent color with
|
74
|
+
:param drawing_scale: Scale factor for the image
|
75
|
+
:param offset: Offset to apply to the texture position
|
76
|
+
"""
|
57
77
|
|
58
78
|
super().__init__(label, True, mapviewer, False)
|
59
79
|
|
@@ -61,6 +81,7 @@ class genericImagetexture(Element_To_Draw):
|
|
61
81
|
self.mapviewer.canvas.SetCurrent(mapviewer.context)
|
62
82
|
except:
|
63
83
|
logging.error(_('Opengl setcurrent -- Do you have a active canvas ?'))
|
84
|
+
return
|
64
85
|
|
65
86
|
self.time = None
|
66
87
|
self.xmin = xmin
|
@@ -82,6 +103,9 @@ class genericImagetexture(Element_To_Draw):
|
|
82
103
|
self.imageFile = imageFile
|
83
104
|
self.myImage = imageObj
|
84
105
|
|
106
|
+
self.drawing_scale = drawing_scale
|
107
|
+
self.offset = offset
|
108
|
+
|
85
109
|
if imageFile != "":
|
86
110
|
if exists(imageFile):
|
87
111
|
try:
|
@@ -142,6 +166,11 @@ class genericImagetexture(Element_To_Draw):
|
|
142
166
|
del self.myImage
|
143
167
|
|
144
168
|
def load(self, imageFile=""):
|
169
|
+
""" Load the image texture into OpenGL
|
170
|
+
|
171
|
+
:param imageFile: Optional file path to load the image from
|
172
|
+
"""
|
173
|
+
|
145
174
|
if self.width == -99999 or self.height == -99999:
|
146
175
|
return
|
147
176
|
|
@@ -167,6 +196,7 @@ class genericImagetexture(Element_To_Draw):
|
|
167
196
|
'Opengl setcurrent -- maybe a conflict with an existing opengl32.dll file - please rename the opengl32.dll in the libs directory and retry')
|
168
197
|
|
169
198
|
def update_minmax(self):
|
199
|
+
""" Update the spatial extent of the texture based on its size """
|
170
200
|
|
171
201
|
if self.myImage is None:
|
172
202
|
return
|
@@ -181,7 +211,7 @@ class genericImagetexture(Element_To_Draw):
|
|
181
211
|
|
182
212
|
self.ymax = self.ymin + dx *scale
|
183
213
|
|
184
|
-
def reload(self,xmin=-99999,xmax=-99999,ymin=-99999,ymax=-99999):
|
214
|
+
def reload(self, xmin=-99999, xmax=-99999, ymin=-99999, ymax=-99999):
|
185
215
|
|
186
216
|
if xmin !=-99999:
|
187
217
|
self.xmin = xmin
|
@@ -210,7 +240,28 @@ class genericImagetexture(Element_To_Draw):
|
|
210
240
|
# Nothing to do, set during initialization phase
|
211
241
|
pass
|
212
242
|
|
243
|
+
def uv(self, x: float, y: float) -> tuple[float, float]:
|
244
|
+
""" Convert coordinates to texture coordinates taking into account the texture's spatial extent,
|
245
|
+
the scaleing factor, and the offset.
|
246
|
+
|
247
|
+
:param x: X coordinate in pixels
|
248
|
+
:param y: Y coordinate in pixels
|
249
|
+
:return: Tuple of (u, v) texture coordinates
|
250
|
+
"""
|
251
|
+
if self.width == -99999 or self.height == -99999:
|
252
|
+
return 0.0, 0.0
|
253
|
+
|
254
|
+
u = (x - self.offset[0] - self.xmin) / ((self.xmax - self.xmin) * self.drawing_scale)
|
255
|
+
v = 1.0 - (y - self.offset[1] - self.ymin) / ((self.ymax - self.ymin) * self.drawing_scale)
|
256
|
+
|
257
|
+
# Ensure u and v are within the range [0, 1]
|
258
|
+
u = max(0.0, min(1.0, u))
|
259
|
+
v = max(0.0, min(1.0, v))
|
260
|
+
|
261
|
+
return u, v
|
262
|
+
|
213
263
|
def paint(self):
|
264
|
+
""" Paint the image texture on the OpenGL canvas """
|
214
265
|
|
215
266
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
|
216
267
|
|
@@ -222,14 +273,31 @@ class genericImagetexture(Element_To_Draw):
|
|
222
273
|
glBindTexture(GL_TEXTURE_2D, self.idtexture[0])
|
223
274
|
|
224
275
|
glBegin(GL_QUADS)
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
276
|
+
|
277
|
+
# Draw a quad with texture coordinates
|
278
|
+
xy = [[self.xmin, self.ymax],
|
279
|
+
[self.xmax, self.ymax],
|
280
|
+
[self.xmax, self.ymin],
|
281
|
+
[self.xmin, self.ymin]]
|
282
|
+
uv = [self.uv(x,y) for x,y in xy]
|
283
|
+
|
284
|
+
glTexCoord2f(uv[0][0], uv[0][1])
|
285
|
+
glVertex2f(xy[0][0], xy[0][1])
|
286
|
+
glTexCoord2f(uv[1][0], uv[1][1])
|
287
|
+
glVertex2f(xy[1][0], xy[1][1])
|
288
|
+
glTexCoord2f(uv[2][0], uv[2][1])
|
289
|
+
glVertex2f(xy[2][0], xy[2][1])
|
290
|
+
glTexCoord2f(uv[3][0], uv[3][1])
|
291
|
+
glVertex2f(xy[3][0], xy[3][1])
|
292
|
+
|
293
|
+
# glTexCoord2f(0.0, 0.0)
|
294
|
+
# glVertex2f(self.xmin, self.ymax)
|
295
|
+
# glTexCoord2f(1.0, 0.0)
|
296
|
+
# glVertex2f(self.xmax, self.ymax)
|
297
|
+
# glTexCoord2f(1.0, 1.0)
|
298
|
+
# glVertex2f(self.xmax, self.ymin)
|
299
|
+
# glTexCoord2f(0.0, 1.0)
|
300
|
+
# glVertex2f(self.xmin, self.ymin)
|
233
301
|
glEnd()
|
234
302
|
glDisable(GL_TEXTURE_2D)
|
235
303
|
glDisable(GL_BLEND)
|