com.github.skjolber.packing.ep.points3d.DefaultPlacement3D Maven / Gradle / Ivy
package com.github.skjolber.packing.ep.points3d;
import java.util.ArrayList;
import java.util.List;
import com.github.skjolber.packing.api.Placement2D;
import com.github.skjolber.packing.api.Placement3D;
public class DefaultPlacement3D implements Placement3D {
protected final int x;
protected final int y;
protected final int z;
protected final int endX;
protected final int endY;
protected final int endZ;
protected final List supports;
public DefaultPlacement3D(int x, int y, int z, int endX, int endY, int endZ) {
this(x, y, z, endX, endY, endZ, new ArrayList<>());
}
public DefaultPlacement3D(int x, int y, int z, int endX, int endY, int endZ, List supports) {
this.x = x;
this.y = y;
this.z = z;
this.endX = endX;
this.endY = endY;
this.endZ = endZ;
this.supports = supports;
}
@Override
public int getAbsoluteX() {
return x;
}
@Override
public int getAbsoluteY() {
return y;
}
@Override
public int getAbsoluteEndX() {
return endX;
}
@Override
public int getAbsoluteEndY() {
return endY;
}
@Override
public boolean intersects2D(Placement2D point) {
return !(point.getAbsoluteEndX() < x || point.getAbsoluteX() > endX || point.getAbsoluteEndY() < y || point.getAbsoluteY() > endY);
}
@Override
public boolean intersects3D(Placement3D point) {
return !(point.getAbsoluteEndX() < x || point.getAbsoluteX() > endX || point.getAbsoluteEndY() < y || point.getAbsoluteY() > endY || point.getAbsoluteEndZ() < z || point.getAbsoluteZ() > endZ);
}
@Override
public int getAbsoluteZ() {
return z;
}
@Override
public int getAbsoluteEndZ() {
return endZ;
}
@Override
public String toString() {
return "DefaultPlacement3D [" + x + "x" + y + "x" + z + " " + endX + "x" + endY + "x" + endZ + "]";
}
@Override
public List getSupports3D() {
return (List) supports;
}
@Override
public List extends Placement2D> getSupports2D() {
return supports;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy