Skip to main content

Shape

Struct Shape 

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

A shape: a topology node, a placement, and an orientation.

Cheap to copy (a key, a small chain and an enum), so it is passed by value everywhere.

Implementations§

Source§

impl Shape

Source

pub const fn new( node: TShapeId, location: Location, orientation: Orientation, ) -> Self

A shape from its three parts.

Source

pub fn of(node: TShapeId) -> Self

A shape at the identity placement, oriented forward.

Source

pub const fn node(&self) -> TShapeId

The topology node.

Source

pub const fn location(&self) -> &Location

The placement.

Source

pub const fn orientation(&self) -> Orientation

The orientation.

Source

pub fn located(&self, location: Location) -> Self

This shape with a different placement.

Source

pub fn moved(&self, outer: &Location) -> Self

This shape moved by outer, applied before its own placement.

The operation traversal uses on descent: a child’s placement within the world is its parent’s composed with its own.

Source

pub fn oriented(&self, orientation: Orientation) -> Self

This shape with a different orientation.

Source

pub fn reversed(&self) -> Self

This shape with its orientation reversed.

Source

pub fn composed(&self, outer: Orientation) -> Self

This shape’s orientation composed under outer.

The other half of what traversal does on descent.

Source

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

The composed placement as a transform.

§Errors

As Location::composed.

Source

pub fn is_partner(&self, other: &Self) -> bool

Whether two shapes share a topology node, ignoring placement and orientation.

“Is this the same underlying topology, anywhere, any way round?”: the question to ask when relating a shape to another instance of itself elsewhere in an assembly.

Source

pub fn is_same(&self, other: &Self) -> bool

Whether two shapes share a node and a placement, ignoring orientation.

The common case, and the one most algorithms want: an edge and its reverse are the same edge in the same place, and a set of edges should hold one of them, not two.

Source

pub fn is_equal(&self, other: &Self) -> bool

Whether two shapes agree in all three parts.

Exact identity. An edge and its reverse are not equal, which is what makes a wire’s direction of travel expressible.

Source

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

Whether two shapes occupy the same place, comparing composed transforms rather than chains.

Costlier than Shape::is_same and answers a different question: two placements built by different routes can land in the same position.

§Errors

As Location::composed.

Trait Implementations§

Source§

impl Clone for Shape

Source§

fn clone(&self) -> Shape

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 Shape

Source§

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

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

impl Eq for Shape

Source§

impl Hash for Shape

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 Shape

Equality by Shape::is_equal: node, placement and orientation.

The strictest of the three, chosen as the derive-shaped default so that a plain == never silently means something looser than the reader expects. Code that wants a weaker equivalence says so, through SameKey or PartnerKey.

Source§

fn eq(&self, other: &Self) -> 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.

Auto Trait Implementations§

§

impl Freeze for Shape

§

impl RefUnwindSafe for Shape

§

impl Send for Shape

§

impl Sync for Shape

§

impl Unpin for Shape

§

impl UnsafeUnpin for Shape

§

impl UnwindSafe for Shape

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.