JaCoP.constraints.geost
Class Shape

java.lang.Object
  extended by JaCoP.constraints.geost.Shape

public class Shape
extends java.lang.Object

Author:
Marc-Olivier Fleury and Radoslaw Szymanek A shape is composed of a set of shifted boxes.

Field Summary
 DBox boundingBox
          It specifies the smallest bounding box which encapsulates all boxes constituting the shape.
 java.util.Collection<DBox> boxes
          The collection of DBoxes that constitute the shape.
 int no
          It defines unique shape id which is used by geost objects to define their shapes.
static java.lang.String[] xmlAttributes
          It specifies the arguments required to be saved by an XML format as well as the constructor being called to recreate an object from an XML format.
 
Constructor Summary
Shape(int no, java.util.Collection<DBox> boxes)
          It constructs a shape with a given id based on a specified collection of Dboxes.
Shape(int id, DBox box)
          It constructs a shape from only one DBox.
Shape(int id, int[] origin, int[] length)
          It constructs a shape with a given id based on a single dbox specified by the origin and length arrays.
 
Method Summary
 int area()
          It computes the area (2D), volumen (3D) of the shape.
 DBox boundingBox()
          It returns previously computed bounding box of the shape.
 java.lang.String checkInvariants()
          It checks whether the shape object is consistent.
 java.util.Collection<DBox> components()
          It returns the dboxes defining the shape.
 boolean containsPoint(int[] point)
          It checks whether a given point lies within any of the shapes boxes.
 java.util.Collection<DBox> holes()
          It returns the set of holes of this shape.
 java.util.Collection<DBox> noOverlapRepresentation()
          It computes a collection of DBoxes that form the same shape, but that are certain to not overlap This implementation is probably not the most efficient possible representation.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

boxes

public java.util.Collection<DBox> boxes
The collection of DBoxes that constitute the shape.


boundingBox

public final DBox boundingBox
It specifies the smallest bounding box which encapsulates all boxes constituting the shape.


no

public int no
It defines unique shape id which is used by geost objects to define their shapes.


xmlAttributes

public static java.lang.String[] xmlAttributes
It specifies the arguments required to be saved by an XML format as well as the constructor being called to recreate an object from an XML format.

Constructor Detail

Shape

public Shape(int no,
             java.util.Collection<DBox> boxes)
It constructs a shape with a given id based on a specified collection of Dboxes.

Parameters:
no - the unique identifier of the created shape.
boxes - the collection of boxes constituting the shape.

Shape

public Shape(int id,
             DBox box)
It constructs a shape from only one DBox.

Parameters:
id - shape unique identifier.
box - the single dbox specifying the shape.

Shape

public Shape(int id,
             int[] origin,
             int[] length)
It constructs a shape with a given id based on a single dbox specified by the origin and length arrays.

Parameters:
id - the unique identifier of the constructed shape.
origin - it specifies the origin of the dbox specifying the shape.
length - it specifies the length of the dbox specifying the shape.
Method Detail

checkInvariants

public java.lang.String checkInvariants()
It checks whether the shape object is consistent.

Returns:
It returns the string description of the problem, or null if no problem with data structure consistency encountered.

components

public java.util.Collection<DBox> components()
It returns the dboxes defining the shape.

Returns:
the collection of dboxes defining the shape.

boundingBox

public final DBox boundingBox()
It returns previously computed bounding box of the shape.

Returns:
the bounding box of the shape.

containsPoint

public boolean containsPoint(int[] point)
It checks whether a given point lies within any of the shapes boxes.

Parameters:
point - the point which containment within a shape is being checked.
Returns:
true if the point lies within a shape, false otherwise.

holes

public java.util.Collection<DBox> holes()
It returns the set of holes of this shape. The set of holes is a set of boxes with the following properties, once scaled by a factor 1/4: - none of its components overlaps with the shape's components - its union with the set of components covers the bounding box of the shape, except for an empty area at the component boundary that has size 1/4

Returns:
the set of holes of this shape.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

area

public int area()
It computes the area (2D), volumen (3D) of the shape.

Returns:
the area/volume of the shape.

noOverlapRepresentation

public java.util.Collection<DBox> noOverlapRepresentation()
It computes a collection of DBoxes that form the same shape, but that are certain to not overlap This implementation is probably not the most efficient possible representation.

Returns:
non overlapping representation of the shape.