Skip to main content

Location

Struct Location 

Source
pub struct Location { /* private fields */ }
Expand description

A placement: a chain of (datum, power) pairs.

Applied left to right, so the first entry is the outermost transform. An empty chain is the identity.

Powers are integers, so a datum applied twice costs one entry rather than two, and its inverse is the same entry with the sign flipped. Equality and hashing are structural: two locations agree when their chains match entry for entry. Deliberately not a comparison of the composed transforms; that would be a tolerance question, and the answer would depend on rounding rather than on what the model says.

Implementations§

Source§

impl Location

Source

pub fn identity() -> Self

The identity placement.

Source

pub fn of(datum: DatumId) -> Self

A placement of one datum, applied once.

Source

pub fn powered(datum: DatumId, power: i32) -> Self

A placement of one datum, applied power times.

A power of zero gives the identity; a negative power gives the inverse.

Source

pub fn is_identity(&self) -> bool

Whether this is the identity.

Source

pub fn ends_with(&self, inner: &Self) -> bool

Whether this placement is inner with further placements outside it: inner’s chain is this chain’s tail.

Source

pub fn chain(&self) -> &[(DatumId, i32)]

The chain, outermost entry first.

Source

pub fn depth(&self) -> usize

Number of entries.

Source

pub fn then(&self, inner: &Self) -> Self

This placement followed by inner.

outer.then(inner) applies inner first, then outer, the same order as transform composition, so a sub-shape’s placement composed with its parent’s reads the way the tree does.

Adjacent entries naming the same datum are merged by adding their powers, and an entry whose power reaches zero is dropped. That keeps a chain from growing without bound as a placement is composed and undone repeatedly, and it is what makes a.then(a.inverted()) come out exactly equal to the identity rather than merely close to it.

Source

pub fn inverted(&self) -> Self

The inverse placement.

Exact: the chain reverses and every power negates. No matrix is inverted, so l.then(&l.inverted()) is the identity structurally, not approximately.

Source

pub fn composed(&self, store: &DatumStore) -> OgeomResult<Transform>

The composed transform.

§Errors

OgeomError::Dangling if the chain names a datum the store does not hold, and OgeomError::Numeric if a negative power requires inverting a degenerate transform.

Source

pub fn preserves_handedness(&self, store: &DatumStore) -> OgeomResult<bool>

Whether the composed transform preserves handedness.

A shape placed by a handedness-reversing location has to have its orientation flipped to stay consistent, or a mirrored solid ends up inside out.

§Errors

As Location::composed.

Source

pub fn is_same_placement( &self, other: &Self, store: &DatumStore, tol: Tolerances, ) -> OgeomResult<bool>

Whether two placements put a shape in the same position.

Falls back to comparing the composed transforms, which costs more than PartialEq and answers a different question: two chains built by different routes can describe the same placement.

§Errors

As Location::composed.

Source

pub fn kind(&self, store: &DatumStore) -> OgeomResult<TransformKind>

The kind of the composed transform, for dispatch.

§Errors

As Location::composed.

Trait Implementations§

Source§

impl Clone for Location

Source§

fn clone(&self) -> Location

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Location

Source§

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

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

impl Default for Location

Source§

fn default() -> Location

Returns the “default value” for a type. Read more
Source§

impl Eq for Location

Source§

impl Hash for Location

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Location

Source§

fn eq(&self, other: &Location) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Location

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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, 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.