upxo.geoEntities.muledge2d module
2D multi-edge collection entity for UPXO.
Usage
from upxo.geoEntities.muledge2d import muledge2d
Classes
muledge2d : Ordered collection of connected 2D edges with spatial operations.
Notes
A muledge2d stores an ordered, optionally closed chain of edge2d
objects, backed by a shared MPoint2d multi-point object for fast spatial
queries.
- class upxo.geoEntities.muledge2d.muledge2d(method='cpairs_list', ordered=True, closed=False, psense='ccw', esense='ccw', clist=[], cpairs_list=[], points=[], edges=None, edge_base='upxo', pindices=[], eindices=[], make_mp=True, make_emp=True, lean='ignore', plean='ignore', mplean='ignore', elean='ignore', melean='ignore')[source]
Bases:
objectOrdered collection of connected 2D edges with spatial and geometric operations.
Represents a chain of
edge2dobjects sharing endpoints. Supports multiple construction pathways (coordinate list, coordinate-pair list, point objects) and exposes properties such as lengths, slopes, centroid, and roughness over the full chain.Usage
from upxo.geoEntities.muledge2d import muledge2d
Notes
Several mutation methods rebuild the internal point, edge, memory-id, and multi-point databases after editing the chain. These cached structures are part of the public state used by older UPXO geometry workflows.
- ROUND_ZERO_DEC_PLACE = 10
- EPS = 1e-12
- dim
- ordered
- closed
- psense
- esense
- lean
- plean
- mplean
- elean
- cpairs
- ppairs
- points
- clist
- pindices
- pmids
- pmid_pairs
- edges
- eindices
- mpoint
- empoints
- dbbuild_plean()[source]
Rebuild
self.pleanfrom the lean of each point in the chain.- Returns:
Updates
self.pleanin place.- Return type:
None
- dbbuild_elean()[source]
Rebuild
self.eleanfrom the lean of each edge in the chain.- Returns:
Updates
self.eleanin place.- Return type:
None
- dbbuild_pmid()[source]
Rebuild
self.pmidsfromid()of each point in the chain.- Returns:
Updates
self.pmidsin place.- Return type:
None
- dbbuild_pmid_pairs()[source]
Rebuild
self.pmid_pairsfromid()of each point-pair.- Returns:
Updates
self.pmid_pairsin place.- Return type:
None
- dbbuild_mpoint()[source]
Rebuild
self.mpointas amulpoint2dfrom all chain points.- Returns:
Updates
self.mpointin place.- Return type:
None
- dbbuild_empoint()[source]
Rebuild
self.empointsas per-edgemulpoint2dobjects.- Returns:
Updates
self.empointsin place.- Return type:
None
- dbbuild_edges()[source]
Rebuild
self.edgesasedge2dobjects fromself.ppairs.- Returns:
Updates
self.edgesin place.- Return type:
None
- edit_edge_add_point(eind, obj)[source]
Adds point (obj) between pnta and pntb and make two edges Original edge gets edited, new one will be returned. returns the additional edge. If EDGE be the edge and OBJ be the point object being added, then the resulting edges will be:
edge 1: EDGE.pnta -- OBJ edge 2: OBJ -- EDGE.pntb
- property centroid
Return the UPXO centroid point.
- Returns:
Centroid of the underlying multi-point object.
- Return type:
- property centroids
Return centroids of constituent edges.
- Returns:
Centroid point of each
edge2din the chain.- Return type:
- property lengths
Return lengths of constituent edges.
- property slopes
Return slopes of constituent edges.
- property length
Return total length of constituent edges.
- Returns:
Sum of all edge lengths in the chain.
- Return type:
- property mean_length
Return mean length of constituent edges.
- Returns:
Arithmetic mean of all edge lengths in the chain.
- Return type:
- property mean_slope
Return mean slope of constituent edges.
- Returns:
Arithmetic mean of all edge slopes in the chain.
- Return type:
- property roughness
Roughness measure of the chain.
- Raises:
NotImplementedError – Always raised because the roughness measure is not implemented.
- property angles180
Orientation angles of each vertex coordinate in [−180°, 180°].
- property angles
Orientation angles of each vertex coordinate in [0°, 360°].
- make_ring(saa=True, throw=False, close_index=0)[source]
Close this multi-edge into a ring by connecting the last point to the first.
- Parameters:
- Return type:
None
Notes
Closing updates:
points,edges,cpairs,ppairs,empoints,pindices,pmids,pmid_pairs, andself.closed.Examples
from upxo.geoEntities.muledge2d import muledge2d cpairs_list = [[[1, 1], [-1, 1]], [[-1, 1], [-1, -1]], [[-1, -1], [1, -1]]] me = muledge2d(method='cpairs_list', ordered=True, closed=False, cpairs_list=cpairs_list, lean='ignore') me.make_ring() me.is_ring()
- is_ring(fast=True)[source]
Return
Trueif this multi-edge forms a closed ring.- Parameters:
fast (bool, optional) – When
True(default), compare point memory ids (fast). WhenFalse, compare point coordinate equality.- Returns:
Trueif the first and last points coincide.- Return type:
Notes
A ring requires: all edges share the same sense; edges are adjacent from
pntaof edge 0 topntbof edge −1; andpntaof edge 0 equalspntbof edge −1.
- pop_point_by_index(n)[source]
Delete the n-th point from the multi-edge chain.
- Parameters:
n (int) – Index of the point to remove (within
range(len(self.points))).- Return type:
None
Examples
from upxo.geoEntities.muledge2d import muledge2d clist = [[0.0, 0.0], [0.5, 0.0], [1.0, 0.0], [1.5, 0.5], [1.0, 1.01], [2.0, 2.0], [2.5, 0.0]] me = muledge2d(method='clist', ordered=True, closed=False, clist=clist, make_mp=True, lean='ignore') me.pop_point_by_index(0)
- pop_points_by_indices(n)[source]
Delete multiple points from the multi-edge chain by index.
- Parameters:
n (int or list of int) – Index or list of indices of points to remove.
- Return type:
None
Examples
from upxo.geoEntities.muledge2d import muledge2d clist = [[0.00, 0.00], [0.50, 0.00], [1.00, 0.00], [1.50, 0.50], [1.00, 1.01], [2.00, 2.00], [2.50, 0.00]] me = muledge2d(method='clist', ordered=True, closed=False, clist=clist, make_mp=True, make_emp=True, lean='ignore', plean='ignore', mplean='ignore', elean='ignore', melean='ignore') n = [0, 2, 4, 6] me.pop_points_by_indices(n)
- pop_point_by_coord(coord=None, tdist=0.1)[source]
Delete point object at coord from the mul-edge object
- Parameters:
coord (list, tuple, deque, or numpy.ndarray) – A single co-ordinate pair
- Return type:
None.
Examples
from upxo.geoEntities.muledge2d import muledge2d clist = [[0.00, 0.00], [0.50, 0.00], [1.00, 0.00], [1.50, 0.50], [1.00, 1.01], [2.00, 2.00], [2.50, 0.00]] me = muledge2d(method='clist', ordered=True, closed=False, clist=clist, make_mp=True, make_emp=True, lean='ignore', plean='ignore', mplean='ignore', elean='ignore', melean='ignore') me.pop_point_by_coord(coord=[0.1, 0.0], tdist=1.0)
- insert_point_by_index(obj, index=None)[source]
Insert one point into the multi-edge at the given index position.
- Parameters:
- Return type:
None
Examples
from upxo.geoEntities.muledge2d import muledge2d from upxo.geoEntities.point2d import Point2d clist = [[0, 0], [0.5, 0], [1, 0], [1.5, 0.5]] me = muledge2d(method='clist', ordered=True, clist=clist, lean='ignore') me.insert_point_by_index(Point2d(0, 5), index=1)
- fine(level)[source]
Subdivide all edges by inserting their centroids,
leveltimes.- Parameters:
level (int) – Number of subdivision passes. Must be in
[0, 2].- Return type:
None
Examples
from upxo.geoEntities.muledge2d import muledge2d me = muledge2d(method='clist', ordered=True, clist=[[0, 0], [1, 0], [2, 0]], lean='ignore') me.fine(level=1)
- insert_point(obj, index=None, insertion_check='edge')[source]
Insert a single point into the multi-edge at the specified position.
- Parameters:
obj (Point2d) – The point to insert.
index (int, optional) – Position at which to insert the point. Default is
None.insertion_check (str, optional) – Strategy used to validate the insertion location.
'edge'checks containment on an existing edge;'index'uses the raw index directly. Default is'edge'.
- Returns:
None
Limitations
———–
- Implementation is incomplete; only the multi-point bookkeeping is – partially done. Edge rebuilding is a stub (
pass).insertion_check='edge'only works for non-intersecting edge chains.
Examples
from upxo.geoEntities.point2d import Point2d from upxo.geoEntities.muledge2d import muledge2d clist = [[0.0, 0.0], [0.5, 0.0], [1.0, 0.0], [1.5, 0.5]] me = muledge2d(method='clist', ordered=True, closed=False, clist=clist, make_mp=True, make_emp=True, lean='ignore') me.insert_point(Point2d(0.25, 0.0), index=1)
- insert_coord_at(coord, indices=[0, 1])[source]
Insert a raw coordinate into the chain at the given edge indices.
- Parameters:
- Raises:
NotImplementedError – Always raised because coordinate insertion is not implemented.
- insert_point_bw(k=0.5)[source]
Insert a point at fractional position
kalong each edge.- Parameters:
k (float, optional) – Fractional position along the edge, where
0corresponds to the start point and1to the end point. Default is0.5.- Raises:
NotImplementedError – Always raised because fractional insertion is not implemented.
- move_nthpoint(n=0, xyincr=[0, 0], overlap_action='exit')[source]
Translate the n-th point by a coordinate increment.
- Parameters:
n (int, optional) – Index of the point to move. Default
0.xyincr (list of float, optional) – Translation increment
[dx, dy]. Default[0, 0].overlap_action (str, optional) – Behaviour when the new position coincides with an existing point.
'exit'rejects the move;'remove_edge2'removes the resulting dangling edge. Default'exit'.
- Returns:
None
Limitations
———–
'remove_edge2'branch is not yet fully implemented.
- move_pointat(coord=[0, 0])[source]
Move the point at
coordto a new position.- Parameters:
coord (array-like, optional) – Coordinate of the point to be moved. Default is
[0, 0].- Raises:
NotImplementedError – Always raised because coordinate-based point movement is not implemented.
- explode(k, method='centroid')[source]
Explode the chain outward from a reference location.
- Parameters:
- Raises:
NotImplementedError – Always raised because chain explosion is not implemented.
- move()[source]
Translate the entire multi-edge chain.
- Raises:
NotImplementedError – Always raised because whole-chain translation is not implemented.
- stretch()[source]
Stretch the chain along an axis.
- Raises:
NotImplementedError – Always raised because whole-chain stretching is not implemented.