Class Shape

java.lang.Object
org.jacop.constraints.geost.Shape

public class Shape extends Object
Version:
4.9

A shape is composed of a set of shifted boxes.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
    It defines the area (2D) or volume (3D) of the shape.
    final DBox
    It specifies the smallest bounding box which encapsulates all boxes constituting the shape.
    The collection of DBoxes that constitute the shape.
     
    int
    It defines unique shape id which is used by geost objects to define their shapes.
  • Constructor Summary

    Constructors
    Constructor
    Description
    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.
    Shape(int no, 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.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    It computes the area (2D), volumen (3D) of the shape.
    final DBox
    It returns previously computed bounding box of the shape.
    It checks whether the shape object is consistent.
    It returns the dboxes defining the shape.
    private DBox
    It computes the bounding box of the given shape.
    boolean
    containsPoint(int[] point)
    It checks whether a given point lies within any of the shapes boxes.
    It returns the set of holes of this shape.
    private void
    It (re)initializes the holes
    It computes a collection of DBoxes that form the same shape, but that are certain to not overlap
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • boxes

      public 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.
    • area

      private int area
      It defines the area (2D) or volume (3D) of the shape.
    • holes

      private SimpleArrayList<DBox> holes
  • Constructor Details

    • Shape

      public Shape(int no, 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 Details

    • checkInvariants

      public 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 Collection<DBox> components()
      It returns the dboxes defining the shape.
      Returns:
      the collection of dboxes defining the shape.
    • computeBoundingBox

      private DBox computeBoundingBox()
      It computes the bounding box of the given shape.
      Returns:
      the bounding box covering all boxes constituting 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.
    • initHoles

      private void initHoles()
      It (re)initializes the holes
    • holes

      public 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 String toString()
      Overrides:
      toString in class Object
    • area

      public int area()
      It computes the area (2D), volumen (3D) of the shape.
      Returns:
      the area/volume of the shape.
    • noOverlapRepresentation

      public 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.