wolfhece 1.8.12__py3-none-any.whl → 2.0.0__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/GraphNotebook.py +0 -1
- wolfhece/PyCrosssections.py +591 -5
- wolfhece/PyDraw.py +1151 -413
- wolfhece/PyGui.py +2 -4
- wolfhece/PyParams.py +1515 -852
- wolfhece/PyVertex.py +73 -73
- wolfhece/PyVertexvectors.py +226 -808
- wolfhece/RatingCurve.py +19 -6
- wolfhece/apps/wolf2D.py +11 -0
- wolfhece/apps/wolfcompare2Darrays.py +51 -22
- wolfhece/bernoulli/NetworkOpenGL.py +337 -341
- wolfhece/drawing_obj.py +25 -0
- wolfhece/hydrology/Catchment.py +77 -77
- wolfhece/hydrology/Optimisation.py +206 -53
- wolfhece/hydrology/PostProcessHydrology.py +22 -22
- wolfhece/hydrology/SubBasin.py +17 -17
- wolfhece/hydrology/constant.py +4 -0
- wolfhece/hydrology/cst_exchanges.py +2 -1
- wolfhece/lazviewer/processing/estimate_normals/estimate_normals.cp310-win_amd64.pyd +0 -0
- wolfhece/lazviewer/vfuncs/vfuncs.cp310-win_amd64.pyd +0 -0
- wolfhece/libs/WolfDll.dll +0 -0
- wolfhece/libs/wolfogl.cp310-win_amd64.pyd +0 -0
- wolfhece/libs/wolfpy.cp310-win_amd64.pyd +0 -0
- wolfhece/mesh2d/wolf2dprev.py +4 -4
- wolfhece/multiprojects.py +13 -13
- wolfhece/pylogging.py +1 -1
- wolfhece/pyshields.py +213 -136
- wolfhece/pyviews.py +23 -23
- wolfhece/wolf_array.py +69 -152
- wolfhece/wolf_texture.py +39 -16
- wolfhece/wolfresults_2D.py +4 -4
- {wolfhece-1.8.12.dist-info → wolfhece-2.0.0.dist-info}/METADATA +3 -2
- {wolfhece-1.8.12.dist-info → wolfhece-2.0.0.dist-info}/RECORD +38 -34
- wolfhece/apps/wolfgpu.py +0 -19
- /wolfhece/lazviewer/processing/estimate_normals/{estimate_normals.pyd → estimate_normals.cp39-win_amd64.pyd} +0 -0
- /wolfhece/lazviewer/vfuncs/{vfuncs.pyd → vfuncs.cp39-win_amd64.pyd} +0 -0
- {wolfhece-1.8.12.dist-info → wolfhece-2.0.0.dist-info}/LICENCE +0 -0
- {wolfhece-1.8.12.dist-info → wolfhece-2.0.0.dist-info}/WHEEL +0 -0
- {wolfhece-1.8.12.dist-info → wolfhece-2.0.0.dist-info}/top_level.txt +0 -0
wolfhece/GraphNotebook.py
CHANGED
wolfhece/PyCrosssections.py
CHANGED
@@ -14,11 +14,13 @@ import typing
|
|
14
14
|
import copy
|
15
15
|
from enum import Enum
|
16
16
|
import logging
|
17
|
+
import wx
|
18
|
+
from typing import Union, Literal
|
17
19
|
|
18
20
|
from .PyTranslate import _
|
19
21
|
from .PyVertexvectors import vector,zone,Zones
|
20
22
|
from .PyVertex import wolfvertex,cloud_vertices, getIfromRGB
|
21
|
-
from .lazviewer.laz_viewer import xyz_laz_grids
|
23
|
+
from .lazviewer.laz_viewer import xyz_laz_grids, myviewer
|
22
24
|
|
23
25
|
example_largesect="""-138 100
|
24
26
|
-114 90
|
@@ -147,8 +149,9 @@ class profile(vector):
|
|
147
149
|
self.refpoints={}
|
148
150
|
|
149
151
|
self.s = 0.0
|
150
|
-
self.up = None
|
151
|
-
self.down = None
|
152
|
+
self.up:profile = None
|
153
|
+
self.down:profile = None
|
154
|
+
|
152
155
|
self.laz=False
|
153
156
|
|
154
157
|
if parent is not None:
|
@@ -2293,7 +2296,7 @@ class crosssections():
|
|
2293
2296
|
self.set_zones()
|
2294
2297
|
self.myzones.showstructure(parent, forceupdate)
|
2295
2298
|
|
2296
|
-
def get_upstream(self):
|
2299
|
+
def get_upstream(self) -> dict:
|
2297
2300
|
curprof:profile
|
2298
2301
|
curprof=self.myprofiles[list(self.myprofiles.keys())[0]]['cs']
|
2299
2302
|
|
@@ -2302,7 +2305,7 @@ class crosssections():
|
|
2302
2305
|
|
2303
2306
|
return self.myprofiles[curprof.myname]
|
2304
2307
|
|
2305
|
-
def get_downstream(self):
|
2308
|
+
def get_downstream(self) -> dict:
|
2306
2309
|
curprof:profile
|
2307
2310
|
curprof=self.myprofiles[list(self.myprofiles.keys())[0]]['cs']
|
2308
2311
|
|
@@ -2502,3 +2505,586 @@ class crosssections():
|
|
2502
2505
|
distmin=dist
|
2503
2506
|
|
2504
2507
|
return profmin
|
2508
|
+
|
2509
|
+
class Interpolator():
|
2510
|
+
"""
|
2511
|
+
Objet d'interpolation sur sections en travers
|
2512
|
+
|
2513
|
+
- self.interpolants est une liste de listes
|
2514
|
+
- chaque élément de self.interpolants est également une liste de listes
|
2515
|
+
- chaque liste de self.interpolants[k] contient les wolfvertex de la section discrétisée
|
2516
|
+
|
2517
|
+
"""
|
2518
|
+
|
2519
|
+
def __init__(self,vec1:vector,vec2:vector,supports:list,ds=1.) -> None:
|
2520
|
+
|
2521
|
+
self.interpolants=[]
|
2522
|
+
|
2523
|
+
sect1={}
|
2524
|
+
sect2={}
|
2525
|
+
|
2526
|
+
#Linestrings shapely des sections 1 et 2
|
2527
|
+
#ATTENTION, SHAPELY est une librairie géométrique 2D --> des outils spécifiques ont été programmés pour faire l'interpolation 3D
|
2528
|
+
s1=sect1['ls']=vec1.asshapely_ls()
|
2529
|
+
s2=sect2['ls']=vec2.asshapely_ls()
|
2530
|
+
|
2531
|
+
nb = 0
|
2532
|
+
supls={}
|
2533
|
+
|
2534
|
+
eps=5.e-2
|
2535
|
+
|
2536
|
+
for curvec in supports:
|
2537
|
+
#linestring du support courant
|
2538
|
+
#distances des intersections des sections sur le support
|
2539
|
+
myls:LineString
|
2540
|
+
myls=curvec.asshapely_ls()
|
2541
|
+
|
2542
|
+
#intersections du vecteur support avec les sections
|
2543
|
+
i1=myls.intersects(s1)
|
2544
|
+
if not i1:
|
2545
|
+
pt=Point(s1.xy[0][0],s1.xy[1][0])
|
2546
|
+
pt1=myls.interpolate(myls.project(pt))
|
2547
|
+
length = pt1.distance(pt)
|
2548
|
+
i1 = length<eps
|
2549
|
+
|
2550
|
+
if i1:
|
2551
|
+
vec1.myvertices[0].x=pt1.xy[0][0]
|
2552
|
+
vec1.myvertices[0].y=pt1.xy[1][0]
|
2553
|
+
s1=vec1.asshapely_ls()
|
2554
|
+
|
2555
|
+
if not i1:
|
2556
|
+
pt=Point(s1.xy[0][-1],s1.xy[1][-1])
|
2557
|
+
pt1=myls.interpolate(myls.project(pt))
|
2558
|
+
length = pt1.distance(pt)
|
2559
|
+
i1 = length<eps
|
2560
|
+
if i1:
|
2561
|
+
vec1.myvertices[-1].x=pt1.xy[0][-1]
|
2562
|
+
vec1.myvertices[-1].y=pt1.xy[1][-1]
|
2563
|
+
s1=vec1.asshapely_ls()
|
2564
|
+
|
2565
|
+
i2=myls.intersects(s2)
|
2566
|
+
if not i2:
|
2567
|
+
pt=Point(s2.xy[0][0],s2.xy[1][0])
|
2568
|
+
pt2=myls.interpolate(myls.project(pt))
|
2569
|
+
length = pt2.distance(Point(s2.xy[0][0],s2.xy[1][0]))
|
2570
|
+
i2 = length<eps
|
2571
|
+
|
2572
|
+
if i2:
|
2573
|
+
vec2.myvertices[0].x=pt2.xy[0][0]
|
2574
|
+
vec2.myvertices[0].y=pt2.xy[1][0]
|
2575
|
+
s2=vec2.asshapely_ls()
|
2576
|
+
|
2577
|
+
if not i2:
|
2578
|
+
pt=Point(s2.xy[0][-1],s2.xy[1][-1])
|
2579
|
+
pt2=myls.interpolate(myls.project(pt))
|
2580
|
+
length = pt2.distance(pt)
|
2581
|
+
i2 = length<eps
|
2582
|
+
if i2:
|
2583
|
+
vec2.myvertices[-1].x=pt2.xy[0][-1]
|
2584
|
+
vec2.myvertices[-1].y=pt2.xy[1][-1]
|
2585
|
+
s2=vec2.asshapely_ls()
|
2586
|
+
|
2587
|
+
if i1 and i2:
|
2588
|
+
supls[nb]={}
|
2589
|
+
supls[nb]['ls']=myls
|
2590
|
+
supls[nb]['vec']=curvec
|
2591
|
+
nb+=1
|
2592
|
+
|
2593
|
+
#bouclage sur les vecteurs supports pour trouver les intersections avec les sections
|
2594
|
+
# - trouver la portion utile entre intersections des supports
|
2595
|
+
# - trouver les distances sur les sections de ces intersections
|
2596
|
+
for k in range(nb):
|
2597
|
+
#linestring du support courant
|
2598
|
+
#distances des intersections des sections sur le support
|
2599
|
+
myls:LineString
|
2600
|
+
myls=supls[k]['ls']
|
2601
|
+
|
2602
|
+
#intersections du vecteur support avec les sections
|
2603
|
+
|
2604
|
+
#section amont
|
2605
|
+
i1=myls.intersection(s1)
|
2606
|
+
if i1.geom_type=='MultiPoint':
|
2607
|
+
i1=i1.geoms[0]
|
2608
|
+
|
2609
|
+
#section aval
|
2610
|
+
i2=myls.intersection(s2)
|
2611
|
+
if i2.geom_type=='MultiPoint':
|
2612
|
+
i2=i2.geoms[0]
|
2613
|
+
|
2614
|
+
#Les distances, sur les sections, sont calculées en projetant l'intersection du vecteur support et des sections
|
2615
|
+
sect1[k]=s1.project(i1)
|
2616
|
+
sect2[k]=s2.project(i2)
|
2617
|
+
|
2618
|
+
#Les distances, sur le support, sont calculées en projetant l'intersection du vecteur support et des sections
|
2619
|
+
supls[k][1]=myls.project(i1)
|
2620
|
+
if supls[k][1]==-1.:
|
2621
|
+
#problème de précision de calcul
|
2622
|
+
if myls.distance(Point(s1.xy[0][0],s1.xy[1][0]))<eps:
|
2623
|
+
supls[k][1]=myls.project(Point(s1.xy[0][0],s1.xy[1][0]))
|
2624
|
+
sect1[k]=s1.project(Point(s1.xy[0][0],s1.xy[1][0]))
|
2625
|
+
elif myls.distance(Point(s1.xy[0][-1],s1.xy[1][-1]))<eps:
|
2626
|
+
supls[k][1]=myls.project(Point(s1.xy[0][-1],s1.xy[1][-1]))
|
2627
|
+
sect1[k]=s1.project(Point(s1.xy[0][-1],s1.xy[1][-1]))
|
2628
|
+
|
2629
|
+
supls[k][2]=myls.project(i2)
|
2630
|
+
if supls[k][2]==-1.:
|
2631
|
+
#problème de précision de calcul
|
2632
|
+
if myls.distance(Point(s2.xy[0][0],s2.xy[1][0]))<eps:
|
2633
|
+
supls[k][2]=myls.project(Point(s2.xy[0][0],s2.xy[1][0]))
|
2634
|
+
sect2[k]=s2.project(Point(s2.xy[0][0],s2.xy[1][0]))
|
2635
|
+
elif myls.distance(Point(s2.xy[0][-1],s2.xy[1][-1]))<eps:
|
2636
|
+
supls[k][2]=myls.project(Point(s2.xy[0][-1],s2.xy[1][-1]))
|
2637
|
+
sect2[k]=s2.project(Point(s2.xy[0][-1],s2.xy[1][-1]))
|
2638
|
+
|
2639
|
+
#on ne conserve que la fraction utile entre intersections
|
2640
|
+
supls[k]['vec']=supls[k]['vec'].substring(supls[k][1],supls[k][2],False,False)
|
2641
|
+
|
2642
|
+
#bouclage sur les intervalles --> nb_supports-1
|
2643
|
+
for k in range(nb-1):
|
2644
|
+
interpolant=[]
|
2645
|
+
self.interpolants.append(interpolant)
|
2646
|
+
|
2647
|
+
cursupl:vector
|
2648
|
+
cursupr:vector
|
2649
|
+
curvec1:vector
|
2650
|
+
curvec2:vector
|
2651
|
+
|
2652
|
+
#morceaux de sections entre intersections avec le support
|
2653
|
+
curvec1=sect1['sub'+str(k)]=vec1.substring(sect1[k],sect1[k+1],is3D=False,adim=False)
|
2654
|
+
curvec2=sect2['sub'+str(k)]=vec2.substring(sect2[k],sect2[k+1],is3D=False,adim=False)
|
2655
|
+
|
2656
|
+
#pointeurrs vers les morceaux des supports
|
2657
|
+
cursupl = supls[k]['vec']
|
2658
|
+
cursupr = supls[k+1]['vec']
|
2659
|
+
|
2660
|
+
#MAJ des longueurs 2D et 3D
|
2661
|
+
cursupl.update_lengths()
|
2662
|
+
cursupr.update_lengths()
|
2663
|
+
curvec1.update_lengths()
|
2664
|
+
curvec2.update_lengths()
|
2665
|
+
|
2666
|
+
#Trouve la liste des distances à traiter pour le maillage
|
2667
|
+
nbi = np.ceil(max(curvec1.length3D,curvec2.length3D)/ds)
|
2668
|
+
locds = 1./float(nbi)
|
2669
|
+
dist3d = np.concatenate([np.arange(0.,1.,locds),np.cumsum(curvec1._lengthparts3D)/curvec1.length3D,np.cumsum(curvec2._lengthparts3D)/curvec2.length3D])
|
2670
|
+
dist3d = np.unique(dist3d)
|
2671
|
+
|
2672
|
+
#nombre de points à traiter sur les supports
|
2673
|
+
# on divise la longueur 3D des supports par la taille souhaitée et on arrondi à l'entier supérieur
|
2674
|
+
nbi = int(np.ceil(max(cursupl.length3D,cursupr.length3D)/ds))
|
2675
|
+
# nouvelle distance de calcul
|
2676
|
+
locds = 1./float(nbi)
|
2677
|
+
|
2678
|
+
sloc=0.
|
2679
|
+
pt1l = curvec1.interpolate(0.,True,True)
|
2680
|
+
pt2l = curvec2.interpolate(0.,True,True)
|
2681
|
+
pt1r = curvec1.interpolate(1.,True,True)
|
2682
|
+
pt2r = curvec2.interpolate(1.,True,True)
|
2683
|
+
|
2684
|
+
s1dr = vector(name='sectiondroite1')
|
2685
|
+
s2dr = vector(name='sectiondroite2')
|
2686
|
+
s1dr.add_vertex([pt1l,pt1r])
|
2687
|
+
s2dr.add_vertex([pt2l,pt2r])
|
2688
|
+
|
2689
|
+
s1dr = s1dr.asshapely_ls()
|
2690
|
+
s2dr = s2dr.asshapely_ls()
|
2691
|
+
|
2692
|
+
# if np.isnan(pt1l.x):
|
2693
|
+
# a=1
|
2694
|
+
# if np.isnan(pt2l.x):
|
2695
|
+
# a=1
|
2696
|
+
# if np.isnan(pt1r.x):
|
2697
|
+
# a=1
|
2698
|
+
# if np.isnan(pt2r.x):
|
2699
|
+
# a=1
|
2700
|
+
|
2701
|
+
for curalong in range(nbi+1):
|
2702
|
+
print(str(curalong))
|
2703
|
+
|
2704
|
+
#interpolation 3D sur les 2 supports
|
2705
|
+
l1 = cursupl.interpolate(sloc,True,True)
|
2706
|
+
l2 = cursupr.interpolate(sloc,True,True)
|
2707
|
+
|
2708
|
+
curvec=vector(name='loc')
|
2709
|
+
curvec.add_vertex([l1,l2])
|
2710
|
+
val = []
|
2711
|
+
|
2712
|
+
if l1.z!=0.:
|
2713
|
+
if pt1l.z==0.:
|
2714
|
+
alpha1l=0.
|
2715
|
+
else:
|
2716
|
+
alpha1l = l1.z/pt1l.z
|
2717
|
+
if pt2l.z==0.:
|
2718
|
+
alpha2l=0.
|
2719
|
+
else:
|
2720
|
+
alpha2l = l1.z/pt2l.z
|
2721
|
+
else:
|
2722
|
+
alpha1l = 0.
|
2723
|
+
alpha2l = 0.
|
2724
|
+
if l2.z!=0.:
|
2725
|
+
if pt1r.z==0.:
|
2726
|
+
alpha1r = 0.
|
2727
|
+
else:
|
2728
|
+
alpha1r = l2.z/pt1r.z
|
2729
|
+
|
2730
|
+
if pt2r.z==0.:
|
2731
|
+
alpha2r = 0.
|
2732
|
+
else:
|
2733
|
+
alpha2r = l2.z/pt2r.z
|
2734
|
+
else:
|
2735
|
+
alpha1r=0.
|
2736
|
+
alpha2r=0.
|
2737
|
+
|
2738
|
+
for curdist in dist3d:
|
2739
|
+
|
2740
|
+
#interpolation 3D dans les 2 sections
|
2741
|
+
cur1 = curvec1.interpolate(curdist,True,True)
|
2742
|
+
cur2 = curvec2.interpolate(curdist,True,True)
|
2743
|
+
|
2744
|
+
alpha1 = alpha1l*(1.-curdist)+alpha1r*curdist
|
2745
|
+
alpha2 = alpha2l*(1.-curdist)+alpha2r*curdist
|
2746
|
+
|
2747
|
+
sr1 = s1dr.project(Point(cur1.x,cur1.y))
|
2748
|
+
sr2 = s2dr.project(Point(cur2.x,cur2.y))
|
2749
|
+
pr1 = s1dr.interpolate(sr1)
|
2750
|
+
pr2 = s2dr.interpolate(sr2)
|
2751
|
+
sr1/=s1dr.length
|
2752
|
+
sr2/=s2dr.length
|
2753
|
+
|
2754
|
+
dx1 = cur1.x-pr1.x
|
2755
|
+
dy1 = cur1.y-pr1.y
|
2756
|
+
dx2 = cur2.x-pr2.x
|
2757
|
+
dy2 = cur2.y-pr2.y
|
2758
|
+
dx = dx1*(1.-sloc)+dx2*sloc
|
2759
|
+
dy = dy1*(1.-sloc)+dy2*sloc
|
2760
|
+
s = sr1*(1.-sloc)+sr2*sloc
|
2761
|
+
|
2762
|
+
# dist2d1 = cur1.dist2D(curvec1.myvertices[0])/curvec1.myvertices[0].dist2D(curvec1.myvertices[-1]) #curvec1.length2D
|
2763
|
+
# dist2d2 = cur2.dist2D(curvec2.myvertices[0])/curvec2.myvertices[0].dist2D(curvec2.myvertices[-1]) #curvec2.length2D
|
2764
|
+
# dist2d = dist2d1*(1.-sloc) + dist2d2*sloc
|
2765
|
+
# pt = curvec.interpolate(dist2d,False,True)
|
2766
|
+
pt = curvec.interpolate(s,False,True)
|
2767
|
+
|
2768
|
+
# xloc = cur1.x + sloc * (cur2.x-cur1.x)
|
2769
|
+
# yloc = cur1.y + sloc * (cur2.y-cur1.y)
|
2770
|
+
zloc = cur1.z*alpha1 + sloc * (cur2.z*alpha2-cur1.z*alpha1)
|
2771
|
+
|
2772
|
+
val.append(wolfvertex(pt.x+dx,pt.y+dy,zloc))
|
2773
|
+
# val.append(wolfvertex(xloc,yloc,zloc))
|
2774
|
+
|
2775
|
+
interpolant.append(val)
|
2776
|
+
|
2777
|
+
sloc+=locds
|
2778
|
+
sloc=min(sloc,1.)
|
2779
|
+
|
2780
|
+
def get_xyz_for_viewer(self,nbsub=10):
|
2781
|
+
|
2782
|
+
pts=self.interpolants
|
2783
|
+
|
2784
|
+
nb=0
|
2785
|
+
for curpt in pts:
|
2786
|
+
for curl in curpt:
|
2787
|
+
nb+=(len(curpt)-1)*(len(curl)-1)*3+(len(curl)-1)+(len(curpt))
|
2788
|
+
|
2789
|
+
pond=np.arange(0.,1.,1./float(nbsub))
|
2790
|
+
xyz=np.ones([(nb-1)*nbsub,4],order='F')
|
2791
|
+
start=0
|
2792
|
+
for curpt in pts:
|
2793
|
+
for k in range(len(curpt)-1):
|
2794
|
+
curl=curpt[k]
|
2795
|
+
nextl=curpt[k+1]
|
2796
|
+
for i in range(len(curl)-1):
|
2797
|
+
v1=curl[i].getcoords()
|
2798
|
+
v2=curl[i+1].getcoords()
|
2799
|
+
v3=nextl[i].getcoords()
|
2800
|
+
|
2801
|
+
xyz[start:start+nbsub,:3]=[v1+(v2-v1)*curpond for curpond in pond]
|
2802
|
+
start+=nbsub
|
2803
|
+
xyz[start:start+nbsub,:3]= [v2+(v3-v2)*curpond for curpond in pond]
|
2804
|
+
start+=nbsub
|
2805
|
+
xyz[start:start+nbsub,:3]= [v3+(v1-v3)*curpond for curpond in pond]
|
2806
|
+
start+=nbsub
|
2807
|
+
|
2808
|
+
curl=curpt[-1]
|
2809
|
+
for i in range(len(curl)-1):
|
2810
|
+
v1=curl[i].getcoords()
|
2811
|
+
v2=curl[i+1].getcoords()
|
2812
|
+
xyz[start:start+nbsub,:3]=[v1+(v2-v1)*curpond for curpond in pond]
|
2813
|
+
start+=nbsub
|
2814
|
+
for k in range(len(curpt)-1):
|
2815
|
+
curl=curpt[k]
|
2816
|
+
nextl=curpt[k+1]
|
2817
|
+
v1=curl[-1].getcoords()
|
2818
|
+
v3=nextl[-1].getcoords()
|
2819
|
+
xyz[start:start+nbsub,:3]=[v1+(v3-v1)*curpond for curpond in pond]
|
2820
|
+
start+=nbsub
|
2821
|
+
|
2822
|
+
return xyz
|
2823
|
+
|
2824
|
+
def add_triangles_to_zone(self,myzone:zone):
|
2825
|
+
|
2826
|
+
nb=0
|
2827
|
+
npt=1
|
2828
|
+
for curpt in self.interpolants:
|
2829
|
+
for k in range(len(curpt)-1):
|
2830
|
+
curl=curpt[k]
|
2831
|
+
nextl=curpt[k+1]
|
2832
|
+
for i in range(len(curl)-1):
|
2833
|
+
curvec = vector(name='tr'+'_'+str(npt)+'_'+str(k)+'_'+str(i),parentzone=myzone)
|
2834
|
+
curvec.add_vertex([curl[i],curl[i+1],nextl[i]])
|
2835
|
+
curvec.close_force()
|
2836
|
+
curvec.myprop.used=False
|
2837
|
+
myzone.add_vector(curvec)
|
2838
|
+
|
2839
|
+
curvec = vector(name='tr'+'_'+str(npt)+'_'+str(k+1)+'_'+str(i),parentzone=myzone)
|
2840
|
+
curvec.add_vertex([nextl[i],curl[i+1],nextl[i+1]])
|
2841
|
+
curvec.close_force()
|
2842
|
+
curvec.myprop.used=False
|
2843
|
+
myzone.add_vector(curvec)
|
2844
|
+
|
2845
|
+
npt+=1
|
2846
|
+
nb+=(len(curpt)-1)*(len(curl)-1)*3+(len(curl)-1)+(len(curpt))
|
2847
|
+
|
2848
|
+
def get_triangles(self,forgltf=True):
|
2849
|
+
|
2850
|
+
points=[]
|
2851
|
+
triangles=[]
|
2852
|
+
nbpts=0
|
2853
|
+
nbtr=0
|
2854
|
+
for curpt in self.interpolants:
|
2855
|
+
|
2856
|
+
nb_points_perline = len(curpt[0])
|
2857
|
+
nbsect=len(curpt)
|
2858
|
+
if forgltf:
|
2859
|
+
pointsloc=[[pt.x,pt.z,-pt.y] for curl in curpt for pt in curl]
|
2860
|
+
else:
|
2861
|
+
pointsloc=[[pt.x,pt.y,pt.z] for curl in curpt for pt in curl]
|
2862
|
+
|
2863
|
+
trianglesloc=[[[k+decal*nb_points_perline+nbpts,
|
2864
|
+
k+1+decal*nb_points_perline+nbpts,
|
2865
|
+
nb_points_perline+k+decal*nb_points_perline+nbpts],
|
2866
|
+
|
2867
|
+
[nb_points_perline+k+decal*nb_points_perline+nbpts,
|
2868
|
+
k+1+decal*nb_points_perline+nbpts,
|
2869
|
+
nb_points_perline+k+decal*nb_points_perline+1+nbpts]]
|
2870
|
+
for decal in range(len(curpt)-1) for k in range(nb_points_perline-1)]
|
2871
|
+
|
2872
|
+
nbpts+=nb_points_perline*nbsect
|
2873
|
+
nbloc=(nb_points_perline-1)*(nbsect-1)*2
|
2874
|
+
nbtr+=nbloc
|
2875
|
+
|
2876
|
+
points.append(pointsloc)
|
2877
|
+
triangles.append(np.asarray(trianglesloc).reshape([nbloc,3]))
|
2878
|
+
|
2879
|
+
|
2880
|
+
points=np.asarray(np.concatenate(points),dtype=np.float32)
|
2881
|
+
triangles=np.asarray(np.concatenate(triangles),dtype=np.uint32)
|
2882
|
+
|
2883
|
+
|
2884
|
+
if len(np.argwhere(np.isnan(points)==True))>0:
|
2885
|
+
a=1
|
2886
|
+
|
2887
|
+
return nbpts,points,triangles
|
2888
|
+
|
2889
|
+
def get_points(self,forgltf=False):
|
2890
|
+
|
2891
|
+
points=[]
|
2892
|
+
nbpts=0
|
2893
|
+
for curpt in self.interpolants:
|
2894
|
+
|
2895
|
+
nb_points_perline = len(curpt[0])
|
2896
|
+
nbsect=len(curpt)
|
2897
|
+
if forgltf:
|
2898
|
+
pointsloc=[[pt.x,pt.z,-pt.y] for curl in curpt for pt in curl]
|
2899
|
+
else:
|
2900
|
+
pointsloc=[[pt.x,pt.y,pt.z] for curl in curpt for pt in curl]
|
2901
|
+
|
2902
|
+
nbpts+=nb_points_perline*nbsect
|
2903
|
+
points.append(pointsloc)
|
2904
|
+
|
2905
|
+
if forgltf:
|
2906
|
+
points=np.asarray(np.concatenate(points),dtype=np.float32)
|
2907
|
+
else:
|
2908
|
+
points=np.asarray(np.concatenate(points))
|
2909
|
+
|
2910
|
+
return nbpts,points
|
2911
|
+
|
2912
|
+
def export_gltf(self,points=None,triangles=None):
|
2913
|
+
|
2914
|
+
if points is None and triangles is None:
|
2915
|
+
points,triangles= self.get_triangles()
|
2916
|
+
|
2917
|
+
triangles_binary_blob = triangles.flatten().tobytes()
|
2918
|
+
points_binary_blob = points.tobytes()
|
2919
|
+
|
2920
|
+
gltf = pygltflib.GLTF2(
|
2921
|
+
scene=0,
|
2922
|
+
scenes=[pygltflib.Scene(nodes=[0])],
|
2923
|
+
nodes=[pygltflib.Node(mesh=0)],
|
2924
|
+
meshes=[
|
2925
|
+
pygltflib.Mesh(
|
2926
|
+
primitives=[
|
2927
|
+
pygltflib.Primitive(
|
2928
|
+
attributes=pygltflib.Attributes(POSITION=1), indices=0
|
2929
|
+
)
|
2930
|
+
]
|
2931
|
+
)
|
2932
|
+
],
|
2933
|
+
accessors=[
|
2934
|
+
pygltflib.Accessor(
|
2935
|
+
bufferView=0,
|
2936
|
+
componentType=pygltflib.UNSIGNED_INT,
|
2937
|
+
count=triangles.size,
|
2938
|
+
type=pygltflib.SCALAR,
|
2939
|
+
max=[int(triangles.max())],
|
2940
|
+
min=[int(triangles.min())],
|
2941
|
+
),
|
2942
|
+
pygltflib.Accessor(
|
2943
|
+
bufferView=1,
|
2944
|
+
componentType=pygltflib.FLOAT,
|
2945
|
+
count=len(points),
|
2946
|
+
type=pygltflib.VEC3,
|
2947
|
+
max=points.max(axis=0).tolist(),
|
2948
|
+
min=points.min(axis=0).tolist(),
|
2949
|
+
),
|
2950
|
+
],
|
2951
|
+
bufferViews=[
|
2952
|
+
pygltflib.BufferView(
|
2953
|
+
buffer=0,
|
2954
|
+
byteLength=len(triangles_binary_blob),
|
2955
|
+
target=pygltflib.ELEMENT_ARRAY_BUFFER,
|
2956
|
+
),
|
2957
|
+
pygltflib.BufferView(
|
2958
|
+
buffer=0,
|
2959
|
+
byteOffset=len(triangles_binary_blob),
|
2960
|
+
byteLength=len(points_binary_blob),
|
2961
|
+
target=pygltflib.ARRAY_BUFFER,
|
2962
|
+
),
|
2963
|
+
],
|
2964
|
+
buffers=[
|
2965
|
+
pygltflib.Buffer(
|
2966
|
+
byteLength=len(triangles_binary_blob) + len(points_binary_blob)
|
2967
|
+
)
|
2968
|
+
],
|
2969
|
+
)
|
2970
|
+
gltf.set_binary_blob(triangles_binary_blob + points_binary_blob)
|
2971
|
+
|
2972
|
+
dlg=wx.FileDialog(None,_('Choose filename'),wildcard='binary gltf2 (*.glb)|*.glb|gltf2 (*.gltf)|*.gltf|All (*.*)|*.*',style=wx.FD_SAVE)
|
2973
|
+
ret=dlg.ShowModal()
|
2974
|
+
if ret==wx.ID_CANCEL:
|
2975
|
+
dlg.Destroy()
|
2976
|
+
return
|
2977
|
+
|
2978
|
+
fn=dlg.GetPath()
|
2979
|
+
dlg.Destroy()
|
2980
|
+
|
2981
|
+
gltf.save(fn)
|
2982
|
+
|
2983
|
+
def get_xy_z_for_griddata(self):
|
2984
|
+
|
2985
|
+
xy = np.asarray([[curvertex.x,curvertex.y] for curpt in self.interpolants for curl in curpt for curvertex in curl])
|
2986
|
+
z = np.asarray([curvertex.z for curpt in self.interpolants for curl in curpt for curvertex in curl])
|
2987
|
+
|
2988
|
+
# if len(np.argwhere(np.isnan(z)))>0:
|
2989
|
+
# test=1
|
2990
|
+
# if len(np.argwhere(np.isneginf(z)))>0:
|
2991
|
+
# test=1
|
2992
|
+
# if len(np.argwhere(np.isposinf(z)))>0:
|
2993
|
+
# test=1
|
2994
|
+
return xy,z
|
2995
|
+
|
2996
|
+
class Interpolators():
|
2997
|
+
""" Classe de gestion des interpolations sur sections en travers """
|
2998
|
+
|
2999
|
+
def __init__(self, banks:Zones, cs:crosssections, ds=1.) -> None:
|
3000
|
+
"""
|
3001
|
+
Constructeur de la classe Interpolators
|
3002
|
+
|
3003
|
+
@param banks: Zones contenant les vecteurs supports
|
3004
|
+
@param cs: objet 'crosssections' contenant les sections en travers --> voir PyCrosssections
|
3005
|
+
"""
|
3006
|
+
|
3007
|
+
self.mybanks = [curv for curzone in banks.myzones for curv in curzone.myvectors]
|
3008
|
+
cs.set_zones()
|
3009
|
+
self.mycs = cs.myzones
|
3010
|
+
|
3011
|
+
self.myinterp:list[Interpolator]=[]
|
3012
|
+
|
3013
|
+
zonecs:zone
|
3014
|
+
zonecs = self.mycs.myzones[0]
|
3015
|
+
|
3016
|
+
if zonecs.myvectors[0].up is not None:
|
3017
|
+
|
3018
|
+
cs1:profile
|
3019
|
+
cs1=cs.get_upstream()['cs']
|
3020
|
+
|
3021
|
+
while cs1.down is not cs1:
|
3022
|
+
cs2=cs1.down
|
3023
|
+
|
3024
|
+
print('{} - {}'.format(cs1.myname,cs2.myname))
|
3025
|
+
|
3026
|
+
myinterp=Interpolator(cs1,cs2,self.mybanks,ds)
|
3027
|
+
self.myinterp.append(myinterp)
|
3028
|
+
cs1=cs2
|
3029
|
+
else:
|
3030
|
+
for i in range(zonecs.nbvectors-1):
|
3031
|
+
cs1=zonecs.myvectors[i]
|
3032
|
+
cs2=zonecs.myvectors[i+1]
|
3033
|
+
|
3034
|
+
print('{} - {}'.format(cs1.myname,cs2.myname))
|
3035
|
+
myinterp=Interpolator(cs1,cs2,self.mybanks,ds)
|
3036
|
+
self.myinterp.append(myinterp)
|
3037
|
+
|
3038
|
+
self.add_interpolators(cs.myzones.parent)
|
3039
|
+
|
3040
|
+
def add_interpolators(self, parent):
|
3041
|
+
"""
|
3042
|
+
Ajout d'objets 'Interpolators' pour affichage/stockage
|
3043
|
+
"""
|
3044
|
+
self.myzones = Zones(parent=parent)
|
3045
|
+
|
3046
|
+
id=0
|
3047
|
+
points=[]
|
3048
|
+
triangles=[]
|
3049
|
+
decal=0
|
3050
|
+
|
3051
|
+
for curinterp in self.myinterp:
|
3052
|
+
id+=1
|
3053
|
+
|
3054
|
+
myzone = zone(name='Interpolator'+str(id), parent=self.myzones, is2D=False)
|
3055
|
+
myzone.used=False
|
3056
|
+
self.myzones.add_zone(myzone)
|
3057
|
+
curinterp.add_triangles_to_zone(myzone)
|
3058
|
+
|
3059
|
+
nbpts,pts,tr=curinterp.get_triangles()
|
3060
|
+
|
3061
|
+
points.append(pts)
|
3062
|
+
triangles.append(tr+decal)
|
3063
|
+
decal+=nbpts
|
3064
|
+
|
3065
|
+
curinterp.export_gltf(np.concatenate(points),np.concatenate(triangles))
|
3066
|
+
|
3067
|
+
|
3068
|
+
def viewer_interpolator(self):
|
3069
|
+
|
3070
|
+
xyz=[]
|
3071
|
+
for curinterp in self.myinterp:
|
3072
|
+
xyz.append(curinterp.get_xyz_for_viewer())
|
3073
|
+
|
3074
|
+
xyz=np.concatenate(xyz)
|
3075
|
+
|
3076
|
+
myviewer(xyz,0)
|
3077
|
+
|
3078
|
+
def interp_on_array(self, myarray, method:Literal["nearest", "linear", "cubic"]):
|
3079
|
+
|
3080
|
+
xy=[]
|
3081
|
+
z=[]
|
3082
|
+
for curinterp in self.myinterp:
|
3083
|
+
tmpxy,tmpz = curinterp.get_xy_z_for_griddata()
|
3084
|
+
xy.append(tmpxy)
|
3085
|
+
z.append(tmpz)
|
3086
|
+
|
3087
|
+
xy = np.concatenate(xy)
|
3088
|
+
z = np.concatenate(z)
|
3089
|
+
|
3090
|
+
myarray.interpolate_on_cloud(xy,z,method)
|