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
- 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_points(method='ppairs', data=None)[source]
Rebuild
self.pointsfrom the current point-pairs.
- 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
- property centroids
Return centroids of constituent edges of me.
- property lengths
Returns lengths of constituent edges of me.
- property slopes
Returns slopes of constituent edges of me.
- property length
Returns total length of constituent edges of me.
- property mean_length
Returns mean length of constituent edges of me.
- property mean_slope
Returns mean slope of constituent edges of me.
- property roughness
Roughness measure of the chain. Not yet 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. Not yet implemented.
- insert_point_bw(k=0.5)[source]
Insert a point at fractional position
kalong each edge. Not yet 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.
- explode(k, method='centroid')[source]
Explode the chain outward from its centroid by factor
k. Not yet implemented.