Class RasMInterval
PURPOSE:
The spatial domain of an MDD is represented by an object
of class RasMInterval. It specifies lower and upper bound
of the point set for each dimension of an MDD. Internally,
the class is realized through an array of intervals of type
RasSInterval.
For the operations union, difference, and intersection the
dimensionalties of the operands must be equal, otherwise an
exception is raised. The semantics of the operations are
defined as follows for each dimension:
| ... fixed bound
-* ... open bound
class orientation union difference intersection
-----------------------------------------------------------
1 |-a-| |-b-| error a error
2 |-a-| [a1,b2] [a1,b1] [b1,a2]
2 |-b-|
3 |--a--| a error b
3 |-b-|
4 |-b-| [b1,a2] [b2,a2] [a1,b2]
4 |-a-|
5 |--b--| b error a
5 |-a-|
6 |-b-| |-a-| error a error
7 |-a-|-b-| [a1,b2] a [a2,a2]
8 |-b-|-a-| [b1,a2] a [b2,b2]
9 |--a--| a [a1,b1] b
9 |-b-|
10 |--a--| a [b2,a2] b
10 |-b-|
11 |-a-| a error a
11 |-b-|
12 |--b--| b error a
12 |-a-|
13 |--b--| b error a
13 |-a-|
-----------------------------------------------------
14 |--a--* a error b
14 |-b-|
15 |--a--* a [b2,a2] b
15 |-b-|
16 |-b-| |-a-* error a error
17 |-b-|-a-* [b1,a2] a [b2,b2]
18 |--a--* [b1,a2] [b2,a2] [a1,b2]
18 |-b-|
-----------------------------------------------------
19 *--a--| a error b
19 |-b-|
20 *--a--| a [a1,b1] b
20 |-b-|
21 *-a-| |-b-| error a error
22 *-a-|-b-| [a1,b2] a [a2,a2]
23 *--a--| [a1,b2] [a1,b1] [b1,a2]
23 |-b-|
-----------------------------------------------------
24 |--b--* b error a
24 |-a-|
25 |--b--* b error a
25 |-a-|
26 |-a-| |-b-* error a error
27 |-a-|-b-* [a1,b2] a [a2,a2]
28 |--b--* [a1,b2] [a1,b1] [b1,a2]
28 |-a-|
-----------------------------------------------------
29 *--b--| b error a
29 |-a-|
30 *--b--| b error a
30 |-a-|
31 *-b-| |-a-| error a error
32 *-b-|-a-| [b1,a2] a [b2,b2]
33 *--b--| [b1,a2] [b2,a2] [a1,b2]
33 |-a-|
-----------------------------------------------------
34 *-a-| |-b-* error a error
35 *-a-|-b-* [a1,b2] a [a2,a2]
36 *-a-| [a1,b2] [a1,b1] [b1,a2]
36 |-b-*
-----------------------------------------------------
37 *-b-| |-a-* error a error
38 *-b-|-a-* [b1,a2] a [b2,b2]
39 *-b-| [b1,a2] [a1,b1] [a1,b2]
39 |-a-*
-----------------------------------------------------
40 *-a-| b error a
40 *-b-|
41 *-a-| a error a
41 *-b-|
42 *-b-| a [b2,a2] b
42 *-a-|
-----------------------------------------------------
43 |-a-* a [a1,b1] b
43 |-b-*
44 |-a-* a error a
44 |-b-*
45 |-b-* b error a
45 |-a-*
-----------------------------------------------------
46 *-a-* |-b-| a error b
47 *-b-* |-a-| b error b
48 *-a-* a [b2,a2] b
48 *-b-|
49 *-a-* a [a1,b1] b
49 |-b-*
50 *-b-* b error a
50 *-a-|
51 *-b-* b error a
51 |-a-*
52 *-a-* a error a
52 *-b-*
Attention: The difference operation has to be reconsidered in future
concerning a discrete interpretation of the intervals.
The closure operation defines an interval which is the smallest
interval containing the two operands.
The method intersectsWith() returns false in the error cases of the
intersection operation and true otherwise.
* @version $Revision: 1.15 $
COMMENTS:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intdimensionality of the domainprotected RasSInterval[]array for storing the intervalsprotected intnumber of components initialized already -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.RasMInterval(int dim) Constructor getting dimensionality for stream initializing.RasMInterval(String mIntStr) Constructor taking a string representation (for example "[1:255, 1:200]").RasMInterval(RasMInterval mInterval) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionadd(RasMInterval mint) Deprecated.This methdod provides just another name for the createUnion method and might not be supported in future versions.addToSelf(RasMInterval mint) Deprecated.This methdod provides just another name for the unionWith method and might not be supported in future versions.closureOf(RasMInterval mint1, RasMInterval mint2) Calculates the closure of two MIntervals.closureWith(RasMInterval mint) Calculates the closure of the current MInterval and the given one.intcovers(RasMInterval inter2) Method for testing if this interval covers the given interval.final intMethod for testing if this interval covers the given point.createClosure(RasMInterval mint) Returns a new MInterval calculated from the closure of the current MInterval and the given one.createDifference(RasMInterval mint) Returns a new MInterval calculated from a difference of the current MInterval and the given one.Returns a new MInterval calculated from the intersection of the current MInterval and the given one.This method returns a new MInterval resulting from a translation of the current MInterval by the given point.createUnion(RasMInterval mint) Returns a new MInterval calculated from a union of the current MInterval and the given one.diff(RasMInterval mint) Deprecated.This methdod provides just another name for the createDifference method and might not be supported in future versions.differenceOf(RasMInterval mint1, RasMInterval mint2) Calculates the difference of two MIntervals.differenceWith(RasMInterval mint) Calculates the difference of the current MInterval and the given one.diffFromSelf(RasMInterval mint) Deprecated.This methdod provides just another name for the differenceWith method and might not be supported in future versions.intGets the dimensionality of this MInterval.booleanequals(RasMInterval mint) Method for testing equality of two MIntervals.Gets the size of this MInterval as a point, that means the point specifies the extent of this MInterval ( i.e.getHigh()Gets the point with the highest coordinates in every dimension.Gets the point with the lowest coordinates in every dimension.intersectionOf(RasMInterval mint1, RasMInterval mint2) This method calculates the intersection of two MIntervals.intersectionWith(RasMInterval mint) Calculates the intersection of the current MInterval and the given one.booleanintersectsWith(RasMInterval mInterval) Determines if the self mInterval intersects with the delivered one.booleanThis method checks if this MInterval is mergeable with another MInterval.item(int i) Read access the i-th interval.mult(RasMInterval mint) Deprecated.This methdod provides just another name for the createIntersection method and might not be supported in future versions.multWithSelf(RasMInterval mint) Deprecated.This methdod provides just another name for the intersectionWith method and might not be supported in future versions.booleannotEquals(RasMInterval mint) Method for testing inequality.voidsetItem(int i, RasSInterval value) Write access to the i-th interval.voidstream(long p) Method for stream initialization with point intervals.voidstream(RasSInterval newInterval) Method for stream initialization with intervals.toString()gives back the string representationThis methods translates the current MInterval by a point.unionOf(RasMInterval mint1, RasMInterval mint2) Calculates the union of two MIntervals.unionWith(RasMInterval mint) Calculates the union of the current MIntervall with another one.
-
Field Details
-
intervals
array for storing the intervals -
dimensionality
protected int dimensionalitydimensionality of the domain -
streamInitCnt
protected int streamInitCntnumber of components initialized already
-
-
Constructor Details
-
RasMInterval
public RasMInterval(int dim) Constructor getting dimensionality for stream initializing.- Parameters:
dim- the dimensionality of this MInterval
-
RasMInterval
Constructor taking a string representation (for example "[1:255, 1:200]").- Parameters:
mIntStr- a string specifying the MInterval- Throws:
RasResultIsNoIntervalException
-
RasMInterval
public RasMInterval()Default constructor. -
RasMInterval
public RasMInterval(RasMInterval mInterval) throws RasStreamInputOverflowException, RasIndexOutOfBoundsException Copy constructor.- Parameters:
mInterval- the MInterval that is to be copied- Throws:
RasStreamInputOverflowExceptionRasIndexOutOfBoundsException
-
-
Method Details
-
stream
Method for stream initialization with intervals.- Parameters:
newInterval- the interval that has to be streamed- Throws:
RasStreamInputOverflowException
-
stream
Method for stream initialization with point intervals.- Parameters:
p- the point interval that has to be streamed- Throws:
RasStreamInputOverflowExceptionRasResultIsNoIntervalException
-
intersectsWith
public boolean intersectsWith(RasMInterval mInterval) throws RasDimensionMismatchException, RasIndexOutOfBoundsException Determines if the self mInterval intersects with the delivered one.- Parameters:
mInterval- the MInterval to be intersected- Throws:
RasDimensionMismatchExceptionRasIndexOutOfBoundsException
-
item
Read access the i-th interval.- Parameters:
i- the dimension to be read- Throws:
RasIndexOutOfBoundsException
-
setItem
Write access to the i-th interval.- Parameters:
i- the dimension that is to be accessedvalue- the interval that is to be assigned to the specified dimension- Throws:
RasIndexOutOfBoundsException
-
equals
Method for testing equality of two MIntervals. Two domains are equal if they have the same number of dimensions and each dimension has the same lower and upper bounds.- Parameters:
mint- the MInterval that is compared to this MInterval- Returns:
- true if the two MIntervals are equal
-
notEquals
Method for testing inequality. This is the negation of the equals method.- Parameters:
mint- the MInterval that is compared to this MInterval- Returns:
- true if the two MIntervals are not equal
-
covers
Method for testing if this interval covers the given point.- Parameters:
pnt- the point to be tested- Returns:
-1 if the point has not the same dimensionality 1 if the point is covered by this MInterval 0 if the point is not covered
-
covers
Method for testing if this interval covers the given interval.- Parameters:
inter2- the MInterval to be tested- Returns:
-1 if the point has not the same dimensionality 1 if the point is covered by this MInterval 0 if the point is not covered dimension
public int dimension()Gets the dimensionality of this MInterval.- Returns:
- the dimensionality of this MInterval
getOrigin
Gets the point with the lowest coordinates in every dimension.- Returns:
- the origin of this MInterval (the point with the lowest coordinates)
getHigh
Gets the point with the highest coordinates in every dimension.- Returns:
- the point with the highest coordinates in this MInterval
getExtent
Gets the size of this MInterval as a point, that means the point specifies the extent of this MInterval ( i.e. high() - low() ) in each dimension.- Returns:
- the size of this MInterval
isMergeable
This method checks if this MInterval is mergeable with another MInterval. Two RasMIntervals are "mergeable" if they have the same low() and high() values in all dimensions except in one where they differ by one point, this is, a.low()==b.high()+1 or b.low()==a.high()+1. For instance, the following two blocks are mergeable:+-------------+---------------------------------------+ | A | B | +-------------|---------------------------------------| and the following two are not: +-------------+-------------------------+ | | B | | A +-------------------------+ +-------------+
- Parameters:
b- the MInterval to be checked- Returns:
- true if the two intervalls are mergeable
translate
public RasMInterval translate(RasPoint t) throws RasDimensionMismatchException, RasResultIsNoIntervalException This methods translates the current MInterval by a point. It adds the coordinates of the given point to the lower bounds of the current MInterval. This operation is only legal if all lower bounds are fixed and the point has the same dimension as the MInterval!Note that this method modifies the current MInterval. If you want to get a new MInterval, use the
createTranslationmethod instead.- Parameters:
t- the point to be added- Returns:
- the current MInterval
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
createTranslation
public RasMInterval createTranslation(RasPoint t) throws RasDimensionMismatchException, RasResultIsNoIntervalException This method returns a new MInterval resulting from a translation of the current MInterval by the given point. It creates a copy of the current MInterval and adds the coordinates of the given point to its lower bounds.This operation is only legal if all lower bounds are fixed and the point has the same dimension as the MInterval!
- Parameters:
t- the point to be added- Returns:
- the new MInterval
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
unionOf
public RasMInterval unionOf(RasMInterval mint1, RasMInterval mint2) throws RasDimensionMismatchException, RasResultIsNoIntervalException Calculates the union of two MIntervals. This is only possible for two MIntervals having the same dimensionality.Note that this operation modifies the current object. If you want to get a new MInterval, use
createUnioninstead.- Parameters:
mint1- the first MIntervalmint2- the second MInterval- Returns:
- the current MInterval (representing the union of mint1 and mint2)
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
unionWith
public RasMInterval unionWith(RasMInterval mint) throws RasDimensionMismatchException, RasResultIsNoIntervalException Calculates the union of the current MIntervall with another one.Note that this operation modifies the current object. If you want to get a new MInterval, use
createUnioninstead.- Parameters:
mint- the MInterval to be used for the union- Returns:
- the current MInterval (after the union with mint)
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
addToSelf
public RasMInterval addToSelf(RasMInterval mint) throws RasDimensionMismatchException, RasResultIsNoIntervalException Deprecated.This methdod provides just another name for the unionWith method and might not be supported in future versions. Please useunionWithinstead.- Parameters:
mint- the MInterval to be added- Returns:
- the current MInterval after adding mint
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
createUnion
public RasMInterval createUnion(RasMInterval mint) throws RasDimensionMismatchException, RasResultIsNoIntervalException Returns a new MInterval calculated from a union of the current MInterval and the given one.- Parameters:
mint- the MInterval to be unioned with this MInterval- Returns:
- the union of this MInterval and mint
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
add
public RasMInterval add(RasMInterval mint) throws RasDimensionMismatchException, RasResultIsNoIntervalException Deprecated.This methdod provides just another name for the createUnion method and might not be supported in future versions. Please usecreateUnioninstead.- Parameters:
mint- the MInterval to be added- Returns:
- the current MInterval after adding mint
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
differenceOf
public RasMInterval differenceOf(RasMInterval mint1, RasMInterval mint2) throws RasDimensionMismatchException, RasResultIsNoIntervalException Calculates the difference of two MIntervals.Note that this operation modifies the current object. If you want to get a new MInterval, use
createDifferenceinstead.- Parameters:
mint1- the first MIntervalmint2- the second MInterval- Returns:
- the current MInterval (representing the difference of mint1 and mint2)
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
differenceWith
public RasMInterval differenceWith(RasMInterval mint) throws RasDimensionMismatchException, RasResultIsNoIntervalException Calculates the difference of the current MInterval and the given one.Note that this operation modifies the current object. If you want to get a new MInterval, use
createDifferenceinstead.- Parameters:
mint- the MInterval used for building the difference- Returns:
- the current MInterval (representing the difference of this MInterval and mint)
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
diffFromSelf
public RasMInterval diffFromSelf(RasMInterval mint) throws RasDimensionMismatchException, RasResultIsNoIntervalException Deprecated.This methdod provides just another name for the differenceWith method and might not be supported in future versions. Please usedifferenceWithinstead.- Parameters:
mint1- the MInterval used for building the difference- Returns:
- the difference of this MInterval and mint2
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
createDifference
public RasMInterval createDifference(RasMInterval mint) throws RasDimensionMismatchException, RasResultIsNoIntervalException Returns a new MInterval calculated from a difference of the current MInterval and the given one.- Parameters:
mint- the MInterval used for calculating the difference with the current MInterval- Returns:
- the difference of this MInterval and mint
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
diff
public RasMInterval diff(RasMInterval mint) throws RasDimensionMismatchException, RasResultIsNoIntervalException Deprecated.This methdod provides just another name for the createDifference method and might not be supported in future versions. Please usecreateDifferenceinstead.- Parameters:
mint- the MInterval used for calculating the difference with the current MInterval- Returns:
- the difference of this MInterval and mint
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
intersectionOf
public RasMInterval intersectionOf(RasMInterval mint1, RasMInterval mint2) throws RasDimensionMismatchException, RasResultIsNoIntervalException This method calculates the intersection of two MIntervals. This is only possible if the two MIntervals have the same dimensionality.Note that this operation modifies the current object. If you want to get a new MInterval, use
createIntersectioninstead.- Parameters:
mint1- the first MIntervalmint2- the second MInterval- Returns:
- the current MInterval (representing the intersection of mint1 and mint2)
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
intersectionWith
public RasMInterval intersectionWith(RasMInterval mint) throws RasDimensionMismatchException, RasResultIsNoIntervalException Calculates the intersection of the current MInterval and the given one.Note that this operation modifies the current object. If you want to get a new MInterval, use
createIntersectioninstead.- Parameters:
mint- the MInterval used for building the intersection- Returns:
- the current MInterval (representing the intersection of this MInterval and mint)
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
multWithSelf
public RasMInterval multWithSelf(RasMInterval mint) throws RasDimensionMismatchException, RasResultIsNoIntervalException Deprecated.This methdod provides just another name for the intersectionWith method and might not be supported in future versions. Please useintersectionWithinstead.- Parameters:
mint- the MInterval used for building the intersection- Returns:
- the intersection of this MInterval and mint
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
createIntersection
public RasMInterval createIntersection(RasMInterval mint) throws RasDimensionMismatchException, RasResultIsNoIntervalException Returns a new MInterval calculated from the intersection of the current MInterval and the given one.- Parameters:
mint- the MInterval used for calculating the intersection with the current MInterval- Returns:
- the intersection of this MInterval and mint
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
mult
public RasMInterval mult(RasMInterval mint) throws RasDimensionMismatchException, RasResultIsNoIntervalException Deprecated.This methdod provides just another name for the createIntersection method and might not be supported in future versions. Please usecreateIntersectioninstead.- Parameters:
mint- the MInterval used for calculating the intersection with the current MInterval- Returns:
- the intersection of this MInterval and mint
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
closureOf
public RasMInterval closureOf(RasMInterval mint1, RasMInterval mint2) throws RasDimensionMismatchException, RasResultIsNoIntervalException Calculates the closure of two MIntervals.Note that this operation modifies the current object. If you want to get a new MInterval, use
createClosureinstead.- Parameters:
mint1- the first MIntervalmint2- the second MInterval- Returns:
- the current MInterval (representing the closure of mint1 and mint2)
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
closureWith
public RasMInterval closureWith(RasMInterval mint) throws RasDimensionMismatchException, RasResultIsNoIntervalException Calculates the closure of the current MInterval and the given one.Note that this operation modifies the current object. If you want to get a new MInterval, use
createClosureinstead.- Parameters:
mint- the MInterval used for building the closure- Returns:
- the current MInterval (representing the closure of this MInterval and mint)
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
createClosure
public RasMInterval createClosure(RasMInterval mint) throws RasDimensionMismatchException, RasResultIsNoIntervalException Returns a new MInterval calculated from the closure of the current MInterval and the given one.- Parameters:
mint- the MInterval used for calculating the closure with the current MInterval- Returns:
- the closure of this MInterval and mint
- Throws:
RasDimensionMismatchExceptionRasResultIsNoIntervalException
toString
gives back the string representation
-