com.github.skjolberg.packing.Level Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of 3d-bin-container-packing Show documentation
Show all versions of 3d-bin-container-packing Show documentation
Library for 3D rectangular bin packing
package com.github.skjolberg.packing;
import java.util.ArrayList;
/**
* A level within a container
*
*/
public class Level extends ArrayList{
private static final long serialVersionUID = 1L;
public int getHeight() {
int height = 0;
for(Placement placement : this) {
Box box = placement.getBox();
if(box.getHeight() > height) {
height = box.getHeight();
}
}
return height;
}
/**
*
* Check wheter placement is valid, i.e. no overlaps.
*
*/
public void validate() {
for(int i = 0; i < size(); i++) {
for(int j = 0; j < size(); j++) {
if(j == i) {
if(!get(i).intercets(get(j))) {
throw new IllegalArgumentException();
}
} else {
if(get(i).intercets(get(j))) {
throw new IllegalArgumentException(i + " vs " + j);
}
}
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy