public abstract class AbstractUniformGridPattern extends AbstractPattern implements UniformGridPattern
A skeletal implementation of the UniformGridPattern
interface to minimize
the effort required to implement this interface.
All nonabstract methods are completely implemented here and may be not overridden in subclasses.
dimCount
MAX_COORDINATE
Modifier  Constructor and Description 

protected 
AbstractUniformGridPattern(Point originOfGrid,
double[] stepsOfGrid,
boolean trivialUnionDecomposition)
Creates a uniform grid pattern with the given origin and steps of the grid.

Modifier and Type  Method and Description 

java.util.List<java.util.List<Pattern>> 
allUnionDecompositions(int minimalPointCount)
This implementation uses a common algorithm that usually provide good results.

UniformGridPattern 
carcass()
//TODO!!  that it checks isActuallyRectangular()
This method is fully implemented in this class and usually should not be overridden.

Range 
coordRange(int coordIndex)
Returns the minimal and maximal coordinate with the given index
(
Point.coord(coordIndex) )
among all points of this pattern. 
IRectangularArea 
gridIndexArea()
This implementation is based on the loop of calls of
gridIndexRange(int) method
for all coordinate indexes from 0 to AbstractPattern.dimCount() 1. 
abstract java.util.Set<IPoint> 
gridIndexes()
Returns a set of all grid indexes i_{j} of this pattern.

IPoint 
gridIndexMax()
This implementation is based on the loop of calls of
gridIndexRange(int) method
for all coordinate indexes from 0 to AbstractPattern.dimCount() 1. 
IPoint 
gridIndexMin()
This implementation is based on the loop of calls of
gridIndexRange(int) method
for all coordinate indexes from 0 to AbstractPattern.dimCount() 1. 
abstract UniformGridPattern 
gridIndexPattern()
Returns an
ordinary integer pattern with the same set of grid indexes
i_{j}^{(k)} as this pattern. 
abstract IRange 
gridIndexRange(int coordIndex)
Returns the minimal and maximal grid index i_{j}
among all points of this pattern
for the specified coordinate index j==coordIndex.

protected java.lang.String 
gridToString() 
boolean 
hasMinkowskiDecomposition()
This implementation returns
minkowskiDecomposition(0) .size()>1. 
boolean 
isActuallyRectangular()
This implementation returns true if and only if
pointCount() =r_{0}r_{1}...<Long.MAX_VALUE,
where r_{i}=gridIndexRange(i) .size() . 
static boolean 
isAllowedGridIndex(IPoint gridIndex) 
static boolean 
isAllowedGridIndexRange(IRange gridIndexRange) 
boolean 
isOrdinary()
Returns true if and only if this uniformgrid pattern is an ordinary integer pattern,
i.e. if the grid origin o is the origin of coordinates (0,0,...,0)
and all grid steps d_{j} are 1.0.

boolean 
isSurelyInteger()
This implementation calls
AbstractPattern.points() method and checks, whether all returned points are integer,
i.e. Point.isInteger() method returns true for all elements the returned set. 
UniformGridPattern 
lowerSurface(int coordIndex)
Returns the lower boundary of this pattern along the given axis:
a pattern consisting of all such points A of this pattern,
that the neighbour point B,
generated by the backward shift of point A along the coordinate #j=coordIndex
by the corresponding grid step
stepOfGrid(coordIndex) 
UniformGridPattern 
maxBound(int coordIndex)
This implementation calls
AbstractPattern.points() method and builds the result on the base of analysis
of the returned point set. 
int 
maxCarcassMultiplier()
//TODO!!  write that it checks isActuallyRectangular()
This method is fully implemented in this class and usually should not be overridden.

UniformGridPattern 
minBound(int coordIndex)
This implementation calls
AbstractPattern.points() method and builds the result on the base of analysis
of the returned point set. 
Pattern 
minkowskiAdd(Pattern added)
This implementation is based on the loop on all points returned by
roundedPoints() method in both patterns
and always returns the simple pattern
consisting of sums of all point pairs. 
java.util.List<Pattern> 
minkowskiDecomposition(int minimalPointCount)
This implementation returns Collections.<Pattern>singletonList(thisInstance)
for nonrectangular patterns or a good decomposition if
isActuallyRectangular() method
returns true. 
Pattern 
minkowskiSubtract(Pattern subtracted)
This implementation is based on the loop on all points returned by
roundedPoints()
method in both patterns
and always returns the simple pattern
consisting of sums of all point pairs. 
UniformGridPattern 
multiply(double multiplier)
This implementation creates Java array double[] by the call
"
AbstractPattern.dimCount ]scale(a) . 
Point 
originOfGrid()
This implementation returns the grid origin, specified in the constructor.

abstract long 
pointCount()
Returns the number of points in this pattern.

java.util.Set<Point> 
points()
Returns a set of all points of this pattern.

abstract UniformGridPattern 
projectionAlongAxis(int coordIndex)
Returns the projection of this pattern along the given axis.

UniformGridPattern 
round()
This implementation calls
AbstractPattern.roundedPoints() method and constructs a new integer pattern on the base
of this set, like as it is performed in Patterns.newIntegerPattern(java.util.Collection) method. 
java.util.Set<IPoint> 
roundedPoints()
This implementation calls
AbstractPattern.points() method and returns a new set, built from the returned set of
real points by conversion of every point to an integer point via Point.toRoundedPoint() method,
as written in
comments to this method in Pattern interface . 
abstract UniformGridPattern 
scale(double... multipliers)
Returns this pattern, scaled by the specified multipliers along all coordinates.

abstract UniformGridPattern 
shift(Point shift)
Returns this pattern, shifted by the argument.

abstract UniformGridPattern 
shiftGridIndexes(IPoint shift)
Returns another uniformgrid pattern, identical to this one with the only difference, that
the grid index
add (shift). 
double 
stepOfGrid(int coordIndex)
Returns the grid step d_{j} along the coordinate #j of this pattern
along the coordinate #j=coordIndex.

double[] 
stepsOfGrid()
This implementation returns a new copy of Java array of grid steps, specified in the constructor.

boolean 
stepsOfGridEqual(UniformGridPattern pattern)
Indicates whether the other uniformgrid pattern has the same grid steps.

Pattern 
surface()
Returns the settheoretical union of all patterns, returned by
UniformGridPattern.lowerSurface(int)
UniformGridPattern.upperSurface(int) methods for all coordinates. 
UniformGridPattern 
symmetric()
This implementation calls
multiply(1.0) . 
UniformGridPattern 
upperSurface(int coordIndex)
Returns the upper boundary of this pattern along the given axis:
a pattern consisting of all such points A of this pattern,
that the neighbour point B,
generated by the forward shift of point A along the coordinate #j=coordIndex
by the corresponding grid step
stepOfGrid(coordIndex) 
checkCoordIndex, coordArea, coordMax, coordMin, dimCount, isAllowedCoordRange, isAllowedPoint, isPointCountVeryLarge, isSurelyOriginPoint, isSurelySinglePoint, largePointCount, roundedCoordArea, roundedCoordRange, unionDecomposition
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
coordArea, coordMax, coordMin, dimCount, isSurelyOriginPoint, isSurelySinglePoint, largePointCount, roundedCoordArea, roundedCoordRange, unionDecomposition
protected AbstractUniformGridPattern(Point originOfGrid, double[] stepsOfGrid, boolean trivialUnionDecomposition)
The trivialUnionDecomposition determines behavior of
AbstractPattern.unionDecomposition(int)
and allUnionDecompositions(int)
methods.
If it is false, they will perform some common algorithm
suitable for most patterns, that have no good Minkowski decompositions (alike spheres).
If it is true, they will return degenerated decomposition
consisting of this pattern as the only element.
You should use true argument in inheritors that have
a good Minkowski decomposition.
The passed stepsOfGrid argument is cloned by this method: no references to it are maintained by the created pattern.
originOfGrid
 the origin of the grid
.stepsOfGrid
 the steps of the grid
.trivialUnionDecomposition
 whether this pattern has the degenerated union decomposition.java.lang.NullPointerException
 if originOfGrid or stepsOfGrid argument is null.java.lang.IllegalArgumentException
 if originOfGrid.coordCount()
!=stepsOfGrid.length, or if one of the passed steps
is zero (==0.0).public Point originOfGrid()
originOfGrid
in interface UniformGridPattern
public double[] stepsOfGrid()
stepsOfGrid
in interface UniformGridPattern
public double stepOfGrid(int coordIndex)
UniformGridPattern
UniformGridPattern.stepsOfGrid()
[coordIndex], but works faster.
There is a guarantee, that this method always works very quickly
(maximally O(dimCount()
) operations) and without exceptions.
stepOfGrid
in interface UniformGridPattern
public boolean stepsOfGridEqual(UniformGridPattern pattern)
UniformGridPattern
dimCount()
)
and the corresponding grid steps stepOfGrid((k)
are equal for every k.
Note: this method does not compare the origin of grid.
Equality of grid steps is important, for example, while calculation of a Minkowski sum
of this and another patterns by Pattern.minkowskiAdd(Pattern)
method.
If two uniformgrid patterns have identical grid steps, then a Minkowski sum of them
can be also represented by uniformgrid pattern (with same grid steps).
In other case, it is usually impossible — the Minkowski sum, returned by
Pattern.minkowskiAdd(Pattern)
, will not implement UniformGridPattern
.
stepsOfGridEqual
in interface UniformGridPattern
pattern
 another uniformgrid pattern,
the grid steps of which should be compared with grid steps of this one.public abstract java.util.Set<IPoint> gridIndexes()
UniformGridPattern
x_{0}^{(k)} = o_{0} + i_{0}^{(k)}d_{0}
x_{1}^{(k)} = o_{1} + i_{1}^{(k)}d_{1}
. . .
x_{n−1}^{(k)} = o_{n−1} + i_{n−1}^{(k)}d_{n−1}
The result of this method is immutable (Collections.unmodifiableSet).
Moreover, the result is always the same for different calls of this method for the same instance —
there are no ways to change it, in particular, via any custom methods of the implementation class
(it is a conclusion from the common requirement, that all implementations of Pattern
interface must be
immutable).
The returned set is always nonempty,
and the number of its elements is always equal to Pattern.pointCount()
.
Warning! This method can work slowly for some forms of large patterns.
In these cases, this method can also throw TooManyPointsInPatternError
or OutOfMemoryError.
This method surely fails (throws one of these exception), if the total number of points
Pattern.pointCount()
>Integer.MAX_VALUE, because Java Set object
cannot contain more than Integer.MAX_VALUE elements.
For example, implementations of the rectangular patterns
allow to successfully define a very large 3D parallelepiped
TooManyPointsInPatternError
)
for n=2000 (2000^{3}>Integer.MAX_VALUE).
There is a guarantee, that if this object implements DirectPointSetPattern
interface,
then this method requires not greater than O(N) operations and memory
(N=pointCount()
)
and never throws TooManyPointsInPatternError
.
Note: if you do not really need to get a Java collection of all grid indexes,
you can use UniformGridPattern.gridIndexPattern()
method, which returns the same result in a form
of another (integer) pattern. That method, unlike this one, never spends extreme amount of memory
and time and has no risk to fail with TooManyPointsInPatternError
/ OutOfMemoryError.
gridIndexes
in interface UniformGridPattern
UniformGridPattern.gridIndexPattern()
public abstract IRange gridIndexRange(int coordIndex)
UniformGridPattern
min()
,
the maximal grid index will be r.max()
,
where r is the result of this method.
See the comments to this interface
for more details.
There is a guarantee, that if this object implements RectangularPattern
interface,
then this method works very quickly (O(1) operations) and without exceptions.
Moreover, all patterns, implemented in this package, have very quick implementations of this method (O(1) operations). Also, the implementations of this method in this package never throw exceptions.
It is theoretically possible, that in custom implementations of this interface
(outside this package) this method will work slowly, up to O(N) operations,
N is the number of points in this pattern.
However, even in such implementations this method must not lead to
TooManyPointsInPatternError
/ OutOfMemoryError, like Pattern.points()
method.
gridIndexRange
in interface UniformGridPattern
coordIndex
 the index j of the coordinate (0 for x, 1 for y, 2 for z, etc.).UniformGridPattern.gridIndexMin()
,
UniformGridPattern.gridIndexMax()
,
UniformGridPattern.gridIndexArea()
public IRectangularArea gridIndexArea()
gridIndexRange(int)
method
for all coordinate indexes from 0 to AbstractPattern.dimCount()
1.gridIndexArea
in interface UniformGridPattern
public IPoint gridIndexMin()
gridIndexRange(int)
method
for all coordinate indexes from 0 to AbstractPattern.dimCount()
1.gridIndexMin
in interface UniformGridPattern
public IPoint gridIndexMax()
gridIndexRange(int)
method
for all coordinate indexes from 0 to AbstractPattern.dimCount()
1.gridIndexMax
in interface UniformGridPattern
public final boolean isOrdinary()
UniformGridPattern
UniformGridPattern.originOfGrid()
.isOrigin()
&& gridIndexRange
(0)==1.0
&& gridIndexRange
(1)==1.0
&& ...
Ordinary integer patterns are a simplest form of integer pattern:
see comments to Pattern
interface, section "Uniformgrid patterns".
There is a guarantee, that this method always works very quickly
(maximally O(dimCount()
) operations) and without exceptions.
isOrdinary
in interface UniformGridPattern
public boolean isActuallyRectangular()
pointCount()
=r_{0}r_{1}...<Long.MAX_VALUE,
where r_{i}=gridIndexRange(i)
.size()
.
This method caches its results: the following calls will work faster.
This method does not provide correct result, if a pattern contains ≥Long.MAX_VALUE points.
This method should be overridden for rectangular patterns, implementing RectangularPattern
interface, or for patterns that surely are not rectangular.
isActuallyRectangular
in interface UniformGridPattern
public abstract UniformGridPattern gridIndexPattern()
UniformGridPattern
ordinary
integer pattern with the same set of grid indexes
i_{j}^{(k)} as this pattern.
In other words, if this pattern is a set of points
x_{0}^{(k)} = o_{0} + i_{0}^{(k)}d_{0}
x_{1}^{(k)} = o_{1} + i_{1}^{(k)}d_{1}
. . .
x_{n−1}^{(k)} = o_{n−1} + i_{n−1}^{(k)}d_{n−1}
(k=0,1,...,N−1, n=dimCount()
), then the returned pattern
consists of points
y_{0}^{(k)} = (double)i_{0}^{(k)}
y_{1}^{(k)} = (double)i_{1}^{(k)}
. . .
y_{n−1}^{(k)} = (double)i_{n−1}^{(k)}
Note: here is a guarantee, that all grid indexes i_{j} will be strictly
represented by double type.
Moreover, there is a guarantee that the returned pattern is correct, i.e. will be successfully built
without a risk of TooLargePatternCoordinatesException
.
See the comments to Pattern.MAX_COORDINATE
and the section "Grid index restrictions" in the comments to UniformGridPattern
interface.
You can use this method to get a set of all grid indexes (integer values):
it is enough to call Pattern.roundedPoints()
in the returned pattern.
The results will be the same as the result of UniformGridPattern.gridIndexes()
method.
The returned pattern always implements DirectPointSetPattern
if this pattern implements DirectPointSetPattern
.
The returned pattern always implements RectangularPattern
if this pattern implements RectangularPattern
.
There is a guarantee, that this method does not try to allocate much more memory,
that it is required for storing this pattern itself, and that it
never throws TooManyPointsInPatternError
.
This method works quickly enough: in the worst case,
it can require O(N) operations (N=pointCount()
).
gridIndexPattern
in interface UniformGridPattern
UniformGridPattern.gridIndexes()
public abstract UniformGridPattern shiftGridIndexes(IPoint shift)
UniformGridPattern
add
(shift).
In other words, if this pattern is a set of points
x_{0}^{(k)} = o_{0} + i_{0}^{(k)}d_{0}
x_{1}^{(k)} = o_{1} + i_{1}^{(k)}d_{1}
. . .
x_{n−1}^{(k)} = o_{n−1} + i_{n−1}^{(k)}d_{n−1}
(k=0,1,...,N−1, n=dimCount()
), then the returned pattern
has the same grid oridin
, the same grid steps
and consists of points
y_{0}^{(k)} = o_{0} + (i_{0}^{(k)}+shift.coord
(0))*d_{0}
y_{1}^{(k)} = o_{1} + (i_{1}^{(k)}+shift.coord
(1))*d_{1}
. . .
y_{n−1}^{(k)} = o_{n−1} + (i_{n−1}^{(k)}+shift.coord
(n−1))*d_{n−1}
The returned pattern always implements DirectPointSetPattern
if this pattern implements DirectPointSetPattern
The returned pattern always implements RectangularPattern
if this pattern implements RectangularPattern
.
There is a guarantee, that this method does not try to allocate much more memory,
that it is required for storing this pattern itself, and that it
never throws TooManyPointsInPatternError
.
For comparison, an attempt to do the same operation via getting all grid indexes via
UniformGridPattern.gridIndexes()
call, correcting them and forming a new pattern via
Patterns.newUniformGridPattern(Point, double[], java.util.Collection)
will lead to TooManyPointsInPatternError
/ OutOfMemoryError for some forms of large patterns.
Warning: this method can fail with TooLargePatternCoordinatesException
, if some of new points
violate restrictions, described in the comments to Pattern
interface,
section "Coordinate restrictions", and in the comments to UniformGridPattern
interface,
section "Coordinate restrictions" (for example, due to very large shift).
Note: the similar results can be got with help of UniformGridPattern.shift(Point)
method
with a corresponding floatingpoint shift. However, this method
guarantees that the returned pattern has the same origin of the grid, but corrected grid indexes.
Unlike this, a good implementation of UniformGridPattern.shift(Point)
method just corrects the grid origin,
but does not change grid indexes. This difference is important, if you are going to get
the grid indexes from the shifted pattern via UniformGridPattern.gridIndexPattern()
or UniformGridPattern.gridIndexes()
method.
shiftGridIndexes
in interface UniformGridPattern
shift
 the shift of the grid indexes.public UniformGridPattern lowerSurface(int coordIndex)
UniformGridPattern
stepOfGrid(coordIndex)
dimCount()
) is the same as in this one.
In other words, the point
Please compare with UniformGridPattern.minBound(int)
method. This method can return a pattern
containing more points than UniformGridPattern.minBound(int)
, in particular, if this pattern contains some "holes".
The returned pattern always implements DirectPointSetPattern
if this pattern implements DirectPointSetPattern
The returned pattern always implements RectangularPattern
if this pattern implements RectangularPattern
.
Note: if this object is not DirectPointSetPattern
and is not RectangularPattern
, this method can work slowly for some large patterns:
the required time can be O(N), where N is the number of points.
In these cases, this method can also throw TooManyPointsInPatternError
or OutOfMemoryError. The situation is like in Pattern.points()
and Pattern.roundedPoints()
method.
However, this situation is possible only in custom implementation of this interface —
all implementations, provided by this package, implement either DirectPointSetPattern
or RectangularPattern
interface.
There is a guarantee, that if this object implements DirectPointSetPattern
interface,
then this method requires not greater than O(N) memory
(N=pointCount()
)
and never throws TooManyPointsInPatternError
.
There is a guarantee, that if this object implements RectangularPattern
interface,
then this method works quickly (O(1) operations) and without exceptions.
lowerSurface
in interface UniformGridPattern
coordIndex
 the index of the coordinate (0 for x, 1 for y, 2 for z, etc.)public UniformGridPattern upperSurface(int coordIndex)
UniformGridPattern
stepOfGrid(coordIndex)
dimCount()
) is the same as in this one.
In other words, the point
Please compare with UniformGridPattern.maxBound(int)
method. This method can return a pattern
containing more points than UniformGridPattern.maxBound(int)
, in particular, if this pattern contains some "holes".
The returned pattern always implements DirectPointSetPattern
if this pattern implements DirectPointSetPattern
The returned pattern always implements RectangularPattern
if this pattern implements RectangularPattern
.
Note: if this object is not DirectPointSetPattern
and is not RectangularPattern
, this method can work slowly for some large patterns:
the required time can be O(N), where N is the number of points.
In these cases, this method can also throw TooManyPointsInPatternError
or OutOfMemoryError. The situation is like in Pattern.points()
and Pattern.roundedPoints()
method.
However, this situation is possible only in custom implementation of this interface —
all implementations, provided by this package, implement either DirectPointSetPattern
or RectangularPattern
interface.
There is a guarantee, that if this object implements DirectPointSetPattern
interface,
then this method requires not greater than O(N) memory
(N=pointCount()
)
and never throws TooManyPointsInPatternError
.
There is a guarantee, that if this object implements RectangularPattern
interface,
then this method works quickly (O(1) operations) and without exceptions.
upperSurface
in interface UniformGridPattern
coordIndex
 the index of the coordinate (0 for x, 1 for y, 2 for z, etc.)public Pattern surface()
UniformGridPattern
UniformGridPattern.lowerSurface(int)
UniformGridPattern.upperSurface(int)
methods for all coordinates.
In other words, the returned pattern contains full "boundary" of this pattern.
The number of dimensions in the resulting pattern (dimCount()
) is the same as in this one.
Note: if this object is not DirectPointSetPattern
and is not RectangularPattern
, this method can work slowly for some large patterns:
the required time can be O(N), where N is the number of points.
In these cases, this method can also throw TooManyPointsInPatternError
or OutOfMemoryError. The situation is like in Pattern.points()
and Pattern.roundedPoints()
method.
However, this situation is possible only in custom implementation of this interface —
all implementations, provided by this package, implement either DirectPointSetPattern
or RectangularPattern
interface.
surface
in interface UniformGridPattern
public abstract long pointCount()
Pattern
Warning! This method can work slowly for some forms of large patterns:
the required time can be O(N), where N is the number of points (result of this method).
In these cases, this method can also throw TooManyPointsInPatternError
or OutOfMemoryError.
There is a guarantee, that if this object implements QuickPointCountPattern
interface,
then this method works very quickly (O(1) operations) and without exceptions.
There is a guarantee, that if this object implements DirectPointSetPattern
interface,
then the result of this method is not greater than Integer.MAX_VALUE.
Note: if this method returns some value greater than Integer.MAX_VALUE,
it means that you cannot use Pattern.points()
and Pattern.roundedPoints()
methods,
because Java Set object cannot contain more than Integer.MAX_VALUE elements.
pointCount
in interface Pattern
pointCount
in class AbstractPattern
points
in this pattern.Pattern.largePointCount()
,
Pattern.isSurelySinglePoint()
,
QuickPointCountPattern.isPointCountVeryLarge()
public java.util.Set<Point> points()
Pattern
The result of this method is immutable (Collections.unmodifiableSet). Moreover, the result is always the same for different calls of this method for the same instance — there are no ways to change it, in particular, via any custom methods of the implementation class (it is a conclusion from the common requirement, that all implementations of this interface must be immutable).
The returned set is always nonempty,
and the number of its elements is always equal to Pattern.pointCount()
.
Warning! This method can work slowly for some forms of large patterns.
In these cases, this method can also throw TooManyPointsInPatternError
or OutOfMemoryError.
This method surely fails (throws one of these exception), if the total number of points
Pattern.pointCount()
>Integer.MAX_VALUE, because Java Set object
cannot contain more than Integer.MAX_VALUE elements.
For example, implementations of the rectangular patterns
allow to successfully define a very large 3D parallelepiped
TooManyPointsInPatternError
)
for n=2000 (2000^{3}>Integer.MAX_VALUE).
There is a guarantee, that if this object implements DirectPointSetPattern
interface,
then this method requires not greater than O(N) operations and memory
(N=pointCount()
)
and never throws TooManyPointsInPatternError
.
Note: this method works very quickly (O(1) operations) in SimplePattern
class.
points
in interface Pattern
points
in class AbstractPattern
public java.util.Set<IPoint> roundedPoints()
AbstractPattern
AbstractPattern.points()
method and returns a new set, built from the returned set of
real points by conversion of every point to an integer point via Point.toRoundedPoint()
method,
as written in
comments to this method in Pattern interface
.
Please override this method if there is more efficient way to get all rounded points.roundedPoints
in interface Pattern
roundedPoints
in class AbstractPattern
public Range coordRange(int coordIndex)
Pattern
Point.coord(coordIndex)
)
among all points of this pattern.
The minimal coordinate will be r.min()
,
the maximal coordinate will be r.max()
,
where r is the result of this method.
There is a guarantee, that if this object implements RectangularPattern
interface,
then this method works very quickly (O(1) operations) and without exceptions.
Moreover, all patterns, implemented in this package, have very quick implementations of this method (O(1) operations). Also, the implementations of this method in this package never throw exceptions.
It is theoretically possible, that in custom implementations of this interface
(outside this package) this method will work slowly, up to O(N) operations,
N is the number of points in this pattern.
However, even in such implementations this method must not lead to
TooManyPointsInPatternError
/ OutOfMemoryError, like Pattern.points()
method.
coordRange
in interface Pattern
coordRange
in class AbstractPattern
coordIndex
 the index of the coordinate (0 for x, 1 for y, 2 for z, etc.).Pattern.roundedCoordRange(int)
,
Pattern.coordMin()
,
Pattern.coordMax()
,
Pattern.coordArea()
public boolean isSurelyInteger()
AbstractPattern
AbstractPattern.points()
method and checks, whether all returned points are integer,
i.e. Point.isInteger()
method returns true for all elements the returned set.
If all points, returned by AbstractPattern.points()
call, are integer, this method returns true,
in other case it returns false.
This method caches its results: the following calls will work faster.
Note: according the comments to this method in Pattern interface
,
such implementation is correct only if AbstractPattern.minkowskiDecomposition(int)
,
AbstractPattern.unionDecomposition(int)
and AbstractPattern.allUnionDecompositions(int)
methods
have default implementations (not overridden). If some of them are overridden and
return some nontrivial results, this method must be also overridden.
Note: according the comments to this method in Pattern interface
,
this method must be overridden if the number of points can be very large and a call of
AbstractPattern.points()
method leads to a risk of TooManyPointsInPatternError
/ OutOfMemoryError.
In particular, this method should be usually overridden in implementations of RectangularPattern
.
isSurelyInteger
in interface Pattern
isSurelyInteger
in class AbstractPattern
integer
points.public UniformGridPattern round()
AbstractPattern
AbstractPattern.roundedPoints()
method and constructs a new integer pattern on the base
of this set, like as it is performed in Patterns.newIntegerPattern(java.util.Collection)
method.
Please override this method if there is more efficient way to round this pattern,
for example, if this pattern is already an integer one.round
in interface Pattern
round
in class AbstractPattern
public abstract UniformGridPattern projectionAlongAxis(int coordIndex)
Pattern
Pattern.dimCount()
) is less by 1, than in this one.
More precisely, the resulting pattern consists of the points,
obtained from all points of this pattern by the call
point.projectionAlongAxis
(coordIndex).
The returned pattern always implements DirectPointSetPattern
if this pattern implements DirectPointSetPattern
The returned pattern always implements RectangularPattern
if this pattern implements RectangularPattern
.
The returned pattern always implements UniformGridPattern
if this pattern implements UniformGridPattern
.
There is a guarantee, that this method does not try to allocate much more memory,
that it is required for storing this pattern itself, and that it
never throws TooManyPointsInPatternError
.
For comparison, an attempt to do the same operation via getting all points (Pattern.points()
method),
correcting them and forming a new pattern via Patterns.newPattern(java.util.Collection)
will lead to TooManyPointsInPatternError
/ OutOfMemoryError for some forms of large patterns.
projectionAlongAxis
in interface Pattern
projectionAlongAxis
in interface UniformGridPattern
projectionAlongAxis
in class AbstractPattern
coordIndex
 the index of the coordinate (0 for xaxis , 1 for yaxis,
2 for zaxis, etc.).Pattern.dimCount()
is equal to
thisInstance.Pattern.dimCount()
1).public UniformGridPattern minBound(int coordIndex)
AbstractPattern
AbstractPattern.points()
method and builds the result on the base of analysis
of the returned point set.
Please override this method if there is more efficient way to find the result,
for example, if this pattern is a rectangular one.minBound
in interface Pattern
minBound
in interface UniformGridPattern
minBound
in class AbstractPattern
coordIndex
 the index of the coordinate (0 for xaxis , 1 for yaxis,
2 for zaxis, etc.).Pattern.maxBound(int)
public UniformGridPattern maxBound(int coordIndex)
AbstractPattern
AbstractPattern.points()
method and builds the result on the base of analysis
of the returned point set.
Please override this method if there is more efficient way to find the result,
for example, if this pattern is a rectangular one.maxBound
in interface Pattern
maxBound
in interface UniformGridPattern
maxBound
in class AbstractPattern
coordIndex
 the index of the coordinate (0 for xaxis , 1 for yaxis,
2 for zaxis, etc.).Pattern.minBound(int)
public UniformGridPattern carcass()
maxCarcassMultiplier()
also,
because that method returns the private field calculated by this one.carcass
in interface Pattern
carcass
in interface UniformGridPattern
carcass
in class AbstractPattern
public int maxCarcassMultiplier()
maxCarcassMultiplier
in interface Pattern
maxCarcassMultiplier
in class AbstractPattern
carcass
.public abstract UniformGridPattern shift(Point shift)
Pattern
More precisely, the resulting pattern consists of the points,
obtained from all points of this pattern by the call point.add
(shift).
The returned pattern always implements DirectPointSetPattern
if this pattern implements DirectPointSetPattern
The returned pattern always implements RectangularPattern
if this pattern implements RectangularPattern
.
The returned pattern always implements UniformGridPattern
if this pattern implements UniformGridPattern
.
There is a guarantee, that this method does not try to allocate much more memory,
that it is required for storing this pattern itself, and that it
never throws TooManyPointsInPatternError
.
For comparison, an attempt to do the same operation via getting all points (Pattern.points()
method),
correcting them and forming a new pattern via Patterns.newPattern(java.util.Collection)
will lead to TooManyPointsInPatternError
/ OutOfMemoryError for some forms of large patterns.
Warning: this method can fail with TooLargePatternCoordinatesException
, if some of new points
violate restrictions, described in the comments to this interface
,
section "Coordinate restrictions" (for example, due to very large shift).
However, TooLargePatternCoordinatesException
is impossible in many important cases, when
this pattern is an integer pattern and each coordinate
coord
(j)TooLargePatternCoordinatesException
in the following situations:
coordMin()
.symmetric()
,coordMax()
.symmetric()
,symmetric()
, where p is
some of the points
if this integer pattern.See more details in the comments to this interface
,
section "Coordinate restrictions", the theorem II.
shift
in interface Pattern
shift
in interface UniformGridPattern
shift
in class AbstractPattern
shift
 the shift.public UniformGridPattern symmetric()
AbstractPattern
multiply(1.0)
.
There are no reasons to override this method usually.symmetric
in interface Pattern
symmetric
in interface UniformGridPattern
symmetric
in class AbstractPattern
public UniformGridPattern multiply(double multiplier)
AbstractPattern
AbstractPattern.dimCount
]scale(a)
.
There are no reasons to override this method usually.multiply
in interface Pattern
multiply
in interface UniformGridPattern
multiply
in class AbstractPattern
multiplier
 the scale along all coordinates.Pattern.scale(double...)
public abstract UniformGridPattern scale(double... multipliers)
Pattern
More precisely, the resulting pattern consists of the points,
obtained from all points of this pattern by the call
point.scale
(multipliers).
The returned pattern always implements DirectPointSetPattern
if this pattern implements DirectPointSetPattern
The returned pattern always implements RectangularPattern
if this pattern implements RectangularPattern
.
The returned pattern always implements UniformGridPattern
if this pattern implements UniformGridPattern
.
There is a guarantee, that this method does not try to allocate much more memory,
that it is required for storing this pattern itself, and that it
never throws TooManyPointsInPatternError
.
For comparison, an attempt to do the same operation via getting all points (Pattern.points()
method),
correcting them and forming a new pattern via Patterns.newPattern(java.util.Collection)
will lead to TooManyPointsInPatternError
/ OutOfMemoryError for some forms of large patterns.
Warning: this method can fail with TooLargePatternCoordinatesException
, if some of new points
violate restrictions, described in the comments to this interface
,
section "Coordinate restrictions" (for example, due to very large multipliers).
However, such failure is obviously impossible, if all multipliers are
in range 1.0<=multipliers[k]<=1.0.
scale
in interface Pattern
scale
in interface UniformGridPattern
scale
in class AbstractPattern
multipliers
 the scales along coordinates.Pattern.multiply(double)
public Pattern minkowskiAdd(Pattern added)
roundedPoints()
method in both patterns
and always returns the simple pattern
consisting of sums of all point pairs.
This algorithm may be very slow for large patterns
(O(NM) operations, N=pointCount()
, M=added.pointCount()
)
and does not work at all if the number of resulting points is greater than Integer.MAX_VALUE.
Please override this method if there is better implementation.minkowskiAdd
in interface Pattern
minkowskiAdd
in class AbstractPattern
added
 another pattern.java.lang.NullPointerException
 if the argument is null.java.lang.IllegalArgumentException
 if the numbers of space dimensions of both patterns are different.Patterns.newMinkowskiSum(java.util.Collection)
,
Pattern.minkowskiSubtract(Pattern)
public Pattern minkowskiSubtract(Pattern subtracted)
roundedPoints()
method in both patterns
and always returns the simple pattern
consisting of sums of all point pairs.
This algorithm may be very slow for large patterns
(O(NM) operations, N=pointCount()
, M=added.pointCount()
)
and does not work at all if the number of resulting points is greater than Integer.MAX_VALUE.
Please override this method if there is better implementation.minkowskiSubtract
in interface Pattern
minkowskiSubtract
in class AbstractPattern
subtracted
 another pattern.java.lang.NullPointerException
 if the argument is null.java.lang.IllegalArgumentException
 if the numbers of space dimensions of both patterns are different.Pattern.minkowskiAdd(Pattern)
public java.util.List<Pattern> minkowskiDecomposition(int minimalPointCount)
isActuallyRectangular()
method
returns true.
This method caches its results for several little values of the argument:
the following calls will work faster.
Please override this method if there is better implementation.minkowskiDecomposition
in interface Pattern
minkowskiDecomposition
in class AbstractPattern
minimalPointCount
 this method does not try to decompose patterns that contain
less than minimalPointCount points.
In particular, if the minkowski sum of several patterns containing
less than minimalPointCount points, this method should return
this sum in the resulting list instead of its summands.java.lang.IllegalArgumentException
 if the argument is negative.public boolean hasMinkowskiDecomposition()
minkowskiDecomposition(0)
.size()>1.
Please override this method if minkowskiDecomposition(int)
method
works slowly and it's possible to know, whether the pattern has Minkowski decomposition, much faster.hasMinkowskiDecomposition
in interface Pattern
hasMinkowskiDecomposition
in class AbstractPattern
public java.util.List<java.util.List<Pattern>> allUnionDecompositions(int minimalPointCount)
allUnionDecompositions
in interface Pattern
allUnionDecompositions
in class AbstractPattern
minimalPointCount
 the minimal number of points in every pattern in all resulting decompositions:
all pattern containing less points should be joined into one element
of the resulting list.java.lang.IllegalArgumentException
 if the argument is negative.public static boolean isAllowedGridIndex(IPoint gridIndex)
public static boolean isAllowedGridIndexRange(IRange gridIndexRange)
protected java.lang.String gridToString()