|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.algart.model3d.common.movement.model.SimpleItemSet net.algart.model3d.common.movement.model.GridItemSet
public class GridItemSet extends SimpleItemSet
Grid item set.
This implementation of ItemSet
interface extends SimpleItemSet
and provides better
implementation of getPossibleInteractingIndexes(int[], int)
method.
Namely, this class works with 3D grid, consisting of have centers and interaction radii
and the centers of which lie
inside this cell. It helps getPossibleInteractingIndexes(int[], int)
method
to find all "neighbours" of the given item by analysing only a limited number of grid cells
"near" the center of this item, namely at the distance depending on the interaction radius
of the given item and the maximal from interaction radii of all items. As a result, if the items are distributed
uniformly enough inside the grid and most of them implement HavingInteractionRadius
interface, the performance of getPossibleInteractingIndexes(int[], int)
method can be
near O(1).
The grid, described above, is fully built by preprocess()
method.
I remind that you should call this method after any correction in the item set,
in particular, after any changes of the coordinates of the centers.
Please see comments fo ItemSet
interface about multithreading usage.
AlgART Laboratory 2010
Modifier and Type | Class and Description |
---|---|
static class |
GridItemSet.GridRangeStyle
Method of calculating the grid bounds: which area of 3D space should be splitted into rectangular cells by GridItemSet .preprocess() method. |
Constructor and Description |
---|
GridItemSet(int dimX,
int dimY,
int dimZ,
GridItemSet.GridRangeStyle gridRangeStyle)
Creates new instance of this class, working with the grid with |
GridItemSet(ItemListBuilder itemListBuilder,
int dimX,
int dimY,
int dimZ,
GridItemSet.GridRangeStyle gridRangeStyle)
Creates new instance of this class, working with the grid with |
Modifier and Type | Method and Description |
---|---|
int |
getPossibleInteractingIndexes(int[] result,
int itemIndex)
This implementation analyses the set of grid cells, lying "near" the center of the specified item — in some sense, not farther than the sum of interaction radiis
of the given item #itemIndex and the maximal from interaction radii of all items
(for which this radius is defined and is not Double.POSITIVE_INFINITY). |
void |
preprocess()
This implementation calls the same method of the superclass
and then builds the grid, according to gridRangeStyle argument of the constructor. |
java.lang.String |
toString()
Returns a brief string description of this object. |
Methods inherited from class net.algart.model3d.common.movement.model.SimpleItemSet |
---|
add, addAll, get, getAll, getAll, removeItems, set, size |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public GridItemSet(ItemListBuilder itemListBuilder, int dimX, int dimY, int dimZ, GridItemSet.GridRangeStyle gridRangeStyle)
The gridRangeStyle specifies, what area of 3D-space should be splitted to cells.
The itemListBuilder argument specifies the builder, that will be used for creating the built-in java.util.List instance, which will really store all items.
itemListBuilder
- the builder, that will be used for creating the java.util.List instance.dimX
- the number of cells along x axis.dimY
- the number of cells along y axis.dimZ
- the number of cells along z axis.gridRangeStyle
- the algorithm of determining grid bounds.java.lang.NullPointerException
- if itemListBuilder or gridRangeStyle is null.java.lang.IllegalArgumentException
- if dimX<=0, dimY<=0, dimZ<=0,
or if the product of these 3 numbers is greater than
Integer.MAX_VALUE.public GridItemSet(int dimX, int dimY, int dimZ, GridItemSet.GridRangeStyle gridRangeStyle)
GridItemSet
(ItemListBuilder.DEFAULT
, dimX, dimY, dimZ, gridRangeStyle)
dimX
- the number of cells along x axis.dimY
- the number of cells along y axis.dimZ
- the number of cells along z axis.gridRangeStyle
- the algorithm of determining grid bounds.java.lang.NullPointerException
- if itemListBuilder or gridRangeStyle is null.java.lang.IllegalArgumentException
- if dimX<=0, dimY<=0, dimZ<=0,
or if the product of these 3 numbers is greater than
Integer.MAX_VALUE.Method Detail |
---|
public int getPossibleInteractingIndexes(int[] result, int itemIndex)
interaction radiis
of the given item #itemIndex and the maximal from interaction radii of all items
(for which this radius is defined and is not Double.POSITIVE_INFINITY).
getPossibleInteractingIndexes
in interface ItemSet
getPossibleInteractingIndexes
in class SimpleItemSet
result
- the indexes of "neighbours": items that can interact with the given item.itemIndex
- the index of the given item.java.lang.NullPointerException
- if result argument is null.java.lang.IllegalStateException
- if the length of result array is insufficient.java.lang.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= SimpleItemSet.size()
).public void preprocess()
the same method of the superclass
and then builds the grid, according to gridRangeStyle argument of the constructor.
This method reallocates memory if and only if it is the first call of this method or
the number of items size()
was changed since the last call of it.
preprocess
in interface ItemSet
preprocess
in class SimpleItemSet
public java.lang.String toString()
The result of this method may depend on implementation.
toString
in class SimpleItemSet
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Http://vpskt.ru http://vpskt.ru дымогарных труб. vpskt.ru |