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
TriangulationModel— triangulation geometry, I/O, transformations.vectorpropertiesModel— visual property storage, I/O, color helpers.
GUI/OpenGL subclasses live in wolfhece.PyVertexvectors.
Module Contents
- class wolfhece.pyvertexvectors._models.VectorOGLRenderer(*args, **kwds)[source]
Bases:
enum.Enum
Rendering backend for vector objects.
- 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
TriangulationaddsElement_To_Drawintegration, OpenGL display lists, and matplotlib plotting helpers.- clip_surface(other: TriangulationModel, invert=True, subdivide=0)[source]
Clip the triangulation with another one.
- _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.
- 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_centertoward (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
.glbor.gltffile (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
.TRIfile.- 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/.glbfile.After reading,
validate_format()andfind_minmax()are called automatically.
- 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
vectorand handles file I/O (save / load) without any wx or OpenGL dependency.The GUI subclass
vectorpropertiesaddsWolf_Paramdialog creation,genericImagetexturemanagement, and property-editing callbacks.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).
- 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 aslist[float].Sparse –
"0:1.0,10:2.0,20:0.5"—index:valuepairs, stored aslist[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.
- 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
wolfvertexand avectorpropertiesModel, plus geometry helpers (shapely, interpolation, etc.) without any OpenGL, wx, or matplotlib dependency.GUI subclass
vectorinwolfhece.PyVertexvectorsadds plotting, tree-widget integration and OpenGL display-list support.- myprop: vectorpropertiesModel[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.
- 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 polygon: shapely.geometry.Polygon[source]
Shapely
Polygonbuilt from the vertices (lazily created).
- property linestring: shapely.geometry.LineString[source]
Shapely
LineStringbuilt 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 area: float[source]
Alias for :pyattr:`surface`.
- property z: numpy.ndarray[source]
Z coordinates of all vertices as a 1-D array.
If
add_zdatumisTrue, thezdatumoffset is added.
- 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, MatplotlibColormap, orScalarMappable).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,
RGBinstance, 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:
filled –
Trueto render as a filled polygon.
- set_props_from_other(other)[source]
Copy visual properties from another vector’s properties.
- Parameters:
other – Source
vectorpropertiesModelinstance.
- 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:
visible –
Trueto display the legend.
- 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, orNoneto 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, orNoneto 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:
pixels –
Truefor pixel widths,Falsefor 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
wolfvertexor 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
LineStringorPolygon.- Parameters:
obj – Shapely geometry object.
- force_to_close()[source]
Alias for :pymeth:`close_force`.
- 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.
- save(f)[source]
Write the vector definition (name, vertices, properties) to an open file.
- Parameters:
f – Writable text file handle.
- 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
Falsereturn 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
Falsereturn a rotated copy.
- Returns:
The rotated vector (self or a new copy).
- 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.
- 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 ShapelyPoint; otherwise awolfvertex.
- 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`.
- 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
Pointorwolfvertex).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:
xy –
cloud_verticesor(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:
xy –
cloud_verticesor(N, 2)array of XY coordinates.- Returns:
(x, y)tuple orNone.
- 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_interior_exists()[source]
Detect repeated XY coordinates and flag them as interior (
in_use = False).
- 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).
- asnparray3d() numpy.ndarray[source]
Return vertices as a
(N, 3)NumPy array of(x, y, z)(respectszdatum).
- 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.
- 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 isTrue.
- 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
Falsereturn 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
Noneon 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_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.
- 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
Pointobjects.
- 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 byget_subpolygons()), the values are resampled with linear interpolation so the profile always spans the full polyline.Sparse – a
listof(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 toGL_LINES_ADJACENCYsegments: 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
zoneModelcontaining 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:
wa –
WolfArrayto sample.- Returns:
A refined vector with Z values from the array, or
None.
- 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
zoneinwolfhece.PyVertexvectorsadds plotting, OpenGL display-list support and wx integration.- myvectors: list[vectorModel][source]
- _make_vector(**kwargs) vectorModel[source]
Create a sibling vector. GUI subclass returns
vector.
- _make_triangulation(**kwargs) TriangulationModel[source]
Create a triangulation. GUI subclass returns
Triangulation.
- 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 (
-99999or > 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, orNone.
- import_shapelyobj(obj)[source]
Import a Shapely geometry (LineString, Polygon, Multi…) as vector(s).
- Parameters:
obj – Shapely geometry object.
- 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:
filled –
Trueto fill.
- 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_visible(visible: bool = True)[source]
Show or hide legends for all vectors.
- Parameters:
visible –
Trueto display.
- 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:
pixels –
Truefor 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.
- 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
Falsereturn 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.
- 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.
- asshapely_ls() shapely.geometry.MultiLineString[source]
Return all vectors as a Shapely
MultiLineString.
- 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.
- 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:
wa –
WolfArrayto 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:
TriangulationModelorNoneon 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:
TriangulationModelorNoneon 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:
TriangulationModelorNoneon 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.
- 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
Zonesinwolfhece.PyVertexvectorsadds wx.Frame, OpenGL display-list support, tree-list UI and wx integration.- 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.
- concatenate_all_vectors() list[vectorModel][source]
Concatenate all vectors in the 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
ZonesModelwith the contained vectors.
- 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.
- 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_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:
pixels –
Truefor 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.
- 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
_valuesdictionary 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
_valuesdictionary 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
Noneis 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_shapeon 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
_valuesdictionary 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
_valuesdictionary 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.
- 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.
- 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_vectorslist 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.
- deepcopy_zones(name: str = None) ZonesModel[source]
Return a deep copy of this object.
- Parameters:
name – Optional name for the copy.
- Returns:
A new
ZonesModelinstance.
- 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
ZonesModelinstance.
- 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
ZonesModelinstance with trace-only vectors.
- 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
Pure-data Grid: one zone with gridx, gridy and contour vectors.
GUI subclass
Gridinwolfhece.PyVertexvectorsinherits from this and adds wx/OpenGL support viaZones.- 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).