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]
impl BinSection
[src]impl BinSection
[src]
impl BinSection
[src]impl BinSection
[src]
impl BinSection
[src]pub fn try_place(
&self,
incoming: &RectToInsert,
container_comparison_fn: &ComparePotentialContainersFn,
heuristic_fn: &BoxSizeHeuristicFn
) -> Result<(PackedLocation, [BinSection; 3]), BinSectionError>
[src]
&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
impl Clone for BinSection
[src]
impl Clone for BinSection
[src]fn clone(&self) -> BinSection
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for BinSection
[src]
impl Copy for BinSection
[src]impl Default for BinSection
[src]
impl Default for BinSection
[src]fn default() -> BinSection
[src]
impl Eq for BinSection
[src]
impl Eq for BinSection
[src]impl Ord for BinSection
[src]
impl Ord for BinSection
[src]impl PartialEq<BinSection> for BinSection
[src]
impl PartialEq<BinSection> for BinSection
[src]fn eq(&self, other: &BinSection) -> bool
[src]
fn ne(&self, other: &BinSection) -> bool
[src]
impl PartialOrd<BinSection> for BinSection
[src]
impl PartialOrd<BinSection> for BinSection
[src]impl StructuralEq for BinSection
[src]
impl StructuralEq for BinSection
[src]impl StructuralPartialEq for BinSection
[src]
impl StructuralPartialEq for BinSection
[src]Auto Trait Implementations
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.