All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.skjolber.packing.ep.points3d.DefaultXZPlanePoint3D Maven / Gradle / Ivy

There is a newer version: 3.0.9
Show newest version
package com.github.skjolber.packing.ep.points3d;

import java.util.ArrayList;
import java.util.List;

import com.github.skjolber.packing.api.Placement3D;
import com.github.skjolber.packing.api.ep.Point3D;
import com.github.skjolber.packing.api.ep.XZPlanePoint3D;

public class DefaultXZPlanePoint3D

extends Point3D

implements XZPlanePoint3D { /** range constrained to current minY */ private final P xzPlane; public DefaultXZPlanePoint3D( int minX, int minY, int minZ, int maxX, int maxY, int maxZ, P xzPlane ) { super(minX, minY, minZ, maxX, maxY, maxZ); this.xzPlane = xzPlane; } public int getSupportedXZPlaneMinX() { return xzPlane.getAbsoluteX(); } public int getSupportedXZPlaneMaxX() { return xzPlane.getAbsoluteEndX(); } @Override public int getSupportedXZPlaneMaxZ() { return xzPlane.getAbsoluteZ(); } @Override public int getSupportedXZPlaneMinZ() { return xzPlane.getAbsoluteEndZ(); } @Override public boolean isSupportedXZPlane(int x, int z) { return xzPlane.getAbsoluteX() <= x && x <= xzPlane.getAbsoluteEndX() && xzPlane.getAbsoluteZ() <= z && z <= xzPlane.getAbsoluteEndZ(); } public boolean isXZPlaneEdgeX(int x) { return xzPlane.getAbsoluteX() == x - 1; } public boolean isXZPlaneEdgeZ(int z) { return xzPlane.getAbsoluteEndZ() == z - 1; } @Override public Point3D

clone(int maxX, int maxY, int maxZ) { return new DefaultXZPlanePoint3D<>( minX, minY, minZ, maxX, maxY, maxZ, xzPlane ); } @Override public Placement3D getXZPlane() { return xzPlane; } @Override public List

getPlacements3D() { List

list = new ArrayList<>(); list.add(xzPlane); return list; } @Override public List

getPlacements2D() { List

list = new ArrayList<>(); list.add(xzPlane); return list; } @Override public DefaultXZPlanePoint3D

clone() { return new DefaultXZPlanePoint3D<>(minX, minY, minZ, maxX, maxY, maxZ, xzPlane); } @Override public Point3D

moveX(int x, int maxX, int maxY, int maxZ) { if(x <= xzPlane.getAbsoluteEndX()) { return new DefaultXZPlanePoint3D<>(x, minY, minZ, maxX, maxY, maxZ, xzPlane); } // xzPlane support is lost return new DefaultPoint3D<>(x, minY, minZ, maxX, maxY, maxZ); } @Override public Point3D

moveX(int x, int maxX, int maxY, int maxZ, P yzSupport) { if(x <= xzPlane.getAbsoluteEndX()) { return new DefaultXZPlaneYZPlanePoint3D<>(x, minY, minZ, maxX, maxY, maxZ, xzPlane, yzSupport); } // xzPlane support is lost return new DefaultYZPlanePoint3D<>(x, minY, minZ, maxX, maxY, maxZ, yzSupport); } @Override public Point3D

moveY(int y, int maxX, int maxY, int maxZ) { // xzPlane support is lost return new DefaultPoint3D<>(minX, y, minZ, maxX, maxY, maxZ); } @Override public Point3D

moveY(int y, int maxX, int maxY, int maxZ, P xzSupport) { // xzPlane support is lost return new DefaultXZPlanePoint3D<>(minX, y, minZ, maxX, maxY, maxZ, xzSupport); } @Override public Point3D

moveZ(int z, int maxX, int maxY, int maxZ) { if(z <= xzPlane.getAbsoluteEndZ()) { return new DefaultXZPlanePoint3D<>(minX, minY, z, maxX, maxY, maxZ, xzPlane); } // all previous plane support is lost return new DefaultPoint3D<>(minX, minY, z, maxX, maxY, maxZ); } @Override public Point3D

moveZ(int z, int maxX, int maxY, int maxZ, P xySupport) { if(z <= xzPlane.getAbsoluteEndZ()) { return new DefaultXYPlaneXZPlanePoint3D<>(minX, minY, z, maxX, maxY, maxZ, xzPlane, xySupport); } // all previous plane support is lost return new DefaultXYPlanePoint3D<>(minX, minY, z, maxX, maxY, maxZ, xySupport); } /** * Rotate box, i.e. in 3D * * @return this instance */ @Override public Point3D

rotate() { return new DefaultPoint3D<>(minY, minZ, minX, maxY, maxZ, maxX); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy