Struct rectangle_pack::BinSection[][src]

pub struct BinSection { /* fields omitted */ }

A rectangular section within a target bin that takes up one or more layers

Implementations

impl BinSection[src]

pub fn overlaps(&self, other: &Self) -> bool[src]

Whether or not two bin sections overlap each other.

impl BinSection[src]

pub fn new(x: u32, y: u32, z: u32, whd: WidthHeightDepth) -> Self[src]

Create a new BinSection

impl BinSection[src]

pub fn try_place(
    &self,
    incoming: &RectToInsert,
    container_comparison_fn: &ComparePotentialContainersFn,
    heuristic_fn: &BoxSizeHeuristicFn
) -> Result<(PackedLocation, [BinSection; 3]), BinSectionError>
[src]

See if a LayeredRect can fit inside of this BinSection.

If it can we return the BinSections that would be created by placing the LayeredRect inside of this BinSection.

Consider the diagram below of a smaller box placed into of a larger one.

The remaining space can be divided into three new sections.

There are several ways to make this division.

You could keep all of the space above the smaller box intact and split up the space behind and to the right of it.

But within that you have a choice between whether the overlapping space goes to right or behind box.

Or you could keep the space to the right and split the top and behind space.

etc.

There are six possible configurations of newly created sections. The configuration to use is decided on based on a a function provided by the consumer.

            ┌┬───────────────────┬┐
          ┌─┘│                 ┌─┘│
        ┌─┘  │               ┌─┘  │
      ┌─┘    │             ┌─┘    │
    ┌─┘      │           ┌─┘      │
  ┌─┘        │         ┌─┘        │
┌─┴──────────┼───────┬─┘          │
│            │       │            │
│            │       │            │
│       ┌┬───┴────┬─┐│            │
│     ┌─┘│      ┌─┘ ││            │
│   ┌─┘  │    ┌─┘   ││            │
│ ┌─┘    │  ┌─┘     ├┼───────────┬┘
├─┴──────┤ ─┘       ││         ┌─┘
│       ┌┴─┬───────┬┘│       ┌─┘   
│     ┌─┘  │     ┌─┘ │     ┌─┘     
│   ┌─┘    │   ┌─┘   │   ┌─┘       
│ ┌─┘      │ ┌─┘     │ ┌─┘         
└─┴────────┴─┴───────┴─┘           

Note

Written to be readable/maintainable, not to minimize conditional logic, under the (unverified) assumption that a release compilation will inline and dedupe the function calls and conditionals.

Trait Implementations

impl Clone for BinSection[src]

impl Copy for BinSection[src]

impl Debug for BinSection[src]

impl Default for BinSection[src]

impl Eq for BinSection[src]

impl Ord for BinSection[src]

impl PartialEq<BinSection> for BinSection[src]

impl PartialOrd<BinSection> for BinSection[src]

impl StructuralEq for BinSection[src]

impl StructuralPartialEq for BinSection[src]

Auto Trait Implementations

impl Send for BinSection

impl Sync for BinSection

impl Unpin for BinSection

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.