public class DBox extends Object
Modifier and Type  Field and Description 

static SimpleArrayList<SimpleArrayList<DBox>> 
freeBoxes
static store of available boxes, accessible by dimension.

int[] 
length
It specifies for each dimension the length of dbox in that dimension.

int[] 
origin
It specifies point in ndimensional space where the dbox originates from.

Constructor and Description 

DBox(int dimension)
constructs a new Box.

DBox(int[] origin,
int[] length)
constructs a new Box.

Modifier and Type  Method and Description 

int 
area()
It computes the area in 2D case or volume in 3D case.

static DBox 
boundingBox(Collection<DBox> boxes)
computes the bounding box of the given collection of boxes

String 
checkInvariants()
It checks whether the DBox is consistent.

boolean 
containsPoint(int[] pointCoordinates)
It checks if this DBox contains the point as specified by an array of coordinates.

DBox 
copyInto(DBox box)
It copies this DBox into given DBox.

static void 
dispatchBox(DBox unusedBox)
It allows the system to reuse the given box by placing it into the pool of
allocated boxes.

boolean 
equals(Object obj) 
static DBox 
getAllocatedInstance(int dimension)
It returns an instance of DBox of the corresponding dimension,
using a previously allocated one if possible

int 
hashCode() 
DBox 
intersectWith(DBox other)
It intersects this DBox with the given DBox.

DBox 
intersectWith(DBox other,
int[] otherOffset)
It intersects this DBox with the given DBox, but the other DBox is
shifted by the specified offset.

DBox 
intersectWith(int[] offset,
DBox other,
int[] otherOffset)
It intersects this DBox with a view of the given DBox that was
shifted according to the given offset.

static DBox 
newBox(int dimension)
It returns an usable box, reusing a box from the pool if possible.

static String 
poolStatus()
It provides a string representation of the DBoxes which are present
in the DBox pool.

Collection<DBox> 
subtract(DBox hole,
Collection<DBox> difference)
computes the difference between this box and the given box.

Collection<DBox> 
subtractAll(Collection<DBox> others,
Collection<DBox> result)
It computes the result of a subtraction from this box of all the boxes given.

static Collection<DBox> 
subtractAll(Collection<DBox> source,
Collection<DBox> holes,
Collection<DBox> result)
It computes the result of a subtraction from the given collection of boxes of all the boxes given
in the subtracting collection.

static void 
supportDimension(int dimension)
It makes sure that there is a slot of the given dimension in the slot.

String 
toString() 
public static final SimpleArrayList<SimpleArrayList<DBox>> freeBoxes
public final int[] origin
public final int[] length
public DBox(int[] origin, int[] length)
origin
 it specifies the origin of the DBox in the ndimensional space.length
 it specifies the length of the Dbox in the ndimensional space.public DBox(int dimension)
dimension
 it specifies the dimension of the createed DBox.public static final void supportDimension(int dimension)
It has to be called at least once before using newBox() and dispatchBox().
dimension
 the number of dimensionspublic String checkInvariants()
public static final void dispatchBox(DBox unusedBox)
unusedBox
 the not used DBox which is being recycled.public static final DBox newBox(int dimension)
dimension
 it specifies number of dimensions of a requested boxpublic static final DBox getAllocatedInstance(int dimension)
dimension
 the number of dimensionspublic static String poolStatus()
public boolean containsPoint(int[] pointCoordinates)
pointCoordinates
 it specifies the point coordinates.public DBox intersectWith(DBox other)
For efficiency reasons, the DBox returned is the static instance; if it needs to be stored, a copy has to be made using clone().
other
 the DBox to intersect this one withpublic DBox intersectWith(DBox other, int[] otherOffset)
For efficiency reasons, the DBox returned is the static instance; if it needs to be stored, a copy has to be made using clone().
other
 DBox with which the intersection is computed.otherOffset
 the offsetpublic DBox intersectWith(int[] offset, DBox other, int[] otherOffset)
For efficiency reasons, the DBox returned is the static instance; if it needs to be stored, a copy has to be made using clone().
offset
 the offset to apply to this box before intersectingother
 the DBox to intersect this one withotherOffset
 the offset to apply to the other DBox before intersectingpublic Collection<DBox> subtract(DBox hole, Collection<DBox> difference)
NOTE: the collection of DBoxes returned is not minimal (in some cases, some boxes can be merged)
if needed, implement a version that can take a lexical order as argument, to allow brute force search or learning of the best decomposition
hole
 the box to subtract this box withdifference
 the collection of boxes corresponding to the remaining areapublic static DBox boundingBox(Collection<DBox> boxes)
boxes
 collection of boxespublic static Collection<DBox> subtractAll(Collection<DBox> source, Collection<DBox> holes, Collection<DBox> result)
source
 the collection of boxes to subtract fromholes
 the boxes to subtract from the source boxesresult
 the collection to store the resulting boxes intopublic Collection<DBox> subtractAll(Collection<DBox> others, Collection<DBox> result)
others
 the boxes to subtract from this boxresult
 the collection to store the resulting boxes intopublic int area()
public final DBox copyInto(DBox box)
box
 the DBox to copy this DBox intoCopyright © 2018. All rights reserved.