:py:mod:`wolfhece.PyVertexvectors` ================================== .. py:module:: wolfhece.PyVertexvectors .. autoapi-nested-parse:: Author: HECE - University of Liege, Pierre Archambeau, Utashi Ciraane Docile Date: 2024 Copyright (c) 2024 University of Liege. All rights reserved. This script and its content are protected by copyright law. Unauthorized copying or distribution of this file, via any medium, is strictly prohibited. Module Contents --------------- .. py:class:: Triangulation(fn='', pts=[], tri=[], idx: str = '', plotted: bool = True, mapviewer=None, need_for_wx: bool = False) Bases: :py:obj:`wolfhece.drawing_obj.Element_To_Draw` .. autoapi-inheritance-diagram:: wolfhece.PyVertexvectors.Triangulation :parts: 1 :private-bases: Base class of element to add into WolfMapViewer or another GUI .. py:method:: valid_format() .. py:method:: as_polydata() -> pyvista.PolyData .. py:method:: from_polydata(poly: pyvista.PolyData) .. py:method:: clip_surface(other, invert=True, subdivide=0) .. py:method:: get_mask(eps=1e-10) Teste si la surface de tous les triangles est positive Retire les triangles problématiques .. py:method:: import_from_gltf(fn='') .. py:method:: export_to_gltf(fn='') .. py:method:: saveas(fn='') Binary '.TRI' format on disk is, little endian : - int32 for number of points - int32 as 64 ou 32 for float64 or float32 - VEC3 (float64 or float32) for points - int32 for number of triangles - VEC3 uint32 for triangles .. py:method:: read(fn: str) Read a binary '.TRI' file .. py:method:: reset_plot() .. py:method:: plot(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None) Plot data in OpenGL context .. py:method:: find_minmax(force) Generic function to find min and max spatial extent in data example : a WolfMapViewer instance needs spatial extent to zoom or test if element must be plotted .. py:method:: import_dxf(fn) .. py:method:: set_cache() Set the cache for the vertices .. py:method:: clear_cache() Clear the cache for the vertices .. py:method:: move(delta_x: float, delta_y: float, use_cache: bool = True) Move the vertices by a delta_x and delta_y :param delta_x: delta x [m] :param delta_y: delta y [m] .. py:method:: rotate(angle: float, center: tuple, use_cache: bool = True) Rotate the vertices around a center :param angle: angle in degrees -- positive for clockwise rotation :param center: center of rotation .. py:method:: rotate_xy(x: float, y: float, use_cache: bool = True) Rotate the vector around the rotation center and a xy point .. py:class:: vectorproperties(lines: list[str] = [], parent: vector = None) Vector properties .. py:attribute:: used :type: bool .. py:attribute:: color :type: int .. py:attribute:: width :type: int .. py:attribute:: style :type: int .. py:attribute:: alpha :type: int .. py:attribute:: closed .. py:attribute:: filled :type: bool .. py:attribute:: legendvisible :type: bool .. py:attribute:: transparent :type: bool .. py:attribute:: flash :type: bool .. py:attribute:: legendtext :type: str .. py:attribute:: legendrelpos :type: int .. py:attribute:: legendx :type: float .. py:attribute:: legendy :type: float .. py:attribute:: legendbold :type: bool .. py:attribute:: legenditalic :type: bool .. py:attribute:: legendunderlined :type: bool .. py:attribute:: legendfontname .. py:attribute:: legendfontsize :type: int .. py:attribute:: legendcolor :type: int .. py:attribute:: extrude :type: bool :value: False .. py:attribute:: myprops :type: wolfhece.PyParams.Wolf_Param .. py:method:: set_color_from_value(key: str, cmap: wolfhece.PyPalette.wolfpalette | str | matplotlib.colors.Colormap | matplotlib.cm.ScalarMappable, vmin: float = 0.0, vmax: float = 1.0) Set the color from a value .. py:method:: init_extra() Init extra properties --> not compatible with VB6, Fortran codes Useful for Python UI, OpenGL legend, etc. .. py:method:: get_extra() -> list[float, float, int, float, str, bool] Return extra properties .. py:method:: set_extra(linesextra: list[float, float, int, float, str, bool] = None) Set extra properties .. py:method:: load_extra(lines: list[str]) -> int Load extra properties from lines .. py:method:: save_extra(f: io.TextIOWrapper) Save extra properties to opened file .. py:method:: save(f: io.TextIOWrapper) Save properties to opened file Pay attention to the order of the lines and the format to be compatible with VB6, Fortran codes .. py:method:: load_unload_image() Load an attached image .. py:method:: fill_property(props: wolfhece.PyParams.Wolf_Param = None, updateOGL: bool = True) Callback for the properties UI When the 'Apply' button is pressed, this function is called .. py:method:: _defaultprop() Create the default properties for the vector and the associated UI .. py:method:: destroyprop() Nullify the properties UI Destroy has been called, so the UI is not visible anymore .. py:method:: show() Show the properties Firstly, set default values Then, add the current properties to the UI .. py:method:: show_properties() Show the properties -- alias of show() .. py:method:: hide_properties() Hide the properties .. py:method:: _convert_fontname2int(fontname: str) -> int .. py:method:: _convert_int2fontname(id: int) -> str .. py:method:: update_myprops() Update the properties .. py:class:: vector(lines: list = [], is2D=True, name='NoName', parentzone: zone = None, fromshapely=None, fromnumpy: numpy.ndarray = None) Objet de gestion d'informations vectorielles Une instance 'vector' contient une liste de 'wolfvertex' .. py:property:: polygon :type: shapely.geometry.Polygon Return the polygon .. py:property:: linestring :type: shapely.geometry.LineString Return the linestring .. py:property:: closed :type: bool .. py:property:: nbvertices :type: int .. py:property:: used :type: bool .. py:property:: has_interior Return True if the vector has an interior .. py:property:: centroid Return the centroid of the vector .. py:property:: z .. py:property:: x .. py:property:: y .. py:property:: xy .. py:property:: xz .. py:property:: xyz .. py:property:: i .. py:property:: xyzi .. py:property:: xyi .. py:property:: sz_curvi .. py:property:: s_curvi .. py:property:: surface Compute the surface of the vector .. py:property:: area Alias for surface .. py:attribute:: myname :type: str .. py:attribute:: parentzone :type: zone .. py:attribute:: nbvertices :type: int .. py:attribute:: myvertices :type: list[wolfhece.PyVertex.wolfvertex] .. py:attribute:: myprop :type: vectorproperties .. py:attribute:: xmin :type: float .. py:attribute:: ymin :type: float .. py:attribute:: xmax :type: float .. py:attribute:: ymax :type: float .. py:attribute:: mytree :type: TreeListCtrl .. py:attribute:: myitem :type: wx.core.TreeItemId .. py:method:: add_value(key: str, value: Union[int, float, bool, str]) Add a value to the properties .. py:method:: get_value(key: str) -> Union[int, float, bool, str] Get a value from the properties .. py:method:: set_color_from_value(key: str, cmap: wolfhece.PyPalette.wolfpalette | matplotlib.colors.Colormap | matplotlib.cm.ScalarMappable, vmin: float = 0.0, vmax: float = 1.0) Set the color from a value .. py:method:: set_alpha(alpha: int) Set the alpha value .. py:method:: set_filled(filled: bool) Set the filled value .. py:method:: buffer(distance: float, resolution: int = 16, inplace: bool = True) -> vector Create a new vector buffered around the vector .. py:method:: set_legend_text(text: str) Set the legend text .. py:method:: set_legend_text_from_value(key: str, visible: bool = True) Set the legend text from a value .. py:method:: set_legend_position(x: str | float, y: str | float) Set the legend position .. py:method:: set_cache() Set the cache for the vertices .. py:method:: clear_cache() Clear the cache for the vertices .. py:method:: move(deltax: float, deltay: float, use_cache: bool = True, inplace: bool = True) Move the vector :param deltax: delta x :param deltay: delta y :param use_cache: use the cache if available :param inplace: move the vector inplace or return a new vector .. py:method:: rotate(angle: float, center: tuple[float, float] = (0.0, 0.0), use_cache: bool = True, inplace: bool = True) Rotate the vector :param angle: angle in degrees :param center: center of the rotation :param use_cache: use the cache if available :param inplace: rotate the vector inplace or return a new vector .. py:method:: rotate_xy(x: float, y: float, use_cache: bool = True, inplace: bool = True) Rotate the vector around the rotation center and a xy point .. py:method:: get_mapviewer() Retourne l'instance de la mapviewer .. py:method:: show_properties() Show the properties .. py:method:: hide_properties() Hide the properties .. py:method:: get_normal_segments() -> numpy.ndarray Return the normals of each segment The normals are oriented to the left .. py:method:: get_center_segments() -> numpy.ndarray Return the center of each segment .. py:method:: import_shapelyobj(obj) Importation d'un objet shapely .. py:method:: get_bounds(grid: float = None) Return tuple with : - (lower-left corner), (upper-right corner) If you want [[xmin,xmax],[ymin,ymax]], use get_bounds_xx_yy() instead. .. py:method:: get_bounds_xx_yy(grid: float = None) Return tuple with : - (xmin,xmax), (ymin, ymax) If you want [[lower-left corner],[upper-right corner]], use get_bounds() instead. .. py:method:: get_mean_vertex(asshapelyPoint=False) Return the mean vertex .. py:method:: highlighting(rgb=(255, 0, 0), linewidth=3) Mise en évidence .. py:method:: withdrawal() Mise en retrait .. py:method:: save(f) Sauvegarde sur disque .. py:method:: reverse() Renverse l'ordre des vertices .. py:method:: isinside(x, y) Teste si la coordonnée (x,y) est dans l'objet -- en 2D .. py:method:: asshapely_pol() -> shapely.geometry.Polygon Conversion des coordonnées en Polygon Shapely .. py:method:: asshapely_pol3D() -> shapely.geometry.Polygon Conversion des coordonnées en Polygon Shapely .. py:method:: asshapely_ls3d() -> shapely.geometry.LineString Conversion des coordonnées en Linestring Shapely .. py:method:: asshapely_ls() -> shapely.geometry.LineString Conversion des coordonnées en Linestring Shapely .. py:method:: asshapely_mp() -> shapely.geometry.MultiPoint Conversion des coordonnées en Multipoint Shapely .. py:method:: asnparray() Conversion des coordonnées en Numpy array -- en 2D return : np.ndarray -- shape = (nb_vert,2) .. py:method:: asnparray3d() Conversion des coordonnées en Numpy array -- en 3D return : np.ndarray -- shape = (nb_vert,3) .. py:method:: prepare_shapely(prepare_shapely: bool = True, linestring: bool = True, polygon: bool = True) Conversion Linestring Shapely et rétention de l'objet afin d'éviter de multiples appel par ex. dans une boucle. :param prepare_shapely: Préparation de l'objet Shapely pour une utilisation optimisée - True par défaut - see https://shapely.readthedocs.io/en/stable/reference/shapely.prepare.html :param linestring: Préparation du linestring :param polygon: Préparation du polygon .. py:method:: projectontrace(trace) Projection du vecteur sur une trace (type 'vector') Return : Nouveau vecteur contenant les infos de position sur la trace et d'altitude (s,z) .. py:method:: parallel_offset(distance=5.0, side='left') The distance parameter must be a positive float value. The side parameter may be ‘left’ or ‘right’. Left and right are determined by following the direction of the given geometric points of the LineString. .. py:method:: intersection(vec2: vector = None, eval_dist=False, norm=False, force_single=False) Calcul de l'intersection avec un autre vecteur Attention, le shapely du vecteur vec2 et self sont automatiquement préparés. Si modifié après intersection, il faut penser à les re-préparer avec self.reset_linestring() ou self.prepare_shapely(). Dans le cas contraire, les anciens vecteurs préparés seront utilisés. Return : - le point d'intersection - la distance (optional) le long de 'self' Utilisation de Shapely .. py:method:: reset() Remise à zéro .. py:method:: reset_linestring() Remise à zéro de l'objet Shapely .. py:method:: add_vertex(addedvert: Union[list[wolfhece.PyVertex.wolfvertex], wolfhece.PyVertex.wolfvertex]) Ajout d'un wolfvertex Le compteur est automatqiuement incrémenté .. py:method:: add_vertices_from_array(xyz: numpy.ndarray) Ajout de vertices depuis une matrice numpy -- shape = (nb_vert,2 ou 3) .. py:method:: count() Retroune le nombre de vertices For compatibility with older version of the code --> use 'nbvertices' property instead Must be removed in the future .. py:method:: close_force() Force la fermeture du 'vector' Commence par vérifier si le premier point possède les mêmes coords que le dernier Si ce n'est pas le cas, on ajoute un wolfvertes self.closed -> True .. py:method:: force_to_close() Force the vector to be closed .. py:method:: _nblines() routine utile pour l'initialisation sur base de 'lines' .. py:method:: verify_s_ascending() Vérifie que les points d'un vecteur sont énumérés par distances 2D croissantes Utile notamment pour le traitement d'interpolation de sections en travers afin d'éviter une triangulation non valable suite à des débords .. py:method:: find_nearest_vert(x, y) Trouve le vertex le plus proche de la coordonnée (x,y) -- en 2D .. py:method:: insert_nearest_vert(x, y) Insertion d'un nouveau vertex au plus proche de la coordonnée (x,y) -- en 2D .. py:method:: find_minmax(only_firstlast: bool = False) Recherche l'extension spatiale du vecteur :param only_firstlast: si True, on ne recherche que les coordonnées du premier et du dernier vertex .. py:method:: get_subpolygons() -> list[list[wolfhece.PyVertex.wolfvertex]] Return a list of polygons from the vector If the vector has no interior, the list contains the whole vector as a polygon .. py:method:: plot(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None) Plot OpenGL .. py:method:: plot_legend(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None) Plot OpenGL Legend is an image texture .. py:method:: plot_legend_mpl(ax: matplotlib.pyplot.Axes) Plot Legend on Matplotlib Axes .. py:method:: plot_image(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None) plot attached images .. py:method:: plot_matplotlib(ax: matplotlib.pyplot.Axes) Plot Matplotlib .. py:method:: _get_textfont() Retunr a 'Text_Infos' instance for the legend .. py:method:: add2tree(tree: TreeListCtrl, root) Ajout de l'objte à un TreeListCtrl wx .. py:method:: unuse() L'objet n'est plus à utiliser .. py:method:: use() L'objet n'est plus à utiliser .. py:method:: fillgrid(gridto: wolfhece.CpGrid.CpGrid) Remplissage d'un CpGrid .. py:method:: updatefromgrid(gridfrom: wolfhece.CpGrid.CpGrid) Mise à jour depuis un CpGrid .. py:method:: get_s2d() -> numpy.ndarray calcul et retour des positions curvilignes 2D .. py:method:: get_s3d() -> numpy.ndarray calcul et retour des positions curvilignes 3D .. py:method:: get_sz(cumul=True) Calcule et retourne la distance horizontale cumulée ou non de chaque point vis-à-vis du premier point Utile pour le tracé de sections en travers ou des vérifications de position :param cumul: si True, retourne la distance cumulée 2D. si False, retourne la distance 2D entre chaque point et le premier. .. py:method:: update_lengths() Mise à jour de la longueur - en 2D - en 3D Retient également les longueurs de chaque segment .. py:method:: get_segment(s, is3D, adim=True, frombegin=True) Retrouve le segment associé aux paramètres passés .. py:method:: _refine2D(ds) Raffine un vecteur selon un pas 'ds' Return : Liste Python avec des Point Shapely .. py:method:: split(ds, new=True) Création d'un nouveau vecteur sur base du découpage d'un autre et d'un pas spatial à respecter Le nouveau vecteur contient tous les points de l'ancien et des nouveaux sur base d'un découpage 3D :param ds: pas spatial :param new: si True, le vecteur est ajouté à la zone parente .. py:method:: interpolate(s, is3D=True, adim=True, frombegin=True) -> wolfhece.PyVertex.wolfvertex Interpolation linéaire à une abscisse curviligne 's' donnée Calcul par défaut : - en 3D - en adimensionnel .. py:method:: substring(s1, s2, is3D=True, adim=True, eps=0.01) Récupération d'une fraction de vector entre 's1' et 's2' Nom similaire à la même opération dans Shapely mais qui ne gère, elle, que le 2D .. py:method:: get_values_linked_polygon(linked_arrays: list, getxy=False) -> dict Retourne les valeurs contenue dans le polygone linked_arrays : liste Python d'objet matriciels WolfArray (ou surcharge) .. py:method:: get_all_values_linked_polygon(linked_arrays, getxy=False) -> dict Retourne toutes les valeurs contenue dans le polygone --> utile au moins pour les résultats WOLF2D linked_arrays : liste Python d'objet matriciels WolfArray (ou surcharge) .. py:method:: get_all_values_linked_polyline(linked_arrays, getxy=True) -> dict Retourne toutes les valeurs sous la polyligne --> utile au moins pour les résultats WOLF2D linked_arrays : liste Python d'objet matriciels WolfArray (ou surcharge) .. py:method:: get_values_on_vertices(curarray) Récupération des valeurs sous les vertices et stockage dans la coordonnée 'z' .. py:method:: get_values_linked(linked_arrays: dict, refine=True, filter_null=False) Récupération des valeurs dans les matrices liées sous les vertices et stockage dans la coordonnée 'z' Possibilité de raffiner la discrétisation pour obtenir au moins une valeur par maille .. py:method:: plot_linked(fig, ax, linked_arrays: dict) Graphique Matplolib de valeurs dans les matrices liées .. py:method:: plot_linked_wx(fig: wolfhece.matplotlib_fig.Matplotlib_Figure, linked_arrays: dict) Graphique Matplolib de valeurs dans les matrices liées. Version pour wxPython .. py:method:: plot_mpl(show=False, forceaspect=True, fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, labels: dict = {}) Graphique Matplolib du vecteur .. py:method:: deepcopy_vector(name: str = None, parentzone=None) -> vector Return a deep copy of the vector. .. py:method:: deepcopy(name: str = None, parentzone=None) -> vector Return a deep copy of the vector. .. py:method:: set_legend_to_centroid(text: str = '', visible: bool = True) Positionne la légende au centre du vecteur .. py:method:: set_legend_position_to_centroid() Positionne la légende au centre du vecteur .. py:method:: set_z(new_z: numpy.ndarray) Set the z values of the vertices .. py:method:: append(other: vector, merge_type: Literal[link, copy] = 'link') Append a vector to the current one .. py:method:: cut(s: float, is3D: bool = True, adim: bool = True, frombegin: bool = True) cut a vector at a given curvilinear abscissa .. py:method:: _reset_listogl() Reset the list of OpenGL display .. py:method:: select_points_inside(xy: wolfhece.PyVertex.cloud_vertices | numpy.ndarray) Select the points inside a polygon :param xy: cloud_vertices or np.ndarray with x,y coordinates :return: list of boolean .. py:method:: split_cloud(cloud_to_split: wolfhece.PyVertex.cloud_vertices) Split a cloud of vertices on the vector .. py:method:: check_if_closed() -> bool Check if the vector is closed .. py:method:: check_if_open() -> bool Check if the vector is open .. py:class:: zone(lines: list[str] = [], name: str = 'NoName', parent: Zones = None, is2D: bool = True, fromshapely: Union[shapely.geometry.LineString, shapely.geometry.Polygon, shapely.geometry.MultiLineString, shapely.geometry.MultiPolygon] = None) Objet de gestion d'informations vectorielles Une instance 'zone' contient une listde de 'vector' (segment, ligne, polyligne, polygone...) .. py:property:: area Compute the area of the zone .. py:property:: areas List of all areas .. py:property:: nbvectors .. py:property:: vector_names :type: list[str] Return the list of vector names .. py:attribute:: myname :type: str .. py:attribute:: nbvectors :type: int .. py:attribute:: myvectors :type: list[vector] .. py:attribute:: xmin :type: float .. py:attribute:: ymin :type: float .. py:attribute:: xmax :type: float .. py:attribute:: ymax :type: float .. py:attribute:: selected_vectors :type: list[tuple[vector, float]] .. py:attribute:: mytree :type: TreeListCtrl .. py:attribute:: myitem :type: wx.core.TreeItemId .. py:method:: add_values(key: str, values: numpy.ndarray) add values to the zone .. py:method:: get_values(key: str) -> numpy.ndarray get values from the zone .. py:method:: set_colors_from_value(key: str, cmap: wolfhece.PyPalette.wolfpalette | matplotlib.colors.Colormap | matplotlib.cm.ScalarMappable, vmin: float = 0.0, vmax: float = 1.0) Set the colors for the zone .. py:method:: set_alpha(alpha: int) Set the alpha for the zone .. py:method:: set_filled(filled: bool) Set the filled for the zone .. py:method:: check_if_open() Check if the vectors in the zone are open .. py:method:: buffer(distance: float, resolution: int = 16, inplace: bool = False) -> zone Create a new zone with a buffer around each vector .. py:method:: set_legend_text(text: str) Set the legend text for the zone .. py:method:: set_legend_text_from_values(key: str) Set the legend text for the zone from a value .. py:method:: set_legend_position(x, y) Set the legend position for the zone .. py:method:: set_cache() Set the cache for the zone and all its vectors .. py:method:: clear_cache() Clear the cache for the zone and all its vectors .. py:method:: move(dx: float, dy: float, use_cache: bool = True, inplace: bool = True) Move the zone and all its vectors .. py:method:: rotate(angle: float, center: tuple[float, float], use_cache: bool = True, inplace: bool = True) Rotate the zone and all its vectors :param angle: angle in degrees (clockwise) :param center: center of rotation :param use_cache: use the cache for the vertices :param inplace: modify the zone in place or return a new one .. py:method:: rotate_xy(x: float, y: float, use_cache: bool = True, inplace: bool = True) Rotate the zone and all its vectors in the xy plane .. py:method:: get_mapviewer() Retourne l'instance de la mapviewer .. py:method:: import_shapelyobj(obj) Importation d'un objet shapely .. py:method:: get_vector(keyvector: Union[int, str]) -> vector Retrouve le vecteur sur base de son nom ou de sa position Si plusieurs vecteurs portent le même nom, seule le premier est retourné .. py:method:: export_shape(fn: str = '') Export to shapefile using GDAL/OGR .. py:method:: save(f: io.TextIOWrapper) Ecriture sur disque .. py:method:: save_extra(f: io.TextIOWrapper) Ecriture des options EXTRA .. py:method:: load_extra(lines: list[str]) -> int Lecture des options EXTRA .. py:method:: add_vector(addedvect: vector, index=-99999, forceparent=False, update_struct=False) Ajout d'une instance 'vector' :param addedvect: instance 'vector' à ajouter :param index: position d'insertion :param forceparent: True = forcer le parent à être la zone dans lequel le vecteur est ajouté .. py:method:: count() Compte le nombre de vecteurs For compatibility with older versions --> Must be removed in future version .. py:method:: _nblines() Utile pour init par 'lines' .. py:method:: find_minmax(update=False, only_firstlast: bool = False) Recherche de l'emprise spatiale de toute la zone :param update: True = mise à jour des valeurs ; False = utilisation des valeurs déjà calculées :param only_firstlast: True = recherche uniquement sur les premiers et derniers points de chaque vecteur .. py:method:: prep_listogl() Préparation des listes OpenGL pour augmenter la vitesse d'affichage .. py:method:: plot(prep: bool = False, sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None) Graphique OpenGL :param prep: True = préparation des listes OpenGL ; False = affichage direct .. py:method:: plot_matplotlib(ax: matplotlib.pyplot.Axes) Plot the zone using matplotlib :param ax: matplotlib Axes :param kwargs: additional arguments .. py:method:: select_vectors_from_point(x: float, y: float, inside=True) Sélection du vecteur de la zone sur base d'une coordonnée (x,y) -- en 2D inside : True = le point est contenu ; False = le point le plus proche .. py:method:: add2tree(tree: TreeListCtrl, root) Ajout à un objet TreeListCtrl .. py:method:: unuse() Ne plus utiliser .. py:method:: use() A utiliser .. py:method:: asshapely_ls() Retroune la zone comme MultiLineString Shaely .. py:method:: prepare_shapely() Converti l'objet en MultiLineString Shapely et stocke dans self.multils .. py:method:: get_selected_vectors(all=False) Retourne la liste du/des vecteur(s) sélectionné(s) .. py:method:: add_parallel(distance) Ajoute une parallèle au vecteur actif .. py:method:: parallel_active(distance) Ajoute une parallèle 'left' et 'right' au vecteur actif .. py:method:: createmultibin(nb=None, nb2=0) -> Triangulation Création d'une triangulation sur base des vecteurs Tient compte de l'ordre :param nb : nombre de points de découpe des vecteurs :param nb2 : nombre de points en perpendiculaire return : - instance de 'Triangulation' .. py:method:: create_tri_crosssection(ds: float = 1.0) -> Triangulation Create a triangulation like cross sections and support vectors .. py:method:: create_constrainedDelaunay(nb=None) -> Triangulation Création d'une triangulation Delaunay contrainte sur base des vecteurs Utilisation de la librairie "triangle" (https://www.cs.cmu.edu/~quake/triangle.delaunay.html) :param nb: nombre de points de découpe des vecteurs (0 pour ne rien redécouper) .. py:method:: createmultibin_proj(nb=None, nb2=0) -> Triangulation Création d'une triangulation sur base des vecteurs par projection au plus proche du vecteur central Tient compte de l'ordre :param nb : nombre de points de découpe des vecteurs :param nb2 : nombre de points en perpendiculaire return : - instance de 'Triangulation' .. py:method:: create_polygon_from_parallel(ds: float, howmanypoly=1) -> None Création de polygones depuis des vecteurs parallèles La zone à traiter ne peut contenir que 3 vecteurs Une zone de résultat est ajouté à l'objet ds : desired size/length of the polygon, adjusted on the basis of a number of polygons rounded up to the nearest integer howmanypoly : Number of transversal polygons (1 = one large polygon, 2 = 2 polygons - one left and one right) .. py:method:: _fill_structure() Mise à jour des structures .. py:method:: create_sliding_polygon_from_parallel(poly_length: float, ds_sliding: float, farthest_parallel: float, interval_parallel: float = None, intersect=None, howmanypoly=1, eps_offset: float = 0.25) Create sliding polygons from a support vector. "poly_length" is the length of the polygons. "ds_sliding" is the sliding length. If "ds_sliding" is lower than "ds", the polygons are overlapping. If "ds_sliding" is greater than "ds", the polygons are separated. If "ds_sliding" is equal to "ds", the polygons are adjacent. The zone to be processed can only contain 1 vector. A result zone is added to the object. The sliding polygons are created on the basis of the left and right parallels of the central vector. "farthest_parallel" is the farthest parallel. "interval_parallel" is the distance between each parallels. If not defined, it is equal to "farthest_parallel". Lateral sides of the polygons are defined by projecting the points/vertices of the support vector onto the parallels, from the nearest to the farthest. The method first creates the parallels. Then, it intersects the parallels with the constraints defined in the "intersect" zone. The intersection is done with an offset defined by "eps_offset". :param poly_length: size/length of the polygon, adjusted on the basis of a number of polygons rounded up to the nearest integer :param ds_sliding: sliding length :param farthest_parallel: position of the parallels :param interval_parallel: parallel intervals (internal computation) :param intersect: zone class containing constraints :param howmanypoly: number of transversal polygons (1 = one large polygon, 2 = 2 polygons - one left and one right) :param eps_offset: space width impose to the "intersect" .. py:method:: get_values_linked_polygons(linked_arrays, stats=True) -> dict Récupération des valeurs contenues dans tous les polygones de la zone Retourne un dictionnaire contenant les valeurs pour chaque polygone Les valeurs de chaque entrée du dict peuvent contenir une ou plusieurs listes en fonction du retour de la fonction de l'objet matriciel appelé .. py:method:: get_all_values_linked_polygon(linked_arrays, stats=True, key_idx_names: Literal[idx, OpenGL.GL.name] = 'idx', getxy=False) -> dict Récupération des valeurs contenues dans tous les polygones de la zone Retourne un dictionnaire contenant les valeurs pour chaque polygone ATTENTION : Il est possible de choisir comme clé soit l'index du vecteur dans la zone, soit non nom Si le nom est choisi, cela peut aboutir à une perte d'information car il n'y a pas de certitude que les noms de vecteur soient uniques --> il est nécessaire que l'utilisateur soit conscient de cette possibilité Les valeurs de chaque entrée du dict peuvent contenir une ou plusieurs listes en fonction du retour de la fonction de l'objet matriciel appelé .. py:method:: _stats_values(vals: dict) Compute statistics on values dict resulting from 'get_values_linked_polygons' .. py:method:: plot_linked_polygons(fig: matplotlib.figure.Figure, ax: matplotlib.axes.Axes, linked_arrays: dict, linked_vec: dict[str, Zones] = None, linestyle: str = '-', onlymedian: bool = False, withtopography: bool = True, ds: float = None) Création d'un graphique sur base des polygones Chaque polygone se positionnera sur base de la valeur Z de ses vertices - façon conventionnelle de définir une longueur - ceci est normalement fait lors de l'appel à 'create_polygon_from_parallel' - si les polygones sont créés manuellement, il faut donc prendre soin de fournir l'information adhoc ou alors utiliser l'rgument 'ds' ATTENTION : Les coordonnées Z ne sont sauvegardées sur disque que si le fichier est 3D, autrement dit au format '.vecz' :param fig: Figure :param ax: Axes :param linked_arrays: dictionnaire contenant les matrices à lier -- les clés sont les labels :param linked_vec: dictionnaire contenant les instances Zones à lier -- Besoin d'une zone et d'un vecteur 'trace/trace' pour convertir les positions en coordonnées curvilignes :param linestyle: style de ligne :param onlymedian: affiche uniquement la médiane :param withtopography: affiche la topographie :param ds: pas spatial le long de l'axe .. py:method:: plot_linked_polygons_wx(fig: wolfhece.matplotlib_fig.Matplotlib_Figure, linked_arrays: dict, linked_vec: dict[str, Zones] = None, linestyle: str = '-', onlymedian: bool = False, withtopography: bool = True, ds: float = None) Création d'un graphique sur base des polygones Chaque polygone se positionnera sur base de la valeur Z de ses vertices - façon conventionnelle de définir une longueur - ceci est normalement fait lors de l'appel à 'create_polygon_from_parallel' - si les polygones sont créés manuellement, il faut donc prendre soin de fournir l'information adhoc ou alors utiliser l'rgument 'ds' ATTENTION : Les coordonnées Z ne sont sauvegardées sur disque que si le fichier est 3D, autrement dit au format '.vecz' :param fig: Figure :param ax: Axes :param linked_arrays: dictionnaire contenant les matrices à lier -- les clés sont les labels :param linked_vec: dictionnaire contenant les instances Zones à lier -- Besoin d'une zone et d'un vecteur 'trace/trace' pour convertir les positions en coordonnées curvilignes :param linestyle: style de ligne :param onlymedian: affiche uniquement la médiane :param withtopography: affiche la topographie :param ds: pas spatial le long de l'axe .. py:method:: reset_listogl() Reset OpenGL lists. Force deletion of the OpenGL list. If the object is newly plotted, the lists will be recreated. .. py:method:: deepcopy_zone(name: str = None, parent: str = None) -> zone Return a deep copy of the zone .. py:method:: deepcopy(name: str = None, parent: str = None) -> zone Return a deep copy of the zone .. py:method:: show_properties() Show properties of the zone --> will be applied to all vectors int he zone .. py:method:: hide_properties() Hide the properties window .. py:method:: _callback_destroy_props() Callback to destroy the properties window .. py:method:: _callback_prop() Callback to update properties .. py:method:: set_legend_to_centroid() Set the legend to the centroid of the vectors .. py:class:: Zones(filename: Union[str, pathlib.Path] = '', ox: float = 0.0, oy: float = 0.0, tx: float = 0.0, ty: float = 0.0, parent=None, is2D=True, idx: str = '', plotted: bool = True, mapviewer=None, need_for_wx: bool = False, bbox: shapely.geometry.Polygon = None, find_minmax: bool = True, shared: bool = False, colors: dict = None) Bases: :py:obj:`wx.dataview.wx.Frame`, :py:obj:`wolfhece.drawing_obj.Element_To_Draw` .. autoapi-inheritance-diagram:: wolfhece.PyVertexvectors.Zones :parts: 1 :private-bases: Objet de gestion d'informations vectorielles Une instance 'Zones' contient une liste de 'zone' Une instance 'zone' contient une listde de 'vector' (segment, ligne, polyligne, polygone...) .. py:property:: mynames :type: list[str] Return the names of all zones .. py:property:: areas List of areas of all zones .. py:property:: nbzones .. py:property:: zone_names :type: list[str] Return the list of zone names .. py:attribute:: tx :type: float .. py:attribute:: ty :type: float .. py:attribute:: myzones :type: list[zone] .. py:attribute:: treelist :type: TreeListCtrl .. py:attribute:: xls :type: wolfhece.CpGrid.CpGrid .. py:method:: add_values(key: str, values: numpy.ndarray | dict) Add values to the zones .. py:method:: get_values(key: str) -> numpy.ndarray Get values from the zones .. py:method:: set_colors_from_value(key: str, cmap: wolfhece.PyPalette.wolfpalette | str | matplotlib.colors.Colormap | matplotlib.cm.ScalarMappable, vmin: float = 0.0, vmax: float = 1.0) Set colors to the zones .. py:method:: set_alpha(alpha: int) Set alpha to the zones .. py:method:: set_filled(filled: bool) Set filled to the zones .. py:method:: check_if_open() Check if the vectors in the zone are open .. py:method:: concatenate_all_vectors() -> list[vector] Concatenate all vectors in the zones .. py:method:: prepare_shapely() Prepare shapely objects for all vectors in zones .. py:method:: filter_contains(others: list[vector]) -> Zones Create a new "Zones" instance with vectors in 'others' contained in the zones .. py:method:: buffer(distance: float, resolution: int = 16, inplace: bool = True) Buffer all zones .. py:method:: set_cache() Set cache for all zones .. py:method:: clear_cache() Clear cache for all zones .. py:method:: move(dx: float, dy: float, use_cache: bool = True, inplace: bool = True) Move all zones .. py:method:: rotate(angle: float, center: shapely.geometry.Point = None, use_cache: bool = True, inplace: bool = True) Rotate all zones .. py:method:: rotate_xy(angle: float, center: shapely.geometry.Point = None, use_cache: bool = True, inplace: bool = True) Rotate all zones .. py:method:: force_unique_zone_name() Check if all zones have a unique id If not, the id will be set to the index of the zone in the list .. py:method:: set_legend_text(text: str) Set the legend text for the zones .. py:method:: set_legend_text_from_values(key: str) Set the legend text for the zones from the values .. py:method:: set_legend_to_centroid() Set the legend to the centroid of the zones .. py:method:: set_legend_position(x, y) Set the legend position for the zones .. py:method:: import_shapefile(fn: str, bbox: shapely.geometry.Polygon = None, colname: str = None) Import shapefile by using geopandas Shapefile == 1 zone .. py:method:: import_GeoDataFrame(content: geopandas.GeoDataFrame, bbox: shapely.geometry.Polygon = None, colname: str = None) Import a GeoDataFrame geopandas Shapefile == 1 zone .. py:method:: export_GeoDataFrame() -> geopandas.GeoDataFrame Export to a GeoDataFrame .. py:method:: export_to_shapefile(filename: str) Export to shapefile. The first vector of each zone will be exported. If you want to export all vectors, you have to use "export_shape" of the zone object. FIXME: Add support of data fields .. py:method:: export_active_zone_to_shapefile(filename: str) Export the active_zone to shapefile. .. py:method:: import_gdb(fn: str, bbox: shapely.geometry.Polygon = None) Import gdb by using geopandas and Fiona .. py:method:: import_gpkg(fn: str, bbox: shapely.geometry.Polygon = None) Import gdb by using geopandas and Fiona .. py:method:: set_mapviewer() Recherche d'une instance WolfMapViewer depuis le parent .. py:method:: colorize_data(colors: dict[str:list[int]], filled: bool = False) -> None Colorize zones based on a dictionary of colors Zone's name must be the key of the dictionary .. py:method:: set_width(width: int) -> None Change with of all vectors in all zones .. py:method:: get_zone(keyzone: Union[int, str]) -> zone Retrouve la zone sur base de son nom ou de sa position Si plusieurs zones portent le même nom, seule la première est retournée .. py:method:: import_dxf(fn, imported_elts=['POLYLINE', 'LWPOLYLINE', 'LINE']) Import d'un fichier DXF en tant qu'objets WOLF .. py:method:: find_nearest_vector(x: float, y: float) -> vector Trouve le vecteur le plus proche de la coordonnée (x,y) .. py:method:: reset_listogl() Reset des listes OpenGL pour toutes les zones .. py:method:: prep_listogl() Préparation des listes OpenGL pour augmenter la vitesse d'affichage .. py:method:: check_plot() L'objet doit être affiché Fonction principalement utile pour l'objet WolfMapViewer et le GUI .. py:method:: uncheck_plot(unload=True) L'objet ne doit pas être affiché Fonction principalement utile pour l'objet WolfMapViewer et le GUI .. py:method:: save() Sauvegarde sur disque, sans remise en cause du nom de fichier .. py:method:: saveas(filename: str = '') Sauvegarde sur disque filename : chemin d'accès potentiellement différent de self.filename si c'est le cas, self.filename est modifié .. py:method:: OnClose(e) Fermeture de la fenêtre .. py:method:: add_zone(addedzone: zone, forceparent=False) Ajout d'une zone à la liste .. py:method:: find_minmax(update=False, only_firstlast: bool = False) Trouve les bornes des vertices pour toutes les zones et tous les vecteurs :param update : si True, force la MAJ des minmax dans chaque zone; si False, compile les minmax déjà présents :param only_firstlast : si True, ne prend en compte que le premier et le dernier vertex de chaque vecteur .. py:method:: plot(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None) Dessine les zones .. py:method:: plot_matplotlib(ax: matplotlib.pyplot.Axes) Plot with matplotlib .. py:method:: select_vectors_from_point(x: float, y: float, inside=True) Sélection de vecteurs dans chaque zones sur base d'une coordonnée --> remplit la liste 'selected_vectors' de chaque zone inside : si True, teste si le point est contenu dans le polygone; si False, sélectionne le vecteur le plus proche .. py:method:: show_properties(parent=None, forceupdate=False) Affichage des propriétés des zones parent : soit une instance 'WolfMapViewer', soit une instance 'Ops_Array' --> est utile pour transférer la propriété 'active_vector' et obtenir diverses informations si parent est d'un autre type, il faut s'assurer que les options/actions sont consistantes .. py:method:: hide_properties() Hide the properties window .. py:method:: showstructure(parent=None, forceupdate=False) Affichage de la structure des zones parent : soit une instance 'WolfMapViewer', soit une instance 'Ops_Array' --> est utile pour transférer la propriété 'active_vector' et obtenir diverses informations si parent est d'un autre type, il faut s'assurer que les options/actions sont consistantes .. py:method:: init_ui() Création de l'interface wx de gestion de l'objet .. py:method:: get_xy_from_sz(event: wx.dataview.wx.Event) Add vertices and their respectives xy coordinates from s and Z entries in the xls grid: - NB: The coordinates of the initial point s= 0 and one other points should be explicitly given in the xls grid. .. py:method:: fill_structure() Remplissage de la structure wx .. py:method:: expand_tree(objzone=None) Développe la structure pour un objet spécifique stocké dans la self.treelist. L'objet peut être une 'zone' ou un 'vector' --> see more in 'fill_structure'. .. py:method:: Oncapture(event: wx.dataview.wx.MouseEvent) Ajoute de nouveaux vertices au vecteur courant Fonctionne par clicks souris via le GUI wx de WolfMapViewer .. py:method:: OnReverse(event: wx.dataview.wx.MouseEvent) Renverse le vecteur courant .. py:method:: OnAddPar(event: wx.dataview.wx.MouseEvent) Ajout d'une parallèle au vecteur courant via le bouton adhoc .. py:method:: OnMove(event: wx.dataview.wx.MouseEvent) Déplacement du vecteur actif .. py:method:: OnMoveZone(event: wx.dataview.wx.MouseEvent) Déplacement de la zone active .. py:method:: OnRotate(event: wx.dataview.wx.MouseEvent) Rotation du vecteur actif .. py:method:: OnRotateZone(event: wx.dataview.wx.MouseEvent) Rotation de la zone active .. py:method:: OncaptureandDynapar(event: wx.dataview.wx.MouseEvent) Ajoute des vertices au vecteur courant et crée des parallèles gauche-droite .. py:method:: Onsascending(e: wx.dataview.wx.MouseEvent) S'assure que les points sont ordonnés avec une distance 2D croissante Retourne un message avec les valeurs modifiées le cas échéant .. py:method:: Onmodify(event: wx.dataview.wx.MouseEvent) Permet la modification interactive de vertex dans le vector actif Premier click : recherche du vertex le plus proche Second click : figer la nouvelle position --> action active jusqu'à sélectionne une autre action ou touche Entrée .. py:method:: Onzoom(event: wx.dataview.wx.MouseEvent) Zoom sur le vecteur actif dans le mapviewer .. py:method:: Onzoomvertex(event: wx.dataview.wx.MouseEvent) Zoom sur le vertex actif dans le mapviewer .. py:method:: Ongetvalues(e: wx.dataview.wx.MouseEvent) Récupère les valeurs dans une matrice --> soit la matrice courante --> soit la matrice active de l'interface parent .. py:method:: Onsurface(e: wx.dataview.wx.MouseEvent) Calcul de la surface du vecteur actif .. py:method:: Ongetvalueslinked(e: wx.dataview.wx.MouseEvent) Récupération des valeurs sous toutes les matrices liées pour le vecteur actif Crée une nouvelle zone contenant une copie du vecteur Le nombre de vertices est conservé .. py:method:: Ongetvalueslinkedandref(e: wx.dataview.wx.MouseEvent) Récupération des valeurs sous toutes les matrices liées pour le vecteur actif Crée une nouvelle zone contenant une copie du vecteur. Le nombre de vertices est adapté pour correspondre au mieux à la matrice de liée et ne pas perdre, si possible, d'information. .. py:method:: Onsaveimages(event: wx.dataview.wx.MouseEvent) Enregistrement d'une image pour tous les vecteurs .. py:method:: Oncreatepolygons(event: wx.dataview.wx.MouseEvent) Création de polygones depuis des paralèles contenues dans la zone active .. py:method:: Oncreateslidingpoly(event: wx.dataview.wx.MouseEvent) Create sliding polygons from a support vector .. py:method:: Oncreatebin(event: wx.dataview.wx.MouseEvent) Création d'un canal sur base de 3 parallèles .. py:method:: Oncreatemultibin(event: wx.dataview.wx.MouseEvent) Création d'une triangulation sur base de plusieurs vecteurs .. py:method:: Oncreatetricrosssection(event: wx.dataview.wx.MouseEvent) Create a tringulation like cross-sections and support vectors .. py:method:: OnconstrainedDelaunay(event: wx.dataview.wx.MouseEvent) Create a constrained Delaunay triangulation from the active zone .. py:method:: Oncreatemultibin_project(event: wx.dataview.wx.MouseEvent) Création d'une triangulation sur base de plusieurs vecteurs Les sommets sont recherchés par projection d'un vecteur sur l'autre .. py:method:: save_images_fromvec(dir='') Sauvegarde d'images des vecteurs dans un répertoire FIXME : pas encore vraiment au point .. py:method:: Oninsert(event: wx.dataview.wx.MouseEvent) Insertion de vertex dans le vecteur courant .. py:method:: Onsplit(event: wx.dataview.wx.MouseEvent) Split le vecteur courant selon un pas spatial déterminé .. py:method:: Onevaluates(event: wx.dataview.wx.MouseEvent) Calcule la position curviligne du vecteur courant Le calcul peut être mené en 2D ou en 3D Remplissage du tableur dans la 5ème colonne .. py:method:: Onupdate_from_sz_support(event: wx.dataview.wx.MouseEvent) Update the active vector from the sz values in the xls grid .. py:method:: update_from_sz_direction(xy1: numpy.ndarray, xy2: numpy.ndarray, sz: numpy.ndarray) Update the active vector from the sz values in the xls grid .. py:method:: update_from_sz_support(vec: vector, sz: numpy.ndarray, dialog_box=True) .. py:method:: evaluate_s(vec: vector = None, dialog_box=True) Calcule la position curviligne du vecteur encodé Le calcul peut être mené en 2D ou en 3D Remplissage du tableur dans la 5ème colonne .. py:method:: Oninterpvec(event: wx.dataview.wx.MouseEvent) Interpole les valeurs Z de l'éditeur sur base des seules valeurs connues, càd autre que vide ou -99999 .. py:method:: Onupdatevertices(event) Mie à jour des vertices sur base du tableur .. py:method:: Onaddrows(event: wx.dataview.wx.MouseEvent) Ajout de lignes au tableur .. py:method:: OnClickadd_zone(event: wx.dataview.wx.MouseEvent) Ajout d'une zone au GUI .. py:method:: OnClickadd_vector(event: wx.dataview.wx.MouseEvent) Ajout d'un vecteur à la zone courante .. py:method:: OnClickduplicate_zone(event: wx.dataview.wx.MouseEvent) Duplication de la zone active .. py:method:: OnClickduplicate_vector(event: wx.dataview.wx.MouseEvent) Duplication du vecteur actif .. py:method:: OnClickdelete_zone(event: wx.dataview.wx.MouseEvent) Suppression de la zone courante .. py:method:: OnClickfindactivate_vector(event: wx.dataview.wx.MouseEvent) Recherche et activation d'un vecteur dans toutes les zones .. py:method:: OnClickfindactivate_vector2(event: wx.dataview.wx.MouseEvent) Recherche et activation d'un vecteur dans la zone courante .. py:method:: get_selected_vectors(all=False) all = True : Récupération et renvoi des vecteurs sélectionnés dans les zones all = False : Récupération et renvoi du vecteur le plus proche .. py:method:: verify_activevec() Vérifie si un vecteur actif est défini, si 'None' affiche un message Return : True if self.active_vector is None False otherwise .. py:method:: verify_activezone() Vérifie si une zone active est définie, si 'None' affiche un message Return : True if self.active_zone is None False otherwise .. py:method:: OnClickdelete_vector(event: wx.dataview.wx.MouseEvent) Suppression du vecteur actif .. py:method:: OnClickup_vector(event: wx.dataview.wx.MouseEvent) Remonte le vecteur actif dans la liste de la zone .. py:method:: OnClickdown_vector(event: wx.dataview.wx.MouseEvent) Descend le vecteur actif dans la liste de la zone .. py:method:: OnClickup_zone(event: wx.dataview.wx.MouseEvent) Remonte la zone active dans la liste de la zones self .. py:method:: OnClickdown_zone(event: wx.dataview.wx.MouseEvent) Descend la zone active dans la liste de la zones self .. py:method:: unuse() Rend inutilisé l'ensemble des zones .. py:method:: use() Rend utilisé l'ensemble des zones .. py:method:: OnCheckItem(event: wx.dataview.wx.MouseEvent) Coche/Décoche un ékement de la treelist .. py:method:: _callback_destroy_props() .. py:method:: _callback_prop() .. py:method:: _edit_all_properties() Show properties of the zone --> will be applied to all vectors int he zone .. py:method:: OnRDown(event: TreeListEvent) Affiche les propriétés du vecteur courant Clicl-droit .. py:method:: OnActivateItem(event: TreeListEvent) Activation d'un élément dans le treelist .. py:method:: Activate_vector(object: vector) Mémorise l'objet passé en argument comme vecteur actif Pousse la même information dans l'objet parent s'il existe .. py:method:: Activate_zone(object: zone) Mémorise l'objet passé en argument comme zone active Pousse la même information dans l'objet parent s'il existe .. py:method:: xls_active_vector() Remplit le tableur .. py:method:: OnEditLabel(event: wx.dataview.wx.MouseEvent) Edition de la clé/label de l'élément actif du treelist .. py:method:: deepcopy_zones(name: str = None) -> Zones Return the deep copy of the current Zones (a new object). .. py:method:: deepcopy(name: str = None) -> Zones Return the deep copy of the current Zones (a new object). .. py:class:: Grid(size: float = 1000.0, ox: float = 0.0, oy: float = 0.0, ex: float = 1000.0, ey: float = 1000.0, parent=None) Bases: :py:obj:`Zones` .. autoapi-inheritance-diagram:: wolfhece.PyVertexvectors.Grid :parts: 1 :private-bases: Grid to draw on the mapviewer. Contains one zone and 3 vectors (gridx, gridy, contour). Each gridx and gridy vector contains vertices forming a continuous line. Contour vector contains 4 vertices forming a closed polyline. Drawing all the elements on the mapviewer allows to draw a grid. Based on spatial extent and resolution. .. py:method:: creategrid(size: float = 100.0, ox: float = 0.0, oy: float = 0.0, ex: float = 1000.0, ey: float = 1000.0)