Struct rectangle_pack::BinSection
source · pub struct BinSection { /* private fields */ }
Expand description
A rectangular section within a target bin that takes up one or more layers
Implementations§
source§impl BinSection
impl BinSection
source§impl BinSection
impl BinSection
source§impl BinSection
impl BinSection
sourcepub fn try_place(
&self,
incoming: &RectToInsert,
container_comparison_fn: &ComparePotentialContainersFn,
heuristic_fn: &BoxSizeHeuristicFn
) -> Result<(PackedLocation, [BinSection; 3]), BinSectionError>
pub fn try_place( &self, incoming: &RectToInsert, container_comparison_fn: &ComparePotentialContainersFn, heuristic_fn: &BoxSizeHeuristicFn ) -> Result<(PackedLocation, [BinSection; 3]), BinSectionError>
See if a LayeredRect
can fit inside of this BinSection.
If it can we return the BinSection
s 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§
source§impl Clone for BinSection
impl Clone for BinSection
source§fn clone(&self) -> BinSection
fn clone(&self) -> BinSection
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for BinSection
impl Debug for BinSection
source§impl Default for BinSection
impl Default for BinSection
source§fn default() -> BinSection
fn default() -> BinSection
source§impl Ord for BinSection
impl Ord for BinSection
source§fn cmp(&self, other: &BinSection) -> Ordering
fn cmp(&self, other: &BinSection) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for BinSection
impl PartialEq for BinSection
source§fn eq(&self, other: &BinSection) -> bool
fn eq(&self, other: &BinSection) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for BinSection
impl PartialOrd for BinSection
source§fn partial_cmp(&self, other: &BinSection) -> Option<Ordering>
fn partial_cmp(&self, other: &BinSection) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more