-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
200 additions
and
2 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
api/src/main/java/com/github/skjolber/packing/api/ContainerLoadConstraint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.github.skjolber.packing.api; | ||
|
||
public interface ContainerLoadConstraint { | ||
|
||
boolean canLoad(Stackable stackable, Container container); | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
api/src/main/java/com/github/skjolber/packing/api/StackableItemGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.github.skjolber.packing.api; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* | ||
* Items which belong together, for example different parts of a single product or order. | ||
* | ||
*/ | ||
|
||
public class StackableItemGroup { | ||
|
||
private String id; | ||
|
||
private List<StackableItem> items; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public List<StackableItem> getItems() { | ||
return items; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public void setItems(List<StackableItem> items) { | ||
this.items = items; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
api/src/main/java/com/github/skjolber/packing/api/StackableLoadConstraint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.github.skjolber.packing.api; | ||
|
||
/** | ||
* | ||
* Interface for reporting whether it is okey to add a stackable to a stack, given the addition of another stackable. | ||
* | ||
* This might be used to limit the number of special packages in each container, i.e. only one battery per contaner. | ||
* | ||
*/ | ||
|
||
public interface StackableLoadConstraint { | ||
|
||
boolean canLoad(Stackable stackable, Stackable loaded); | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
api/src/main/java/com/github/skjolber/packing/api/ep/Point3DFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.github.skjolber.packing.api.ep; | ||
import java.util.List; | ||
|
||
import com.github.skjolber.packing.api.ep.Point3D; | ||
|
||
/** | ||
* Constraint describing where a box can be placed within a stack. | ||
* For example, a flammable item must be stacked by the door. | ||
*/ | ||
|
||
public interface Point3DFilter { | ||
|
||
List<Point3D> filter(List<Point3D> points); | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
api/src/main/java/com/github/skjolber/packing/api/packager/DefaultLoadableItemScope.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.github.skjolber.packing.api.packager; | ||
import java.util.List; | ||
|
||
public class DefaultLoadableItemScope implements LoadableItemScope { | ||
|
||
protected final List<LoadableItem> loadableItems; | ||
|
||
public DefaultLoadableItemScope(List<LoadableItem> loadableItems) { | ||
this.loadableItems = loadableItems; | ||
} | ||
|
||
@Override | ||
public List<LoadableItem> getLoadableItems() { | ||
return loadableItems; | ||
} | ||
|
||
@Override | ||
public boolean loaded(int index) { | ||
LoadableItem loadableItem = loadableItems.get(index); | ||
loadableItem.decrement(); | ||
if(loadableItem.isEmpty()) { | ||
loadableItems.remove(index); | ||
} | ||
return false; | ||
} | ||
|
||
} |
7 changes: 5 additions & 2 deletions
7
...lber/packing/api/PlacementComparator.java → .../packing/api/packager/LoadComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
api/src/main/java/com/github/skjolber/packing/api/packager/LoadableItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.github.skjolber.packing.api.packager; | ||
|
||
import java.util.List; | ||
|
||
import com.github.skjolber.packing.api.StackValue; | ||
import com.github.skjolber.packing.api.Stackable; | ||
|
||
/** | ||
* | ||
* Stackable item which fit within certain bounds, i.e. load dimensions of a container. | ||
* | ||
*/ | ||
|
||
public class LoadableItem { | ||
|
||
protected final List<StackValue> values; | ||
protected final Stackable stackable; | ||
|
||
private int count; | ||
|
||
protected final long minVolumeLimit; | ||
protected final long minAreaLimit; | ||
|
||
public LoadableItem(Stackable stackable, List<StackValue> stackValues, int count) { | ||
this.values = stackValues; | ||
this.stackable = stackable; | ||
this.count = count; | ||
|
||
long minVolumeLimit = Long.MAX_VALUE; | ||
long minAreaLimit = Long.MAX_VALUE; | ||
|
||
for (int i = 0; i < values.size(); i++) { | ||
StackValue stackValue = values.get(i); | ||
|
||
if(minVolumeLimit > stackValue.getVolume()) { | ||
minVolumeLimit = stackValue.getVolume(); | ||
} | ||
|
||
if(minAreaLimit > stackValue.getArea()) { | ||
minAreaLimit = stackValue.getArea(); | ||
} | ||
} | ||
|
||
this.minAreaLimit = minAreaLimit; | ||
this.minVolumeLimit = minVolumeLimit; | ||
} | ||
|
||
public List<StackValue> getValues() { | ||
return values; | ||
} | ||
|
||
public long getMinAreaLimit() { | ||
return minAreaLimit; | ||
} | ||
|
||
public long getMinVolumeLimit() { | ||
return minVolumeLimit; | ||
} | ||
|
||
public Stackable getStackable() { | ||
return stackable; | ||
} | ||
|
||
public int getCount() { | ||
return count; | ||
} | ||
|
||
public void decrement() { | ||
count--; | ||
} | ||
|
||
public boolean isEmpty() { | ||
return count == 0; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
api/src/main/java/com/github/skjolber/packing/api/packager/LoadableItemScope.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.github.skjolber.packing.api.packager; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* | ||
* The items which are available for load into some particular container. | ||
* | ||
*/ | ||
|
||
public interface LoadableItemScope { | ||
|
||
List<LoadableItem> getLoadableItems(); | ||
|
||
/** | ||
* | ||
* Notify item was loaded | ||
* | ||
* @param index | ||
* @return true if some loadable item was excluded due to this | ||
*/ | ||
|
||
boolean loaded(int index); | ||
} |