Edges

Struct Edges 

Source
pub struct Edges<'a> {
    pub all: Vec<&'a Edge>,
}
Expand description

Defines an array of edges

Fields§

§all: Vec<&'a Edge>

Holds a set of edges

Implementations§

Source§

impl<'a> Edges<'a>

Source

pub fn any_path(&self) -> (Vec<usize>, Vec<usize>)

Finds a sequence of edges by following connected points to create a path

§Returns

Returns a tuple (path, points) where:

  • path – List of indices into self.all representing edges along the path
  • points – List of all points along the path. The list includes the middle points of high-order edges.
§Path Finding Algorithm
  1. Start point selection:

    • First tries to find points connected to only one edge (endpoints)
    • If no endpoints exist (e.g., in a loop), uses point with lowest ID
    • If multiple endpoints exist, uses endpoint with lowest ID
  2. Path construction:

    • Starts from selected point and follows connected edges
    • At each step, takes first available edge not yet used
    • Stops when no more edges can be followed or a loop is detected
§Notes
  • Does not guarantee finding the longest path (NP-hard problem)
  • For simple connected paths (no branches), will find the only possible path
  • For branching paths, result depends on edge order in self.all
  • For loops, starts at lowest numbered point and follows first available edge
  • For disconnected components, follows path until no more connected edges
§Special Cases
  • Empty edge list returns (Vec::new(), Vec::new())
  • Single edge returns path with just that edge
  • Loop starts from lowest numbered point
  • Branching paths follow first available edge at each step
  • Disconnected edges follow path until component ends
§Examples
use gemlab::mesh::{Edge, Edges};
use gemlab::shapes::GeoKind;

// Create some sample edges (a simple path 1-2-3)
let e1 = Edge { kind: GeoKind::Lin2, points: vec![1, 2], marker: 0 };
let e2 = Edge { kind: GeoKind::Lin2, points: vec![2, 3], marker: 0 };
let edges = Edges { all: vec![&e1, &e2] };

// Get path through edges
let (path, points) = edges.any_path();
assert_eq!(path, vec![0, 1]);      // Edge indices
assert_eq!(points, vec![1, 2, 3]); // Point indices

Trait Implementations§

Source§

impl<'a> Clone for Edges<'a>

Source§

fn clone(&self) -> Edges<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Edges<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Display for Edges<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Edges<'a>

§

impl<'a> RefUnwindSafe for Edges<'a>

§

impl<'a> Send for Edges<'a>

§

impl<'a> Sync for Edges<'a>

§

impl<'a> Unpin for Edges<'a>

§

impl<'a> UnwindSafe for Edges<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V