Class Shape


  • public class Shape
    extends java.lang.Object
    Version:
    4.8

    A shape is composed of a set of shifted boxes.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int area
      It defines the area (2D) or volume (3D) of the shape.
      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.
      private SimpleArrayList<DBox> holes  
      int no
      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, 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.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      private DBox computeBoundingBox()
      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.
      java.util.Collection<DBox> holes()
      It returns the set of holes of this shape.
      private void initHoles()
      It (re)initializes the holes
      java.util.Collection<DBox> noOverlapRepresentation()
      It computes a collection of DBoxes that form the same shape, but that are certain to not overlap
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, 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.
      • area

        private int area
        It defines the area (2D) or volume (3D) of the shape.
    • 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.
      • 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 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.