-
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
105 changed files
with
1,844 additions
and
2,824 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
api/src/main/java/com/github/skjolber/packing/api/AbstractStackScopeConstraintBuilder.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,33 @@ | ||
package com.github.skjolber.packing.api; | ||
|
||
import java.util.List; | ||
|
||
public abstract class AbstractStackScopeConstraintBuilder<B extends AbstractStackScopeConstraintBuilder<B>> { | ||
|
||
protected List<Stackable> stackables; | ||
protected Container container; | ||
protected ContainerStackValue containerStackValue; | ||
protected Stack stack; | ||
|
||
public B withContainer(Container container) { | ||
this.container = container; | ||
return (B)this; | ||
} | ||
|
||
public B withStack(Stack stack) { | ||
this.stack = stack; | ||
return (B)this; | ||
} | ||
|
||
public B withContainerStackValue(ContainerStackValue containerStackValue) { | ||
this.containerStackValue = containerStackValue; | ||
return (B)this; | ||
} | ||
|
||
public B withStackables(List<Stackable> stackables) { | ||
this.stackables = stackables; | ||
return (B)this; | ||
} | ||
|
||
public abstract StackScopeConstraint build(); | ||
} |
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
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
31 changes: 31 additions & 0 deletions
31
api/src/main/java/com/github/skjolber/packing/api/ContainerLoadStackValue.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,31 @@ | ||
package com.github.skjolber.packing.api; | ||
|
||
import com.github.skjolber.packing.api.StackValue; | ||
import com.github.skjolber.packing.api.Stackable; | ||
|
||
/** | ||
* | ||
* A {@linkplain Stackable} in a specific {@linkplain StackValue}. | ||
* | ||
*/ | ||
|
||
public class ContainerLoadStackValue { | ||
|
||
private final Stackable stackable; | ||
private final StackValue value; | ||
|
||
public ContainerLoadStackValue(Stackable stackable, StackValue value) { | ||
super(); | ||
this.stackable = stackable; | ||
this.value = value; | ||
} | ||
|
||
public Stackable getStackable() { | ||
return stackable; | ||
} | ||
|
||
public StackValue getValue() { | ||
return value; | ||
} | ||
|
||
} |
74 changes: 74 additions & 0 deletions
74
api/src/main/java/com/github/skjolber/packing/api/ContainerLoadable.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,74 @@ | ||
package com.github.skjolber.packing.api; | ||
|
||
import java.util.List; | ||
|
||
import com.github.skjolber.packing.api.StackValue; | ||
import com.github.skjolber.packing.api.Stackable; | ||
|
||
public class ContainerLoadable { | ||
|
||
protected final ContainerLoadStackValue[] values; | ||
protected final Stackable stackable; | ||
|
||
protected final long minVolumeLimit; | ||
protected final long minAreaLimit; | ||
|
||
public ContainerLoadable(Stackable stackable, List<StackValue> stackValues) { | ||
this.values = new ContainerLoadStackValue[stackValues.size()]; | ||
this.stackable = stackable; | ||
|
||
long minVolumeLimit = Long.MAX_VALUE; | ||
long minAreaLimit = Long.MAX_VALUE; | ||
|
||
for (int i = 0; i < values.length; i++) { | ||
StackValue stackValue = stackValues.get(i); | ||
|
||
values[i] = new ContainerLoadStackValue(stackable, stackValue); | ||
|
||
if(minVolumeLimit > stackValue.getVolume()) { | ||
minVolumeLimit = stackValue.getVolume(); | ||
} | ||
|
||
if(minAreaLimit > stackValue.getArea()) { | ||
minAreaLimit = stackValue.getArea(); | ||
} | ||
} | ||
|
||
this.minAreaLimit = minAreaLimit; | ||
this.minVolumeLimit = minVolumeLimit; | ||
} | ||
|
||
public ContainerLoadable(ContainerLoadable clone) { | ||
// clone working object in order to improve performance | ||
this.values = new ContainerLoadStackValue[clone.values.length]; | ||
this.stackable = clone.stackable.clone(); | ||
for (int i = 0; i < values.length; i++) { | ||
ContainerLoadStackValue permutationRotation = clone.values[i]; | ||
values[i] = new ContainerLoadStackValue(permutationRotation.getStackable().clone(), permutationRotation.getValue().clone()); | ||
|
||
} | ||
this.minAreaLimit = clone.minAreaLimit; | ||
this.minVolumeLimit = clone.minVolumeLimit; | ||
|
||
} | ||
|
||
public ContainerLoadStackValue[] getBoxes() { | ||
return values; | ||
} | ||
|
||
public long getMinAreaLimit() { | ||
return minAreaLimit; | ||
} | ||
|
||
public long getMinVolumeLimit() { | ||
return minVolumeLimit; | ||
} | ||
|
||
public Stackable getStackable() { | ||
return stackable; | ||
} | ||
|
||
public ContainerLoadable clone() { | ||
return new ContainerLoadable(this); | ||
} | ||
} |
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
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
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
29 changes: 29 additions & 0 deletions
29
api/src/main/java/com/github/skjolber/packing/api/DefaultStackScopeConstraint.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,29 @@ | ||
package com.github.skjolber.packing.api; | ||
|
||
import java.util.List; | ||
|
||
public class DefaultStackScopeConstraint implements StackScopeConstraint { | ||
|
||
protected final List<Stackable> stackables; | ||
protected final Container container; | ||
protected final ContainerStackValue containerStackValue; | ||
protected final Stack stack; | ||
|
||
public DefaultStackScopeConstraint(List<Stackable> stackables, Container container, ContainerStackValue containerStackValue, Stack stack) { | ||
this.stackables = stackables; | ||
this.container = container; | ||
this.containerStackValue = containerStackValue; | ||
this.stack = stack; | ||
} | ||
|
||
@Override | ||
public List<Stackable> getStackScope() { | ||
return stackables; | ||
} | ||
|
||
@Override | ||
public void stacked(int index) { | ||
stackables.remove(index); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
api/src/main/java/com/github/skjolber/packing/api/DefaultStackScopeConstraintBuilder.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,10 @@ | ||
package com.github.skjolber.packing.api; | ||
|
||
public class DefaultStackScopeConstraintBuilder extends AbstractStackScopeConstraintBuilder<DefaultStackScopeConstraintBuilder> { | ||
|
||
@Override | ||
public StackScopeConstraint build() { | ||
return new DefaultStackScopeConstraint(stackables, container, containerStackValue, stack); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
api/src/main/java/com/github/skjolber/packing/api/FixedOrderStackScopeConstraint.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,11 @@ | ||
package com.github.skjolber.packing.api; | ||
|
||
import java.util.List; | ||
|
||
public interface FixedOrderStackScopeConstraint { | ||
|
||
List<Stackable> getStackScope(); | ||
|
||
void stacked(int index); | ||
|
||
} |
33 changes: 0 additions & 33 deletions
33
api/src/main/java/com/github/skjolber/packing/api/HorizontalSupport.java
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
api/src/main/java/com/github/skjolber/packing/api/Placement2D.java
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
api/src/main/java/com/github/skjolber/packing/api/Placement3D.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.