wolfhece.pyvertexvectors._models

Model-only base classes for PyVertexvectors (no wx, no OpenGL dependency).

Author: HECE - University of Liege, Pierre Archambeau Date: 2024-2026

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.

Provides

GUI/OpenGL subclasses live in wolfhece.PyVertexvectors.

Module Contents

class wolfhece.pyvertexvectors._models.VectorOGLRenderer(*args, **kwds)[source]

Bases: enum.Enum

Inheritance diagram of wolfhece.pyvertexvectors._models.VectorOGLRenderer

Rendering backend for vector objects.

LIST = 0[source]
SHADER = 1[source]
class wolfhece.pyvertexvectors._models.TriangulationModel(fn: str = '', pts=None, tri=None, idx: str = '')[source]

Pure-data triangulation: vertices, triangles, I/O, transforms.

Holds arrays of points and triangle indices and provides geometry operations, file reading/writing, and coordinate transformations without any OpenGL or wx dependency.

The GUI subclass Triangulation adds Element_To_Draw integration, OpenGL display lists, and matplotlib plotting helpers.

filename = ''[source]
idx = ''[source]
tri = None[source]
pts = None[source]
_used_tri[source]
_move_start = None[source]
_move_step = None[source]
_rotation_center = None[source]
_rotation_step = None[source]
_cache = None[source]
property nb_tri: int[source]

Return the number of triangles.

property nb_pts: int[source]

Return the number of points.

validate_format()[source]

Force pts and tri to numpy arrays.

as_polydata() pyvista.PolyData[source]

Convert the triangulation to a PyVista PolyData object.

from_polydata(poly: pyvista.PolyData)[source]

Populate from a PyVista PolyData object.

clip_surface(other: TriangulationModel, invert=True, subdivide=0)[source]

Clip the triangulation with another one.

get_mask(eps: float = 1e-10)[source]

Return a boolean mask where triangle area ≤ eps.

_get_polygons() list[shapely.geometry.Polygon][source]

Get a list of Shapely polygons from each triangle.

unuse_triangles_containing_points(points: list[shapely.geometry.Point])[source]

Mark triangles containing any of points as unused.

get_triangles_as_listwolfvertices(used_only: bool = True) list[list[wolfhece.PyVertex.wolfvertex]][source]

Return triangles as lists of wolfvertex.

find_minmax(force)[source]

Compute bounding box from point coordinates.

Parameters:

force – if True, always recompute.

set_cache()[source]

Snapshot current points for cached transformations.

clear_cache()[source]

Discard cached point snapshot.

move(delta_x: float, delta_y: float, use_cache: bool = True)[source]

Translate all points by (delta_x, delta_y).

Parameters:
  • delta_x – delta x [m]

  • delta_y – delta y [m]

rotate(angle: float, center: tuple | wolfhece.PyVertex.wolfvertex, use_cache: bool = True)[source]

Rotate all points around center.

Parameters:
  • angle – angle in degrees — positive for clockwise rotation.

  • center – centre of rotation.

rotate_xy(x: float, y: float, use_cache: bool = True)[source]

Rotate around _rotation_center toward (x, y).

copy() TriangulationModel[source]

Return a deep copy of the triangulation.

import_from_gltf(fn: str = '')[source]

Import a GLTF/GLB file.

Parameters:

fn – path to the .glb or .gltf file (required).

Raises:

ValueError – if fn is empty.

export_to_gltf(fn: str = '') str[source]

Export the triangulation to a GLTF/GLB file.

Parameters:

fn – path to the output file (required).

Raises:

ValueError – if fn is empty.

Returns:

the path written to.

saveas(fn: str = '')[source]

Write the triangulation to a binary .TRI file.

Binary layout (little-endian):
  • int32 number_of_points

  • int32 64 or 32 (float64 / float32 flag)

  • VEC3 points (float64 or float32)

  • int32 number_of_triangles

  • VEC3 triangle indices (uint32)

read(fn: str)[source]

Read a binary .TRI, .dxf, or .gltf/.glb file.

After reading, validate_format() and find_minmax() are called automatically.

import_dxf(fn: str)[source]

Import 3DFACE entities from a DXF file.

class wolfhece.pyvertexvectors._models.vectorpropertiesModel(lines: list[str] = None, parent=None)[source]

Pure-data vector properties: colors, widths, legend, persistence.

Stores all visual/styling attributes for a vector and handles file I/O (save / load) without any wx or OpenGL dependency.

The GUI subclass vectorproperties adds Wolf_Param dialog creation, genericImagetexture management, and property-editing callbacks.

used: bool[source]
color: int[source]
width: int[source]
style: int[source]
alpha: int[source]
closed: bool[source]
filled: bool[source]
legendvisible: bool[source]
transparent: bool[source]
flash: bool[source]
legendtext: str[source]
legendrelpos: int[source]
legendx: float[source]
legendy: float[source]
legendbold: bool[source]
legenditalic: bool[source]
legendunderlined: bool[source]
legendfontname: str[source]
legendfontsize: int[source]
legendcolor: int[source]
extrude: bool[source]
parent = None[source]
plot_indices = False[source]
plot_lengths = False[source]
_values[source]
add_values(values: dict)[source]

Merge a mapping of values into the internal storage.

set_shared_values(shared_values: dict)[source]

Attach an existing values mapping by reference.

This is useful when multiple vectors must share identical attribute values (e.g. split parts of a multipart geometry).

value_keys() set[source]

Return the set of stored value keys.

values_dict() dict[source]

Return a shallow copy of stored values.

values_view() dict[source]

Return the internal values mapping for read-only access.

Callers must not mutate the returned dictionary directly.

_parse_width_profile(raw) list | None[source]

Convert a width profile string to a list or None.

Two formats are accepted:

  • Dense CSV"1.0,1.5,2.0" — one multiplier per vertex, stored as list[float].

  • Sparse"0:1.0,10:2.0,20:0.5"index:value pairs, stored as list[tuple[int, float]]. Unspecified vertices are filled by linear interpolation (constant beyond the endpoints).

Both formats are auto-detected from the presence of : tokens.

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)[source]

Derive the drawing color from a stored value and a colormap.

set_color(color: int | wolfhece.color_constants.RGB | str | list | tuple)[source]

Set the drawing color from various input formats.

init_extra()[source]

Initialise extra properties not part of the VB6/Fortran format.

get_extra() list[source]

Return extra properties as a serialisable list.

set_extra(linesextra: list = None)[source]

Restore extra properties from a serialised list.

load_extra(lines: list[str]) int[source]

Load extra properties from file lines, return number consumed.

save_extra(f: io.TextIOWrapper)[source]

Write extra properties to an already-opened text file.

save(f: io.TextIOWrapper)[source]

Write properties in VB6/Fortran-compatible format.

property image_path: pathlib.Path[source]

Path of the attached image.

_convert_fontname2int(fontname: str) int[source]
_convert_int2fontname(id: int) str[source]
egalize(other)[source]

Copy visual attributes from another properties object or vector.

update_myprops()[source]

No-op in model. GUI subclass populates the Wolf_Param dialog.

update_image_texture()[source]

No-op in model. GUI subclass updates texture coordinates.

class wolfhece.pyvertexvectors._models.vectorModel(lines: list = [], is2D=True, name='NoName', parentzone: zoneModel = None, fromshapely=None, fromnumpy: numpy.ndarray = None, fromlist: list = None)[source]

Pure-data vector: vertices, properties, geometry, I/O.

Holds a list of wolfvertex and a vectorpropertiesModel, plus geometry helpers (shapely, interpolation, etc.) without any OpenGL, wx, or matplotlib dependency.

GUI subclass vector in wolfhece.PyVertexvectors adds plotting, tree-widget integration and OpenGL display-list support.

myname: str[source]
parentzone: zoneModel[source]
myvertices: list[wolfhece.PyVertex.wolfvertex][source]
myprop: vectorpropertiesModel[source]
xmin: float[source]
ymin: float[source]
xmax: float[source]
ymax: float[source]
is2D = True[source]
_mylimits = None[source]
length2D = None[source]
length3D = None[source]
_lengthparts2D = None[source]
_lengthparts3D = None[source]
_normals = None[source]
_center_segments = None[source]
_simplified_geometry = False[source]
_cache_vertices = None[source]
_move_start = None[source]
_move_step = None[source]
_rotation_center = None[source]
_rotation_step = None[source]
_linestring = None[source]
_polygon = None[source]
_vertex_kdtree = None[source]
_vertex_kdtree_xy = None[source]
zdatum = 0.0[source]
add_zdatum = False[source]
sdatum = 0.0[source]
add_sdatum = False[source]
_make_properties(*args, **kwargs) vectorpropertiesModel[source]

Create a properties object. GUI subclass returns vectorproperties.

_make_vector(**kwargs) vectorModel[source]

Create a sibling vector. GUI subclass returns vector.

_make_zone(**kwargs) zoneModel[source]

Create a sibling zone. GUI subclass returns zone.

classmethod make_from_shapely(shapelyobj, **kwargs) vectorModel[source]

Factory method to create a vector from a Shapely geometry.

classmethod make_from_numpy(array: numpy.ndarray, **kwargs) vectorModel[source]

Factory method to create a vector from a NumPy array of shape (N, 2) or (N, 3).

classmethod make_from_list(lst: list, **kwargs) vectorModel[source]

Factory method to create a vector from a list of coordinate tuples.

_on_vertices_changed()[source]

Hook called when vertices are modified.

Invalidates the cached Shapely geometries. The GUI subclass overrides this (calling super()) to also invalidate the parent zone’s OpenGL display list.

property closed: bool[source]

Whether the vector is closed (first vertex == last vertex).

property nbvertices: int[source]

Number of vertices in the vector.

property used: bool[source]

Whether the vector is marked as used/active.

property polygon: shapely.geometry.Polygon[source]

Shapely Polygon built from the vertices (lazily created).

property linestring: shapely.geometry.LineString[source]

Shapely LineString built from the vertices (lazily created).

property has_interior: bool[source]

Whether any vertex is flagged as not in use, indicating interior boundaries.

property nb_interiors: int[source]

Number of interior boundaries (holes) derived from unused vertices.

property centroid: shapely.geometry.Point[source]

Centroid of the polygon formed by the vertices (Shapely Point).

property surface: float[source]

Area of the polygon (0 if the vector is not closed).

property area: float[source]

Alias for :pyattr:`surface`.

property z: numpy.ndarray[source]

Z coordinates of all vertices as a 1-D array.

If add_zdatum is True, the zdatum offset is added.

property x: numpy.ndarray[source]

X coordinates of all vertices as a 1-D array.

property y: numpy.ndarray[source]

Y coordinates of all vertices as a 1-D array.

property xy: numpy.ndarray[source]

XY coordinates as a (N, 2) array.

property xz: numpy.ndarray[source]

XZ coordinates as a (N, 2) array.

property xyz: numpy.ndarray[source]

XYZ coordinates as a (N, 3) array (respects zdatum).

property i: numpy.ndarray[source]

In-use flags of all vertices as a 1-D boolean array.

property xyzi: numpy.ndarray[source]

XYZI coordinates as a (N, 4) array (x, y, z, in_use).

property xyi: numpy.ndarray[source]

XYI coordinates as a (N, 3) array (x, y, in_use).

property sz_curvi: tuple[numpy.ndarray, numpy.ndarray][source]

Tuple (s, z) of curvilinear abscissa and altitude arrays.

property s_curvi: numpy.ndarray[source]

Curvilinear abscissa (cumulative 2-D distance from first vertex).

add_value(key: str, value: int | float | bool | str)[source]

Store an arbitrary key/value pair in the vector properties.

Parameters:
  • key – Property key.

  • value – Property value.

get_value(key: str) int | float | bool | str[source]

Retrieve a stored property value by key.

Parameters:

key – Property key.

Returns:

The stored value.

set_color_from_value(key: str, cmap: wolfhece.PyPalette.wolfpalette | matplotlib.colors.Colormap | matplotlib.cm.ScalarMappable, vmin: float = 0.0, vmax: float = 1.0)[source]

Set the vector colour from a stored property value using a colormap.

Parameters:
  • key – Property key whose numeric value drives the colour.

  • cmap – Colour map (wolfpalette, Matplotlib Colormap, or ScalarMappable).

  • vmin – Minimum value for colour mapping.

  • vmax – Maximum value for colour mapping.

set_color(color: int | wolfhece.color_constants.RGB | str | list | tuple)[source]

Set the vector rendering colour.

Parameters:

color – Colour as an integer, RGB instance, name string, or (r, g, b) tuple/list.

set_linewidth(linewidth: int | float)[source]

Set the rendering line width.

Parameters:

linewidth – Line width in pixels.

set_alpha(alpha: int)[source]

Set the transparency level.

Parameters:

alpha – Alpha value (0 = fully transparent, 255 = opaque).

set_filled(filled: bool)[source]

Enable or disable polygon filling.

Parameters:

filledTrue to render as a filled polygon.

set_props_from_other(other)[source]

Copy visual properties from another vector’s properties.

Parameters:

other – Source vectorpropertiesModel instance.

set_legend_text(text: str)[source]
set_legend_color(color: int | wolfhece.color_constants.RGB | str | list | tuple)[source]
set_legend_text_from_value(key: str, visible: bool = True)[source]

Set the legend text from a stored property value.

Parameters:
  • key – Property key whose value becomes the label.

  • visible – Whether to make the legend visible.

set_legend_position(x: str | float, y: str | float)[source]

Set the legend display position.

Parameters:
  • x – X position as a float or keyword (‘median’, ‘mean’, ‘min’, ‘max’, ‘first’, ‘last’).

  • y – Y position as a float or keyword (same options as x).

set_legend_to_centroid(text: str = '', visible: bool = True)[source]

Place the legend at the polygon centroid.

Parameters:
  • text – Legend text (defaults to the vector name).

  • visible – Whether to make the legend visible.

set_legend_visible(visible: bool = True)[source]

Show or hide the legend.

Parameters:

visibleTrue to display the legend.

set_legend_position_to_centroid()[source]

Move the legend position to the polygon centroid.

set_glow(enabled: bool = True, width: float = 0.4, color: tuple = (1.0, 1.0, 1.0), alpha: float = 0.4)[source]

Configure line glow effect.

Parameters:
  • enabled – Enable or disable glow.

  • width – Glow width as fraction of half-width (0–1).

  • color – RGB colour tuple with components in [0, 1].

  • alpha – Glow opacity in [0, 1].

set_dash(enabled: bool = True, dash_length: float = 10.0, gap_length: float = 5.0)[source]

Configure dashed line rendering.

Parameters:
  • enabled – Enable or disable dashes.

  • dash_length – Dash length in world units.

  • gap_length – Gap length in world units.

set_animation(mode: int = 1, speed: float = 1.0)[source]

Configure line animation.

Parameters:
  • mode – Animation mode (0=none, 1=pulse, 2=marching ants).

  • speed – Speed multiplier.

set_fill_animation(mode: int = 1, speed: float = 1.0, center_index: int = 0, start_angle: float = 90.0)[source]

Configure filled-polygon animation.

Parameters:
  • mode – Animation mode (0=none, 1=pulse, 2=sweep, 3=ripple, 4=radial progressive, 5=clockwise clock, 6=counter-clockwise clock).

  • speed – Speed multiplier.

  • center_index – Vertex index used as the radial/clock centre.

  • start_angle – Clock fill start angle in degrees.

set_fill_color(color=None)[source]

Set the independent fill colour for filled polygons.

Parameters:

color – RGB tuple (r, g, b) with values in [0, 255], packed int, or None to inherit the vector’s main colour.

set_contour_color(color=None, width: float = 1.0, enabled: bool = True)[source]

Set the contour/stroke colour for filled polygons.

Activates a second polyline pass drawn on top of the filled area. Set enabled=False or color=None to disable the contour.

Parameters:
  • color – RGB tuple (r, g, b) with values in [0, 255], packed int, or None to inherit the vector’s main colour.

  • width – Contour line width (same unit as the vector width).

  • enabled – Whether to draw the contour pass at all.

set_join_style(style: int = 0, size: float = 0.5, size_mode: int = 0)[source]

Configure join rendering at polyline corners.

Parameters:
  • style – Join style (0=miter, 1=bevel, 2=round, 3=fillet).

  • size – Join size (fraction or world distance depending on size_mode).

  • size_mode – 0=fraction (adimensional), 1=world distance (metres).

set_width_in_pixels(pixels: bool = True)[source]

Toggle pixel-based vs world-unit line width.

Parameters:

pixelsTrue for pixel widths, False for world units.

set_text_along(text: str, enabled: bool = True, offset: float = 0.0, perp: float = 0.0, alignment: str = 'center')[source]

Configure text displayed along the polyline.

Parameters:
  • text – Text to render along the path.

  • enabled – Enable or disable text-along.

  • offset – Shift start along the polyline (world units).

  • perp – Perpendicular offset (world units, + left).

  • alignment – Text alignment (‘left’, ‘center’, ‘right’).

set_legend_glow(enabled: bool = True, width: float = 0.15, color: tuple = (1.0, 1.0, 1.0), alpha: float = 0.5)[source]

Configure legend text glow effect.

Parameters:
  • enabled – Enable or disable legend glow.

  • width – SDF threshold offset (e.g. 0.15).

  • color – RGB colour tuple with components in [0, 1].

  • alpha – Glow opacity in [0, 1].

set_legend_animation(mode: int = 1, speed: float = 1.0)[source]

Configure legend text animation.

Parameters:
  • mode – Animation mode (0=none, 1=pulse, 2=wave, 3=typewriter).

  • speed – Speed multiplier.

set_legend_style(smoothing: float = 1.0, alignment: str = 'left', line_spacing: float = 1.2)[source]

Fine-tune legend SDF text rendering.

Parameters:
  • smoothing – SDF anti-aliasing multiplier.

  • alignment – Text alignment (‘left’, ‘center’, ‘right’).

  • line_spacing – Multiline spacing multiplier.

highlighting(rgb=(255, 0, 0), linewidth=3)[source]

Highlight the vector with a temporary colour and line width.

Parameters:
  • rgb – Highlight colour as (r, g, b) tuple.

  • linewidth – Highlight line width.

withdrawal()[source]

Restore the colour and line width saved by :pymeth:`highlighting`.

add_vertex(addedvert: list[wolfhece.PyVertex.wolfvertex] | wolfhece.PyVertex.wolfvertex)[source]

Append one or more vertices.

Parameters:

addedvert – A single wolfvertex or a list of vertices to append.

add_vertices_from_array(xyz: numpy.ndarray)[source]

Append vertices from a NumPy array.

Parameters:

xyz(N, 2) or (N, 3) array of coordinates.

add_vertices_from_list(xyz: list)[source]

Append vertices from a list of coordinate tuples.

Parameters:

xyz – List of (x, y) or (x, y, z) tuples.

import_shapelyobj(obj)[source]

Replace vertices from a Shapely LineString or Polygon.

Parameters:

obj – Shapely geometry object.

count()[source]
close_force()[source]

Close the vector by appending the first vertex if needed.

force_to_close()[source]

Alias for :pymeth:`close_force`.

reverse()[source]

Reverse the order of vertices in-place.

reset()[source]

Remove all vertices and reset caches.

append(other: vectorModel, merge_type: Literal['link', 'copy'] = 'link')[source]

Append vertices from another vector.

Parameters:
  • other – Source vector.

  • merge_type‘link’ to share vertex references, ‘copy’ for deep copies.

_set_limits()[source]

Compute and store the bounding-box limits.

_nblines()[source]
save(f)[source]

Write the vector definition (name, vertices, properties) to an open file.

Parameters:

f – Writable text file handle.

set_z(new_z: numpy.ndarray)[source]

Deprecated — use the z property setter instead.

set_cache()[source]

Cache the current vertex coordinates and bounds for incremental transforms.

clear_cache()[source]

Clear the cached vertex coordinates and bounds.

move(deltax: float, deltay: float, use_cache: bool = True, inplace: bool = True)[source]

Translate the vector.

Parameters:
  • deltax – Displacement along X.

  • deltay – Displacement along Y.

  • use_cache – Use cached coordinates for incremental moves.

  • inplace – Modify in place; if False return a moved copy.

Returns:

The moved vector (self or a new copy).

rotate(angle: float, center: tuple[float, float] = (0.0, 0.0), use_cache: bool = True, inplace: bool = True)[source]

Rotate the vector around a centre point.

Parameters:
  • angle – Rotation angle in degrees.

  • center – Centre of rotation (x, y).

  • use_cache – Use cached coordinates for incremental rotations.

  • inplace – Modify in place; if False return a rotated copy.

Returns:

The rotated vector (self or a new copy).

rotate_xy(x: float, y: float, use_cache: bool = True, inplace: bool = True)[source]
get_mapviewer()[source]

Return the parent map-viewer widget, or None.

find_minmax(only_firstlast: bool = False)[source]

Compute the bounding box of the vertices.

Parameters:

only_firstlast – If True, consider only the first and last vertex.

update_image_texture()[source]

Synchronise the image-texture bounds with the current bounding box.

get_bounds(grid: float = None)[source]

Return the bounding box as ((xmin, ymin), (xmax, ymax)).

Parameters:

grid – If given, snap bounds to the nearest grid step.

get_bounds_xx_yy(grid: float = None)[source]

Return the bounding box as ((xmin, xmax), (ymin, ymax)).

Parameters:

grid – If given, snap bounds to the nearest grid step.

intersects_bounds(xmin: float = None, ymin: float = None, xmax: float = None, ymax: float = None) bool[source]

Return whether the vector bounding box intersects the given bbox.

If bounds are not provided, the vector is considered intersecting. Sentinel unset bounds are treated as intersecting to avoid false negatives.

get_mean_vertex(asshapelyPoint=False)[source]

Return the mean position of all vertices.

Parameters:

asshapelyPoint – If True, return a Shapely Point; otherwise a wolfvertex.

isinside(x: float, y: float) bool[source]

Test whether the point (x, y) is inside the polygon.

Parameters:
  • x – X coordinate.

  • y – Y coordinate.

contains(x: float, y: float) bool[source]

Alias for :pymeth:`isinside`.

_invalidate_spatial_index()[source]

Drop cached spatial indices built from the current vertices.

_get_vertex_kdtree()[source]

Return the lazy-built KDTree used for nearest-vertex queries.

_get_nearest_search_geometry()[source]

Return the geometry used for nearest-geometry queries.

distance_to_geometry(x: float, y: float) float[source]

Return the distance from (x, y) to the vector geometry.

find_nearest_vertex(x, y) wolfhece.PyVertex.wolfvertex[source]

Return the vertex nearest to (x, y).

Parameters:
  • x – X coordinate.

  • y – Y coordinate.

insert_nearest_vert(x, y) wolfhece.PyVertex.wolfvertex[source]

Insert a new vertex at (x, y) between the two nearest existing vertices.

Parameters:
  • x – X coordinate of the new vertex.

  • y – Y coordinate of the new vertex.

Returns:

The inserted wolfvertex.

insert_vertex_at_s(s: float, z: float = None, tolerance: float = 0.001) wolfhece.PyVertex.wolfvertex[source]

Insert a vertex at curvilinear abscissa s.

Parameters:
  • s – Distance along the linestring.

  • z – Optional Z value for the new vertex.

  • tolerance – Distance threshold to reuse an existing vertex.

Returns:

The inserted (or reused) vertex.

project_vertex_onto_vector_and_insert(xy: shapely.geometry.Point | wolfhece.PyVertex.wolfvertex, tolerance: float = 0.001) wolfhece.PyVertex.wolfvertex[source]

Project a point onto the linestring and insert a new vertex there.

Parameters:
  • xy – Point to project (Shapely Point or wolfvertex).

  • tolerance – Distance threshold to reuse an existing vertex.

Returns:

The inserted (or reused) vertex.

get_normal_segments(update: bool = False) numpy.ndarray[source]

Return outward unit normals for each segment as a (N-1, 2) array.

Parameters:

update – Force recomputation even if cached.

get_center_segments(update: bool = False) numpy.ndarray[source]

Return segment mid-points as a (N-1, 2) array.

Parameters:

update – Force recomputation even if cached.

select_points_inside(xy: wolfhece.PyVertex.cloud_vertices | numpy.ndarray) list[bool][source]

Return a list of booleans indicating which points are inside the polygon.

Parameters:

xycloud_vertices or (N, 2) array of XY coordinates.

get_first_point_inside(xy: wolfhece.PyVertex.cloud_vertices | numpy.ndarray)[source]

Return the first point that lies inside the polygon.

Parameters:

xycloud_vertices or (N, 2) array of XY coordinates.

Returns:

(x, y) tuple or None.

split_cloud(cloud_to_split: wolfhece.PyVertex.cloud_vertices)[source]

Split a point cloud into inside and outside subsets.

Parameters:

cloud_to_split – Point cloud to partition.

Returns:

(cloud_inside, cloud_outside) tuple.

check_if_closed() bool[source]

Return True if the vector is geometrically closed.

check_if_open() bool[source]

Return True if the vector is open; also updates self.closed.

check_if_interior_exists()[source]

Detect repeated XY coordinates and flag them as interior (in_use = False).

asshapely_pol() shapely.geometry.Polygon[source]

Convert vertex list to a Shapely 2-D Polygon.

asshapely_pol3D() shapely.geometry.Polygon[source]

Convert vertex list to a Shapely 3-D Polygon.

asshapely_ls3d() shapely.geometry.LineString[source]

Convert vertex list to a Shapely 3-D LineString.

asshapely_ls() shapely.geometry.LineString[source]

Convert vertex list to a Shapely 3-D LineString (returns empty if < 2 vertices).

asshapely_mp() shapely.geometry.MultiPoint[source]

Convert vertex list to a Shapely MultiPoint.

asnparray() numpy.ndarray[source]

Return vertices as a (N, 2) NumPy array of (x, y).

asnparray3d() numpy.ndarray[source]

Return vertices as a (N, 3) NumPy array of (x, y, z) (respects zdatum).

prepare_shapely(prepare_shapely: bool = True, linestring: bool = True, polygon: bool = True)[source]

Build and optionally prepare Shapely linestring and/or polygon geometries.

Parameters:
  • prepare_shapely – Whether to call Shapely prepare() for faster operations.

  • linestring – Build the linestring geometry.

  • polygon – Build the polygon geometry.

reset_linestring()[source]

Destroy cached Shapely linestring and polygon (with prepared versions).

intersection(vec2: vectorModel = None, eval_dist=False, norm=False, force_single=False)[source]

Compute the intersection with another vector.

Parameters:
  • vec2 – Other vector to intersect with.

  • eval_dist – Also return projected distance(s) on this linestring.

  • norm – Normalise distances to [0, 1].

  • force_single – If multi-result, keep only the first geometry.

Returns:

Intersection geometry, or (geom, dist) when eval_dist is True.

intersects(x: float, y: float) bool[source]

Test whether the linestring intersects the point (x, y).

Parameters:
  • x – X coordinate.

  • y – Y coordinate.

aligned_with(x: float, y: float, tolerance: float = 1e-06) bool[source]

Test whether the point (x, y) lies on the linestring within tolerance.

Parameters:
  • x – X coordinate.

  • y – Y coordinate.

  • tolerance – Distance tolerance.

buffer(distance: float, resolution: int = 16, inplace: bool = True) vectorModel[source]

Return the buffered polygon.

Parameters:
  • distance – Buffer distance.

  • resolution – Number of segments to approximate a quarter-circle.

  • inplace – Modify this vector; if False return a new one.

projectontrace(trace: vectorModel) vectorModel[source]

Project each vertex onto a trace and return a new 2-D vector (s, z).

Parameters:

trace – Reference trace vector.

Returns:

New vector with (s, z) coordinates.

parallel_offset(distance=5.0, side: Literal['left', 'right'] = 'left') vectorModel | None[source]

Create a parallel offset of the linestring.

Parameters:
  • distance – Offset distance.

  • side – Side of the offset (‘left’ or ‘right’).

Returns:

New vector or None on failure.

verify_s_ascending() tuple[bool, list[int]][source]

Check and fix non-ascending curvilinear abscissae by swapping vertices.

Returns:

(correction_applied, list_of_corrected_indices).

get_s2d() numpy.ndarray[source]

Return cumulative 2-D curvilinear distances from the first vertex.

get_s3d() numpy.ndarray[source]

Return cumulative 3-D curvilinear distances from the first vertex.

get_sz(cumul=True) tuple[numpy.ndarray, numpy.ndarray][source]

Return (s, z) arrays of curvilinear abscissa and altitude.

Parameters:

cumul – If True, cumulative inter-vertex distance; otherwise direct distance from the first vertex.

update_lengths()[source]

Recompute 2-D and 3-D segment lengths and total lengths.

get_segment(s, is3D, adim=True, frombegin=True)[source]

Find the segment containing the curvilinear abscissa s.

Parameters:
  • s – Curvilinear abscissa.

  • is3D – Use 3-D lengths.

  • adim – If True, s is normalised to [0, 1].

  • frombegin – Search from the beginning; if False, from the end.

Returns:

(segment_index, cumulative_s, lengthparts).

interpolate(s: float, is3D: bool = True, adim: bool = True, frombegin: bool = True) wolfhece.PyVertex.wolfvertex[source]

Interpolate a point along the polyline at curvilinear abscissa s.

Parameters:
  • s – Curvilinear abscissa.

  • is3D – Use 3-D lengths.

  • adim – If True, s is normalised to [0, 1].

  • frombegin – Search from the beginning.

Returns:

An interpolated wolfvertex.

tangent_at_s(s: float, is3D: bool = True, adim: bool = True, frombegin: bool = True) wolfhece.PyVertex.wolfvertex[source]

Return the unit tangent vector at curvilinear abscissa s.

Parameters:
  • s – Curvilinear abscissa.

  • is3D – Use 3-D lengths.

  • adim – Normalised abscissa.

  • frombegin – Search direction.

normal_at_s(s: float, is3D: bool = True, adim: bool = True, frombegin: bool = True, counterclockwise=True) wolfhece.PyVertex.wolfvertex[source]

Return the unit normal vector at curvilinear abscissa s.

Parameters:
  • s – Curvilinear abscissa.

  • is3D – Use 3-D lengths.

  • adim – Normalised abscissa.

  • frombegin – Search direction.

  • counterclockwise – Normal orientation.

_refine2D(ds)[source]

Refine the polyline in 2-D with a target spacing ds.

Parameters:

ds – Maximum distance between interpolated points.

Returns:

List of Shapely Point objects.

substring(s1: float, s2: float, is3D: bool = True, adim: bool = True, eps: float = 0.01) vectorModel[source]

Extract a sub-vector between curvilinear abscissae s1 and s2.

Parameters:
  • s1 – Start curvilinear abscissa.

  • s2 – End curvilinear abscissa.

  • is3D – Use 3-D lengths.

  • adim – Normalised abscissae.

  • eps – Minimum length offset when s1 == s2.

Returns:

New sub-vector.

split(ds, new=True)[source]

Split the vector by inserting vertices at regular 3-D spacing ds.

Parameters:
  • ds – Target 3-D spacing.

  • new – If True, add the new vector to the parent zone; otherwise replace vertices in place.

cut(s: float, is3D: bool = True, adim: bool = True, frombegin: bool = True) vectorModel[source]

Cut the vector at curvilinear abscissa s and return the detached part.

Parameters:
  • s – Curvilinear abscissa of the cut.

  • is3D – Use 3-D lengths.

  • adim – Normalised abscissa.

  • frombegin – Cut direction.

Returns:

New vector containing the cut-off portion.

simplify(tolerance: float = 1.0, preserve_topology: bool = True) vectorModel[source]

Simplify the geometry using Shapely’s Douglas-Peucker algorithm.

Parameters:
  • tolerance – Distance tolerance for simplification.

  • preserve_topology – Prevent self-intersections.

Returns:

New simplified vector.

deepcopy_vector(name: str = None, parentzone=None) vectorModel[source]

Return a deep copy of this vector.

Parameters:
  • name – Name for the copy (defaults to <name>_copy).

  • parentzone – Optional parent zone for the copy.

deepcopy(name: str = None, parentzone=None) vectorModel[source]

Alias for :pymeth:`deepcopy_vector`.

property _parts: zoneModel[source]

Split the vector into sub-parts based on in-use flags.

Vertices flagged as not in use act as separators between parts. The first part is always closed.

get_subpolygons() list[list[wolfhece.PyVertex.wolfvertex]][source]

Return triangulated sub-polygons for rendering, handling interiors.

Returns:

List of vertex lists, each forming a triangle or polygon.

static _fillet_polyline(xs: numpy.ndarray, ys: numpy.ndarray, ws: numpy.ndarray, join_size: float, join_size_mode: int, is_closed: bool, n_subdiv: int = 8) tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray][source]

Replace sharp corners with quadratic Bézier fillets.

For each interior corner, the original vertex is replaced by a smooth curve starting/ending at a controlled distance along the adjacent segments.

Parameters:
  • ys (xs,) – coordinate arrays (float64).

  • ws – width multiplier array (float32).

  • join_size – Fraction (mode 0) or world distance (mode 1). In fraction mode, 0 = sharp corner, 1 = fillet eats half of each adjacent segment (clamped so adjacent fillets don’t overlap).

  • join_size_mode – 0 = fraction (adimensional), 1 = world.

  • is_closed – whether the polyline is closed.

  • n_subdiv – number of Bézier subdivision points per corner.

Returns:

(new_xs, new_ys, new_ws) with inserted fillet points.

static _expand_width_profile(profile: list, n: int) numpy.ndarray[source]

Expand a raw width profile to exactly n per-vertex multipliers.

Supports two storage formats:

  • Dense – a plain list[float], one value per vertex. If the length differs from n (e.g. a phantom closing vertex was appended by get_subpolygons()), the values are resampled with linear interpolation so the profile always spans the full polyline.

  • Sparse – a list of (int, float) tuples [(index, multiplier), ...]. Unspecified vertices are filled by linear interpolation between adjacent control points; extrapolation uses the nearest endpoint value (constant fill). A single control point produces a uniform profile at that multiplier value.

Parameters:
  • profile – Dense or sparse width profile (as returned by _parse_width_profile()).

  • n – Number of vertices the result must cover.

Returns:

float32 array of length n, all values ≥ 0.

build_shader_vbo_data() tuple[numpy.ndarray, int][source]

Build VBO data for shader rendering of this vector.

Each sub-polyline (from get_subpolygons() in non-filled mode) is converted to GL_LINES_ADJACENCY segments: four vertices per segment (prev, start, end, next), each carrying (x, y, curvilinear_distance, width_multiplier).

Returns:

(vbo_data, vertex_count) — contiguous float32 array and total number of vertices emitted.

get_values_linked_polygon(linked_arrays: list, getxy=False) dict[source]

Extract values from arrays inside this polygon.

Parameters:
  • linked_arrays – List of arrays to query.

  • getxy – Also return XY coordinates.

Returns:

Dict mapping array index to extracted values.

get_all_values_linked_polygon(linked_arrays, getxy=False) dict[source]

Extract all values from arrays inside this polygon.

Parameters:
  • linked_arrays – Arrays to query.

  • getxy – Also return XY coordinates.

Returns:

Dict mapping array index to all extracted values.

get_all_values_linked_polyline(linked_arrays, getxy=True) dict[source]

Extract values from arrays under this polyline.

Parameters:
  • linked_arrays – Arrays to query.

  • getxy – Also return XY coordinates.

Returns:

Dict mapping array index to extracted values.

get_values_on_vertices(curarray)[source]

Sample a raster array at each vertex position and store as Z.

Parameters:

curarray – Array from which to sample values.

get_values_linked(linked_arrays: dict, refine=True, filter_null=False)[source]

Extract values from linked arrays along the polyline.

Parameters:
  • linked_arrays – Dict of {label: array} to query.

  • refine – Refine the polyline to the array resolution before sampling.

  • filter_null – Exclude null values (-99999) from results.

Returns:

A zoneModel containing one vector per array.

interpolate_coordinates()[source]

Linearly interpolate Z values at vertices where Z is invalid (-99999, 99999, NaN).

create_cs(wa) vectorModel[source]

Create a cross-section profile by sampling a raster array.

Parameters:

waWolfArray to sample.

Returns:

A refined vector with Z values from the array, or None.

keep_only_trace()[source]

Reduce the vector to only two vertices: first and last, with Z = 0.

extend_along_trace(distance: float | str)[source]

Extend the trace (first/last vertices) by distance in both directions.

Parameters:

distance – Extension distance in metres, or a percentage string (e.g. '10%').

class wolfhece.pyvertexvectors._models.zoneModel(lines: list[str] = [], name: str = 'NoName', parent=None, is2D: bool = True, fromshapely: shapely.geometry.LineString | shapely.geometry.Polygon | shapely.geometry.MultiLineString | shapely.geometry.MultiPolygon = None)[source]

Pure-data zone: a list of vectorModel instances plus geometry helpers.

GUI subclass zone in wolfhece.PyVertexvectors adds plotting, OpenGL display-list support and wx integration.

myname: str[source]
myvectors: list[vectorModel][source]
xmin: float[source]
ymin: float[source]
xmax: float[source]
ymax: float[source]
myprops = None[source]
active_vector = None[source]
parent = None[source]
has_legend = False[source]
has_image = False[source]
_move_start = None[source]
_move_step = None[source]
_rotation_center = None[source]
_rotation_step = None[source]
selected_vectors = [][source]
multils: shapely.geometry.MultiLineString = None[source]
used = True[source]
_make_vector(**kwargs) vectorModel[source]

Create a sibling vector. GUI subclass returns vector.

_make_zone(**kwargs) zoneModel[source]

Create a sibling zone. GUI subclass returns zone.

_make_triangulation(**kwargs) TriangulationModel[source]

Create a triangulation. GUI subclass returns Triangulation.

reset_listogl()[source]

No-op in model. GUI subclass deletes gl list and sets idgllist=-99999.

_fill_structure()[source]

No-op in model. GUI subclass calls parent.fill_structure().

property nbvectors: int[source]

Number of vectors in the zone.

property area: float[source]

Total area of all vectors in the zone.

property areas: list[float][source]

List of individual vector areas.

property vector_names: list[str][source]

List of vector names in the zone.

add_vector(addedvect: vectorModel, index=-99999, forceparent=False, update_struct=False)[source]

Add a vector to the zone.

Parameters:
  • addedvect – Vector to add.

  • index – Insertion position (-99999 or > count appends).

  • forceparent – Set this zone as the vector’s parent.

  • update_struct – Trigger GUI structure update.

get_vector(keyvector: int | str) vectorModel[source]

Return a vector by index or name.

Parameters:

keyvector – Integer index or string name.

Returns:

The matching vectorModel, or None.

count()[source]

No-op placeholder (kept for backward compatibility).

import_shapelyobj(obj)[source]

Import a Shapely geometry (LineString, Polygon, Multi…) as vector(s).

Parameters:

obj – Shapely geometry object.

check_if_interior_exists()[source]

Check all vectors for interior boundaries.

add_values(key: str, values: numpy.ndarray)[source]

Assign a value to each vector.

Parameters:
  • key – Property key.

  • values – 1-D array with one value per vector.

get_values(key: str) numpy.ndarray[source]

Retrieve values for a given key from all vectors.

Parameters:

key – Property key.

set_colors_from_value(key: str, cmap: wolfhece.PyPalette.wolfpalette | matplotlib.colors.Colormap | matplotlib.cm.ScalarMappable, vmin: float = 0.0, vmax: float = 1.0)[source]

Colour all vectors according to a stored value and a colormap.

Parameters:
  • key – Property key.

  • cmap – Colour map.

  • vmin – Minimum value for mapping.

  • vmax – Maximum value for mapping.

set_color(color: int | wolfhece.color_constants.RGB | str | list | tuple)[source]

Set the same colour on all vectors.

Parameters:

color – Colour specification.

set_linewidth(linewidth: int | float)[source]

Set the line width for all vectors.

Parameters:

linewidth – Line width in pixels.

set_alpha(alpha: int)[source]

Set the transparency for all vectors.

Parameters:

alpha – Alpha value (0–255).

set_filled(filled: bool)[source]

Enable or disable polygon filling for all vectors.

Parameters:

filledTrue to fill.

check_if_open()[source]

Check all vectors for open/closed state.

set_legend_text(text: str)[source]

Set legend text for all vectors.

Parameters:

text – Legend text.

set_legend_color(color: int | wolfhece.color_constants.RGB | str | list | tuple)[source]

Set legend colour for all vectors.

Parameters:

color – Colour specification.

set_legend_text_from_values(key: str)[source]

Set legend text from stored values for all vectors.

Parameters:

key – Property key.

set_legend_position(x, y)[source]

Set legend position for all vectors.

Parameters:
  • x – X position (float or keyword string).

  • y – Y position (float or keyword string).

set_legend_to_centroid()[source]

Place legends at each vector’s centroid.

set_legend_visible(visible: bool = True)[source]

Show or hide legends for all vectors.

Parameters:

visibleTrue to display.

keep_only_trace()[source]

Reduce all vectors to their trace (first and last vertices).

extend_along_trace(distance: float | str)[source]

Extend all vectors along their trace.

Parameters:

distance – Extension distance or percentage string.

set_glow(enabled: bool = True, width: float = 0.4, color: tuple = (1.0, 1.0, 1.0), alpha: float = 0.4)[source]

Configure line glow for all vectors.

Parameters:
  • enabled – Enable or disable glow.

  • width – Glow width as fraction of half-width (0–1).

  • color – RGB colour tuple [0, 1].

  • alpha – Glow opacity [0, 1].

set_dash(enabled: bool = True, dash_length: float = 10.0, gap_length: float = 5.0)[source]

Configure dashed lines for all vectors.

Parameters:
  • enabled – Enable or disable dashes.

  • dash_length – Dash length in world units.

  • gap_length – Gap length in world units.

set_animation(mode: int = 1, speed: float = 1.0)[source]

Configure line animation for all vectors.

Parameters:
  • mode – 0=none, 1=pulse, 2=marching ants.

  • speed – Speed multiplier.

set_fill_animation(mode: int = 1, speed: float = 1.0, center_index: int = 0, start_angle: float = 90.0)[source]

Configure filled-polygon animation for all vectors.

Parameters:
  • mode – 0=none, 1=pulse, 2=sweep, 3=ripple, 4=radial progressive, 5=clockwise clock, 6=counter-clockwise clock.

  • speed – Speed multiplier.

  • center_index – Vertex index used as the radial/clock centre.

  • start_angle – Clock fill start angle in degrees.

set_fill_color(color=None)[source]

Set independent fill colour for all vectors.

Parameters:

color – RGB tuple, packed int, or None to inherit main colour.

set_contour_color(color=None, width: float = 1.0, enabled: bool = True)[source]

Set contour colour/width for all vectors.

Parameters:
  • color – RGB tuple, packed int, or None to inherit main colour.

  • width – Contour line width.

  • enabled – Whether to draw the contour pass.

set_join_style(style: int = 0, size: float = 0.5, size_mode: int = 0)[source]

Configure join rendering for all vectors.

Parameters:
  • style – 0=miter, 1=bevel, 2=round, 3=fillet.

  • size – Join size.

  • size_mode – 0=fraction, 1=world distance.

set_width_in_pixels(pixels: bool = True)[source]

Toggle pixel vs world-unit line width for all vectors.

Parameters:

pixelsTrue for pixel widths.

set_text_along(text: str, enabled: bool = True, offset: float = 0.0, perp: float = 0.0, alignment: str = 'center')[source]

Configure text along polyline for all vectors.

Parameters:
  • text – Text to display.

  • enabled – Enable or disable.

  • offset – Shift start along polyline (world units).

  • perp – Perpendicular offset (world units).

  • alignment – ‘left’, ‘center’, ‘right’.

set_legend_glow(enabled: bool = True, width: float = 0.15, color: tuple = (1.0, 1.0, 1.0), alpha: float = 0.5)[source]

Configure legend glow for all vectors.

Parameters:
  • enabled – Enable or disable legend glow.

  • width – SDF threshold offset.

  • color – RGB colour tuple [0, 1].

  • alpha – Glow opacity [0, 1].

set_legend_animation(mode: int = 1, speed: float = 1.0)[source]

Configure legend animation for all vectors.

Parameters:
  • mode – 0=none, 1=pulse, 2=wave, 3=typewriter.

  • speed – Speed multiplier.

set_legend_style(smoothing: float = 1.0, alignment: str = 'left', line_spacing: float = 1.2)[source]

Configure legend SDF text style for all vectors.

Parameters:
  • smoothing – SDF AA multiplier.

  • alignment – ‘left’, ‘center’, ‘right’.

  • line_spacing – Multiline spacing multiplier.

set_cache()[source]

Cache coordinates and bounds for all vectors.

clear_cache()[source]

Clear cached data for all vectors and reset transform state.

move(dx: float, dy: float, use_cache: bool = True, inplace: bool = True)[source]

Translate all vectors in the zone.

Parameters:
  • dx – Displacement along X.

  • dy – Displacement along Y.

  • use_cache – Use cached coordinates.

  • inplace – Modify in place; if False return a moved copy.

rotate(angle: float, center: tuple[float, float], use_cache: bool = True, inplace: bool = True)[source]

Rotate all vectors around a centre point.

Parameters:
  • angle – Rotation angle in degrees.

  • center – Centre of rotation (x, y).

  • use_cache – Use cached coordinates.

  • inplace – Modify in place or return a copy.

rotate_xy(x: float, y: float, use_cache: bool = True, inplace: bool = True)[source]
use()[source]

Mark all vectors and the zone as used/active.

unuse()[source]

Mark all vectors and the zone as unused/inactive.

get_mapviewer()[source]

Return the parent map-viewer widget.

find_minmax(update=False, only_firstlast: bool = False)[source]

Compute the bounding box across all vectors.

Parameters:
  • update – Recompute individual vector bounds first.

  • only_firstlast – Consider only first/last vertices.

find_nearest_vertex(x: float, y: float) wolfhece.PyVertex.wolfvertex | None[source]

Return the nearest vertex across all vectors in the zone.

find_nearest_vector(x: float, y: float) vectorModel | None[source]

Return the vector whose geometry is nearest to (x, y).

select_vectors_from_point(x: float, y: float, inside=True)[source]

Select vectors containing or nearest to the point (x, y).

Parameters:
  • x – X coordinate.

  • y – Y coordinate.

  • inside – If True, select vectors whose polygon contains the point; otherwise select the nearest vector.

get_selected_vectors(all=False)[source]
asshapely_ls() shapely.geometry.MultiLineString[source]

Return all vectors as a Shapely MultiLineString.

prepare_shapely()[source]

Build a Shapely MultiLineString for the zone.

_nblines() int[source]

Return the number of lines required when saving this zone.

save(f: io.TextIOWrapper)[source]

Write the zone definition to an open file.

Parameters:

f – Writable text file handle.

save_extra(f: io.TextIOWrapper)[source]

Write extra properties for each vector.

Parameters:

f – Writable text file handle.

load_extra(lines: list[str]) int[source]
export_shape(fn: str = '')[source]

Export vectors as an ESRI Shapefile (Lambert 72 / EPSG:31370).

Parameters:

fn – Output file path.

buffer(distance: float, resolution: int = 16, inplace: bool = False) zoneModel[source]

Buffer all vectors in the zone.

Parameters:
  • distance – Buffer distance.

  • resolution – Segments per quarter-circle.

  • inplace – Modify in place or return a new zone.

reverse(inplace: bool = True) zoneModel[source]

Reverse vertex order in all vectors.

Parameters:

inplace – Modify in place or return a copy.

add_parallel(distance)[source]

Add a parallel offset of the active vector to the zone.

Parameters:

distance – Offset distance (positive = right, negative = left).

parallel_active(distance)[source]

Replace zone contents with the active vector plus left and right offsets.

Parameters:

distance – Offset distance.

create_cs(wa) zoneModel[source]

Create cross-section profiles for each vector by sampling a raster.

Parameters:

waWolfArray to sample.

Returns:

New zone containing the cross-section vectors.

deepcopy_zone(name: str = None, parent=None) zoneModel[source]

Return a deep copy of this zone.

Parameters:
  • name – Name for the copy (defaults to <name>_copy).

  • parent – Optional parent for the copy.

deepcopy(name: str = None, parent=None) zoneModel[source]

Alias for :pymeth:`deepcopy_zone`.

create_multibin(nb: int = None, nb2: int = 0) TriangulationModel[source]

Create a multi-bin triangulation between the zone’s vectors.

Parameters:
  • nb – Number of interpolation points per vector.

  • nb2 – Number of intermediate vectors between each pair.

Returns:

TriangulationModel or None on error.

create_constrainedDelaunay(nb: int = None) TriangulationModel[source]

Create a constrained Delaunay triangulation from the zone’s vectors.

Parameters:

nb – Number of interpolation points per vector (0 = no resampling).

Returns:

TriangulationModel or None on error.

createmultibin_proj(nb: int = None, nb2: int = 0) TriangulationModel[source]

Create a projected multi-bin triangulation using a support line.

Parameters:
  • nb – Number of interpolation points per vector.

  • nb2 – Number of intermediate vectors between each pair.

Returns:

TriangulationModel or None on error.

create_polygon_from_parallel(ds: float, howmanypoly=1) None[source]

Create polygons between left, centre, and right vectors.

The zone must contain exactly 3 vectors.

Parameters:
  • ds – Spacing along the trace.

  • howmanypoly – Number of polygons.

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)[source]

Create sliding polygons along a trace with parallel offsets.

Parameters:
  • poly_length – Length of each polygon along the trace.

  • ds_sliding – Sliding step between successive polygons.

  • farthest_parallel – Maximum offset distance.

  • interval_parallel – Interval between parallel offsets.

  • intersect – Optional intersecting vector to limit the trace.

  • howmanypoly – Number of polygons per position.

  • eps_offset – Small offset applied at the starting position.

get_values_linked_polygons(linked_arrays, stats=True) dict[source]

Extract raster values inside each vector’s polygon.

Parameters:
  • linked_arrays – Arrays to query.

  • stats – Compute statistics on the results.

get_all_values_linked_polygon(linked_arrays, stats=True, key_idx_names: Literal['idx', 'name'] = 'idx', getxy=False) dict[source]

Extract all raster values inside each vector’s polygon.

Parameters:
  • linked_arrays – Arrays to query.

  • stats – Compute statistics.

  • key_idx_names – Key type for result dict (‘idx’ or ‘name’).

  • getxy – Also return XY coordinates.

_stats_values(vals: dict)[source]

Compute median, mean, min, max, p5, p95 statistics on extracted values.

Parameters:

vals – Dict of {polygon_id: {values: ...}}.

class wolfhece.pyvertexvectors._models.ZonesModel(filename: str | pathlib.Path = '', ox: float = 0.0, oy: float = 0.0, tx: float = 0.0, ty: float = 0.0, is2D: bool = True, idx: str = '', colname: str = None, bbox: shapely.geometry.Polygon = None, find_minmax_init: bool = True, colors: dict = None)[source]

Pure-data Zones: a list of zoneModel instances plus I/O and geometry helpers.

GUI subclass Zones in wolfhece.PyVertexvectors adds wx.Frame, OpenGL display-list support, tree-list UI and wx integration.

tx: float[source]
ty: float[source]
myzones: list[zoneModel][source]
wx_exists = False[source]
plotted = True[source]
mapviewer = None[source]
_myprops = None[source]
loaded = True[source]
active_vector = None[source]
active_zone = None[source]
last_active = None[source]
force3D = False[source]
is2D = True[source]
filename = ''[source]
init_struct = True[source]
xmin = 0.0[source]
ymin = 0.0[source]
xmax = -99999.0[source]
ymax = -99999.0[source]
_first_find_minmax: bool = True[source]
_move_start = None[source]
_move_step = None[source]
_rotation_center = None[source]
_rotation_step = None[source]
prep_listogl()[source]

No-op in the model; GUI override prepares OpenGL display lists.

reset_listogl()[source]

No-op in the model; GUI override resets OpenGL display lists.

_make_zone(**kwargs)[source]

Factory: create a zoneModel. GUI override returns zone.

_make_zones(**kwargs)[source]

Factory: create a ZonesModel. GUI override returns Zones.

_make_vector(**kwargs)[source]

Factory: create a vectorModel. GUI override returns vector.

property mynames: list[str][source]

Return the names of all zones

check_if_interior_exists()[source]

Check if the zone has at least one vector with interior points

add_values(key: str, values: numpy.ndarray | dict)[source]

Add values to the zones.

Parameters:
  • key – Value identifier.

  • values – Either a dict {zone_name: ndarray} or an ndarray whose first axis length must match :pyattr:`nbzones`.

get_values(key: str) numpy.ndarray[source]

Get values from the zones.

Parameters:

key – Value identifier.

Returns:

Array of values, one element per zone.

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)[source]

Set colours for all zones based on stored values.

Parameters:
  • key – Value identifier used to look up per-zone data.

  • cmap – Colour map (palette, name, Colormap or ScalarMappable).

  • vmin – Lower bound of the value range.

  • vmax – Upper bound of the value range.

set_color(color: int | wolfhece.color_constants.RGB | str | list | tuple)[source]

Set a uniform colour for all zones.

Parameters:

color – Colour specification (integer, RGB, name, or list/tuple).

set_linewidth(linewidth: int | float)[source]

Set line width for all zones.

Parameters:

linewidth – Width in pixels.

set_alpha(alpha: int)[source]

Set transparency for all zones.

Parameters:

alpha – Alpha value (0–255).

set_filled(filled: bool)[source]

Set filled rendering for all zones.

Parameters:

filled – Whether polygons should be drawn filled.

check_if_open()[source]

Check if the vectors in the zone are open

concatenate_all_vectors() list[vectorModel][source]

Concatenate all vectors in the zones

prepare_shapely()[source]

Prepare shapely objects for all vectors in zones

filter_contains(others: list[vectorModel]) ZonesModel[source]

Create a new ZonesModel with vectors from others contained in the zones.

Parameters:

others – List of vectors or a ZonesModel to filter.

Returns:

A new ZonesModel with the contained vectors.

property areas[source]

List of areas of all zones

buffer(distance: float, resolution: int = 16, inplace: bool = True)[source]

Buffer all zones.

Parameters:
  • distance – Buffer distance in world units.

  • resolution – Number of segments to approximate a quarter circle.

  • inplace – If True, modify in place; otherwise return a new object.

set_cache()[source]

Set cache for all zones

clear_cache()[source]

Clear cache for all zones

move(dx: float, dy: float, use_cache: bool = True, inplace: bool = True)[source]

Move all zones.

Parameters:
  • dx – Translation along X.

  • dy – Translation along Y.

  • use_cache – If True, move relative to cached positions.

  • inplace – If True, modify in place; otherwise return a deep copy.

rotate(angle: float, center: shapely.geometry.Point = None, use_cache: bool = True, inplace: bool = True)[source]

Rotate all zones.

Parameters:
  • angle – Rotation angle in radians.

  • center – Centre of rotation (default: origin).

  • use_cache – If True, rotate from cached positions.

  • inplace – If True, modify in place; otherwise return a deep copy.

rotate_xy(angle: float, center: shapely.geometry.Point = None, use_cache: bool = True, inplace: bool = True)[source]

Rotate all zones (XY plane only).

Parameters:
  • angle – Rotation angle in radians.

  • center – Centre of rotation (default: origin).

  • use_cache – If True, rotate from cached positions.

  • inplace – If True, modify in place; otherwise return a deep copy.

force_unique_zone_name()[source]

Check if all zones have a unique id

If not, the id will be set to the index of the zone in the list

set_legend_visible(visible: bool = True)[source]

Set the visibility of the legend for all zones.

Parameters:

visible – Whether the legend should be visible.

set_legend_text(text: str)[source]

Set the legend text for all zones.

Parameters:

text – Legend text string.

set_legend_color(color: str | int | tuple | list | wolfhece.color_constants.RGB)[source]

Set the legend colour for all zones.

Parameters:

color – Colour specification.

set_legend(x: float | str, y: float | str, text: str, visible: bool = True)[source]

Set legend position, text and visibility for all zones.

Parameters:
  • x – X-coordinate of the legend.

  • y – Y-coordinate of the legend.

  • text – Legend text string.

  • visible – Whether the legend should be visible.

set_legend_text_from_values(key: str)[source]

Set legend text for all zones from stored values.

Parameters:

key – Value identifier.

set_legend_to_centroid()[source]

Set the legend to the centroid of the zones

set_legend_position(x, y)[source]

Set legend position for all zones.

Parameters:
  • x – X-coordinate.

  • y – Y-coordinate.

set_glow(enabled: bool = True, width: float = 0.4, color: tuple = (1.0, 1.0, 1.0), alpha: float = 0.4)[source]

Configure line glow for all zones.

Parameters:
  • enabled – Enable or disable glow.

  • width – Glow width as fraction of half-width (0–1).

  • color – RGB colour tuple [0, 1].

  • alpha – Glow opacity [0, 1].

set_dash(enabled: bool = True, dash_length: float = 10.0, gap_length: float = 5.0)[source]

Configure dashed lines for all zones.

Parameters:
  • enabled – Enable or disable dashes.

  • dash_length – Dash length in world units.

  • gap_length – Gap length in world units.

set_animation(mode: int = 1, speed: float = 1.0)[source]

Configure line animation for all zones.

Parameters:
  • mode – 0=none, 1=pulse, 2=marching ants.

  • speed – Speed multiplier.

set_fill_animation(mode: int = 1, speed: float = 1.0, center_index: int = 0, start_angle: float = 90.0)[source]

Configure filled-polygon animation for all zones.

Parameters:
  • mode – 0=none, 1=pulse, 2=sweep, 3=ripple, 4=radial progressive, 5=clockwise clock, 6=counter-clockwise clock.

  • speed – Speed multiplier.

  • center_index – Vertex index used as the radial/clock centre.

  • start_angle – Clock fill start angle in degrees.

set_fill_color(color=None)[source]

Set independent fill colour for all zones.

Parameters:

color – RGB tuple, packed int, or None to inherit main colour.

set_contour_color(color=None, width: float = 1.0, enabled: bool = True)[source]

Set contour colour/width for all zones.

Parameters:
  • color – RGB tuple, packed int, or None to inherit main colour.

  • width – Contour line width.

  • enabled – Whether to draw the contour pass.

set_join_style(style: int = 0, size: float = 0.5, size_mode: int = 0)[source]

Configure join rendering for all zones.

Parameters:
  • style – 0=miter, 1=bevel, 2=round, 3=fillet.

  • size – Join size.

  • size_mode – 0=fraction, 1=world distance.

set_width_in_pixels(pixels: bool = True)[source]

Toggle pixel vs world-unit line width for all zones.

Parameters:

pixelsTrue for pixel widths.

set_text_along(text: str, enabled: bool = True, offset: float = 0.0, perp: float = 0.0, alignment: str = 'center')[source]

Configure text along polyline for all zones.

Parameters:
  • text – Text to display.

  • enabled – Enable or disable.

  • offset – Shift start along polyline (world units).

  • perp – Perpendicular offset (world units).

  • alignment – ‘left’, ‘center’, ‘right’.

set_legend_glow(enabled: bool = True, width: float = 0.15, color: tuple = (1.0, 1.0, 1.0), alpha: float = 0.5)[source]

Configure legend glow for all zones.

Parameters:
  • enabled – Enable or disable legend glow.

  • width – SDF threshold offset.

  • color – RGB colour tuple [0, 1].

  • alpha – Glow opacity [0, 1].

set_legend_animation(mode: int = 1, speed: float = 1.0)[source]

Configure legend animation for all zones.

Parameters:
  • mode – 0=none, 1=pulse, 2=wave, 3=typewriter.

  • speed – Speed multiplier.

set_legend_style(smoothing: float = 1.0, alignment: str = 'left', line_spacing: float = 1.2)[source]

Configure legend SDF text style for all zones.

Parameters:
  • smoothing – SDF AA multiplier.

  • alignment – ‘left’, ‘center’, ‘right’.

  • line_spacing – Multiline spacing multiplier.

property nbzones[source]

Number of zones in the collection.

import_shapefile(fn: str, bbox: shapely.geometry.Polygon = None, colname: str = None, value_columns: str | list[str] | tuple[str, Ellipsis] | None = None, share_multipart_values: bool = False)[source]

Import a shapefile using geopandas.

The entire shapefile is loaded as a single zone.

Parameters:
  • fn – Path to the shapefile.

  • bbox – Optional bounding box to filter features.

  • colname – Column name used to build zone names.

  • value_columns – Columns to store into vector properties. - None: do not import attribute values (default). - 'all': import all non-geometry columns. - list/tuple: import selected columns.

  • share_multipart_values – If True, multipart geometries share the same underlying _values dictionary across split vectors.

import_GeoDataFrame(content: geopandas.GeoDataFrame, bbox: shapely.geometry.Polygon = None, colname: str = None, value_columns: str | list[str] | tuple[str, Ellipsis] | None = None, share_multipart_values: bool = False)[source]

Import a GeoDataFrame.

Parameters:
  • content – GeoDataFrame to import.

  • bbox – Optional bounding box to filter features.

  • colname – Column name used to build zone names.

  • value_columns – Columns to store into vector properties. - None: do not import attribute values (default). - 'all': import all non-geometry columns. - list/tuple: import selected columns.

  • share_multipart_values – If True, multipart geometries share the same underlying _values dictionary across split vectors.

export_GeoDataFrame(as_multipart: bool = False) geopandas.GeoDataFrame[source]

Export to a GeoDataFrame

Parameters:

as_multipart – If True, export one row per zone with Multi* geometries when possible. Default False keeps legacy behavior.

_vector_geometry_for_export(curvect: vectorModel)[source]

Return the most suitable shapely geometry for a vector export.

_zone_multipart_geometry_for_export(curzone: zoneModel)[source]

Return a Multi* geometry for a zone when possible.

If a zone mixes closed and open vectors, multipart export is ambiguous; in that case None is returned and a warning is emitted.

export_GeoDataFrame_with_values(value_columns: str | list[str] | tuple[str, Ellipsis] = 'common', missing_value=np.nan, include_vector_meta: bool = True, as_multipart: bool = False) geopandas.GeoDataFrame[source]

Export vectors to a temporary GeoDataFrame including property values.

By default, one row is written per vector. With as_multipart=True, one row is written per zone with a Multi* geometry.

Property keys can be selected with:

  • 'common': keys present in every exported vector.

  • 'union': all keys found on at least one vector.

  • list/tuple: explicit key selection.

Parameters:
  • value_columns – Column-selection mode.

  • missing_value – Fill value for missing keys.

  • include_vector_meta – Include helper metadata columns.

  • as_multipart – Export one Multi* geometry per zone.

Returns:

A GeoDataFrame ready to be written with GeoPandas.

export_to_shapefile(filename: str, include_values: bool = False, value_columns: str | list[str] | tuple[str, Ellipsis] = 'common', missing_value=np.nan, include_vector_meta: bool = True, as_multipart: bool = False)[source]

Export to shapefile.

The first vector of each zone will be exported. Use export_shape on the zone object to export all vectors.

Parameters:
  • filename – Output shapefile path.

  • include_values – If True, export per-vector property values.

  • value_columns – Property-key selection mode used when include_values=True.

  • missing_value – Fill value for missing keys.

  • include_vector_meta – Include helper metadata columns.

  • as_multipart – If True, export one row per zone as Multi*.

export_to_geopackage(filename: str, layer: str = 'zones', include_values: bool = True, value_columns: str | list[str] | tuple[str, Ellipsis] = 'common', missing_value=np.nan, include_vector_meta: bool = True, as_multipart: bool = False)[source]

Export to GeoPackage using GeoPandas.

Parameters:
  • filename – Output GeoPackage path.

  • layer – Layer name inside the GeoPackage.

  • include_values – If True, export per-vector property values.

  • value_columns – Property-key selection mode used when include_values=True.

  • missing_value – Fill value for missing keys.

  • include_vector_meta – Include helper metadata columns.

  • as_multipart – If True, export one row per zone as Multi*.

export_active_zone_to_shapefile(filename: str)[source]

Export the active zone to a shapefile.

Parameters:

filename – Output shapefile path.

import_gdb(fn: str, bbox: shapely.geometry.Polygon = None, layers: list[str] = None, colname: str = None, value_columns: str | list[str] | tuple[str, Ellipsis] | None = None, share_multipart_values: bool = False)[source]

Import a GDB file using geopandas and Fiona.

Parameters:
  • fn – Path to the GDB file.

  • bbox – Optional bounding box to filter features.

  • layers – List of layer names to import (default: all).

  • colname – Column name used to build zone names.

  • value_columns – Columns to store into vector properties.

  • share_multipart_values – If True, multipart geometries share the same underlying _values dictionary across split vectors.

import_gpkg(fn: str, bbox: shapely.geometry.Polygon = None, layers: list[str] = None, colname: str = None, value_columns: str | list[str] | tuple[str, Ellipsis] | None = None, share_multipart_values: bool = False)[source]

Import a GeoPackage file using geopandas and Fiona.

Parameters:
  • fn – Path to the GPKG file.

  • bbox – Optional bounding box to filter features.

  • layers – List of layer names to import (default: all).

  • colname – Column name used to build zone names.

  • value_columns – Columns to store into vector properties.

  • share_multipart_values – If True, multipart geometries share the same underlying _values dictionary across split vectors.

colorize_data(colors: dict[str:list[int]], filled: bool = False) None[source]

Colorize zones based on a dictionary of colours.

Zone names must match the dictionary keys.

Parameters:
  • colors – Mapping {zone_name: [R, G, B]}.

  • filled – Whether polygons should be drawn filled.

set_width(width: int) None[source]

Set line width for all vectors in all zones.

Parameters:

width – Width in pixels.

get_zone(keyzone: int | str) zoneModel[source]

Retrieve a zone by name or index.

If multiple zones share the same name, only the first is returned.

Parameters:

keyzone – Zone index (int) or zone name (str).

Returns:

The matching zone, or None if not found.

property zone_names: list[str][source]

Return the list of zone names

import_dxf(fn, imported_elts=['POLYLINE', 'LWPOLYLINE', 'LINE'])[source]

Import of a DXF file as a ‘Zones’.

The DXF file is read and the elements are stored in zones based on their layers.

The supported elements are POLYLINE, LWPOLYLINE and LINE. If you want to import other elements, you must upgrade this routine import_dxf.

Parameters:
  • fn – name of the DXF file to import

  • imported_elts – list of DXF elements to import. Default is [‘POLYLINE’,’LWPOLYLINE’,’LINE’].

Returns:

None

find_nearest_vertex(x: float, y: float) wolfhece.PyVertex.wolfvertex | None[source]

Find the nearest vertex across all zones.

find_nearest_vector(x: float, y: float) vectorModel[source]

Find the vector whose geometry is closest to a coordinate.

Parameters:
  • x – X-coordinate.

  • y – Y-coordinate.

Returns:

The nearest vector.

find_vector_containing_point(x: float, y: float) vectorModel[source]

Find the first vector whose polygon contains the point.

Parameters:
  • x – X-coordinate.

  • y – Y-coordinate.

Returns:

The containing vector, or None.

check_plot()[source]

L’objet doit être affiché

Fonction principalement utile pour l’objet WolfMapViewer et le GUI

uncheck_plot(unload=True)[source]

Mark the object as not plotted.

Parameters:

unload – Reserved for GUI subclasses.

save()[source]

Sauvegarde sur disque, sans remise en cause du nom de fichier

saveas(filename: str = '')[source]

Save to disk, optionally under a new filename.

Parameters:

filename – New path; if empty, uses the current self.filename.

add_zone(addedzone: zoneModel, forceparent=False)[source]

Add a zone to the collection.

Parameters:
  • addedzone – The zone to add.

  • forceparent – If True, set this object as the zone’s parent.

create_zone(name: str = '') zoneModel[source]

Create a new zone and add it to the collection.

Parameters:

name – Name of the new zone.

Returns:

The newly created zone.

find_minmax(update=False, only_firstlast: bool = False)[source]

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

plot(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None)[source]

Draw all zones.

Parameters:
  • sx – Scale factor along X.

  • sy – Scale factor along Y.

  • xmin – Minimum X of the viewport.

  • ymin – Minimum Y of the viewport.

  • xmax – Maximum X of the viewport.

  • ymax – Maximum Y of the viewport.

  • size – Reference size for rendering.

get_bounds(force_to_update: bool = True) tuple[tuple[float, float], tuple[float, float]][source]

Return the bounds of all zones.

Parameters:

force_to_update – If True, recompute bounds before returning.

Returns:

((xmin, xmax), (ymin, ymax)).

select_vectors_from_point(x: float, y: float, inside=True)[source]

Select vectors in each zone from a coordinate.

Fills the selected_vectors list of each zone.

Parameters:
  • x – X-coordinate.

  • y – Y-coordinate.

  • inside – If True, select by containment; if False, select the nearest vector.

create_cs(wa) ZonesModel[source]

Create cross-section zones from the active zone.

Parameters:

wa – Active WolfArray used to extract cross-section elevations.

Returns:

A new ZonesModel containing the cross-sections, or None.

update_from_sz_direction(xy1: numpy.ndarray, xy2: numpy.ndarray, sz: numpy.ndarray)[source]

Update the active vector from curvilinear s-z values along a direction.

Parameters:
  • xy1 – Start point [x, y] of the direction.

  • xy2 – End point [x, y] of the direction.

  • sz – Array of shape (n, 2) with columns [s, z].

get_selected_vectors(all=False)[source]

Return selected vectors from all zones.

Parameters:

all – If True, return all selected vectors as a list; if False, return only the nearest selected vector.

unuse()[source]

Rend inutilisé l’ensemble des zones

use()[source]

Rend utilisé l’ensemble des zones

_callback_destroy_props()[source]

Callback invoked when the properties dialog is destroyed.

deepcopy_zones(name: str = None) ZonesModel[source]

Return a deep copy of this object.

Parameters:

name – Optional name for the copy.

Returns:

A new ZonesModel instance.

deepcopy(name: str = None) ZonesModel[source]

Return a deep copy of this object (alias for deepcopy_zones()).

Parameters:

name – Optional name for the copy.

Returns:

A new ZonesModel instance.

keep_only_trace()[source]

Keep only the trace (first and last vertices) of all vectors for all zones in this Zones.

deepcopy_only_trace(name: str = None) ZonesModel[source]

Return a deep copy keeping only trace vertices (first and last).

Parameters:

name – Optional name for the copy.

Returns:

A new ZonesModel instance with trace-only vectors.

extend_along_trace(distance: float | str)[source]

Extend all vectors along their trace by the given distance. :param distance: Distance to extend (float) or ‘auto’ to extend

by 10% of the vector length.

class wolfhece.pyvertexvectors._models.GridModel(size: float = 1000.0, ox: float = 0.0, oy: float = 0.0, ex: float = 1000.0, ey: float = 1000.0)[source]

Bases: ZonesModel

Inheritance diagram of wolfhece.pyvertexvectors._models.GridModel

Pure-data Grid: one zone with gridx, gridy and contour vectors.

GUI subclass Grid in wolfhece.PyVertexvectors inherits from this and adds wx/OpenGL support via Zones.

creategrid(size: float = 100.0, ox: float = 0.0, oy: float = 0.0, ex: float = 1000.0, ey: float = 1000.0)[source]

(Re)create the grid lines and contour.

Resets the gridx, gridy and contour vectors and rebuilds them as a regular rectangular grid.

Parameters:
  • size – Grid cell size in world units.

  • ox – X-coordinate of the grid origin (lower-left).

  • oy – Y-coordinate of the grid origin (lower-left).

  • ex – X-coordinate of the grid extent (upper-right).

  • ey – Y-coordinate of the grid extent (upper-right).