Package geomerative

Class RGroup


  • public class RGroup
    extends RGeomElem
    RGroup is a holder for a group of geometric elements that can be drawn and transformed, such as shapes, polygons or meshes.
    • Field Detail

      • type

        public int type
      • elements

        public RGeomElem[] elements
        Array of RGeomElem objects holding the elements of the group. When accessing theses elements we must cast them to their class in order to get all the functionalities of each representation. e.g. RShape s = group.elements[i].toShape() If the element cannot be converted to the target class it will throw a RuntimeException, to ignore these, use try-catch syntax.
    • Constructor Detail

      • RGroup

        public RGroup()
        Use this method to create a new empty group.
      • RGroup

        public RGroup​(RGroup grp)
        Use this method to create a copy of a group.
    • Method Detail

      • getCentroid

        public RPoint getCentroid()
        Use this method to get the centroid of the element.
        Overrides:
        getCentroid in class RGeomElem
        Returns:
        RPoint, the centroid point of the element
      • countElements

        public int countElements()
        Use this method to count the number of elements in the group.
        Returns:
        int, the number elements in the group.
      • draw

        public void draw​(processing.core.PGraphics g)
        Use this method to draw the group. This will draw each element at a time, without worrying about intersections or holes. This is the main difference between having a shape with multiple paths and having a group with multiple shapes.
        Specified by:
        draw in class RGeomElem
        Parameters:
        g - PGraphics, the graphics object on which to draw the group
      • draw

        public void draw​(processing.core.PApplet a)
        Specified by:
        draw in class RGeomElem
      • addElement

        public void addElement​(RGeomElem elem)
        Use this method to add a new element.
        Parameters:
        elem - RGeomElem, any kind of RGeomElem to add. It accepts the classes RShape, RPolygon and RMesh.
      • addGroup

        public void addGroup​(RGroup grupo)
        Use this method to add a new element.
        Parameters:
        grupo - RGroup, A group of elements to add to this group.
      • removeElement

        public void removeElement​(int i)
                           throws java.lang.RuntimeException
        Use this method to remove an element.
        Parameters:
        i - int, the index of the element to remove from the group.
        Throws:
        java.lang.RuntimeException
      • toMeshGroup

        public RGroup toMeshGroup()
                           throws java.lang.RuntimeException
        Use this method to get a new group whose elements are the corresponding meshes of the elements in the current group. This can be used for increasing performance in exchange of losing abstraction.
        Returns:
        RGroup, the new group made of RMeshes
        Throws:
        java.lang.RuntimeException
      • toPolygonGroup

        public RGroup toPolygonGroup()
                              throws java.lang.RuntimeException
        Use this method to get a new group whose elements are the corresponding polygons of the elements in the current group. At this moment there is no implementation for transforming a mesh to a polygon so applying this method to groups holding mesh elements will generate an exception.
        Returns:
        RGroup, the new group made of RPolygons
        Throws:
        java.lang.RuntimeException
      • toShapeGroup

        public RGroup toShapeGroup()
                            throws java.lang.RuntimeException
        Use this method to get a new group whose elements are all the corresponding shapes of the elements in the current group. At this moment there is no implementation for transforming a mesh or a polygon to a shape so applying this method to groups holding mesh or polygon elements will generate an exception.
        Returns:
        RGroup, the new group made of RShapes
        Throws:
        java.lang.RuntimeException
      • toMesh

        public RMesh toMesh()
                     throws java.lang.RuntimeException
        Overrides:
        toMesh in class RGeomElem
        Throws:
        java.lang.RuntimeException
      • toPolygon

        public RPolygon toPolygon()
                           throws java.lang.RuntimeException
        Overrides:
        toPolygon in class RGeomElem
        Throws:
        java.lang.RuntimeException
      • toShape

        public RShape toShape()
                       throws java.lang.RuntimeException
        Specified by:
        toShape in class RGeomElem
        Throws:
        java.lang.RuntimeException
      • getHandles

        public RPoint[] getHandles()
        Use this to return the points of the group. It returns the points as an array of RPoint.
        Specified by:
        getHandles in class RGeomElem
        Returns:
        RPoint[], the points returned in an array.
      • getPoints

        public RPoint[] getPoints()
        Use this to return the points of the group. It returns the points as an array of RPoint.
        Specified by:
        getPoints in class RGeomElem
        Returns:
        RPoint[], the points returned in an array.
      • getTangents

        public RPoint[] getTangents()
        Use this to return the points of the group. It returns the points as an array of RPoint.
        Specified by:
        getTangents in class RGeomElem
        Returns:
        RPoint[], the points returned in an array.
      • getPointsInPaths

        public RPoint[][] getPointsInPaths()
        Use this to return the points of each path of the group. It returns the points as an array of arrays of RPoint.
        Specified by:
        getPointsInPaths in class RGeomElem
        Returns:
        RPoint[], the points returned in an array.
      • contains

        public boolean contains​(RPoint p)
        Use this to return a specific tangent on the curve. It returns true if the point passed as a parameter is inside the group.
        Specified by:
        contains in class RGeomElem
        Parameters:
        p - the point for which to test containment..
        Returns:
        boolean, true if the point is in the path.
      • getType

        public int getType()
        Use this method to get the type of element this is.
        Specified by:
        getType in class RGeomElem
        Returns:
        int, will allways return RGeomElem.POLYGON
      • split

        public RGroup[] split​(float t)
      • splitPaths

        public RGroup[] splitPaths​(float t)
      • insertHandleInPaths

        public void insertHandleInPaths​(float t)
        Use this to insert a split point into each command of the group.
        Parameters:
        t - float, the parameter of advancement on the curve. t must have values between 0 and 1.
      • adapt

        public void adapt​(RGroup grp,
                          float wght,
                          float lngthOffset)
                   throws java.lang.RuntimeException
        Use this method to adapt a group of of figures to a group.
        Parameters:
        grp - the path to which to adapt
        Throws:
        java.lang.RuntimeException
      • adapt

        public void adapt​(RGroup grp)
                   throws java.lang.RuntimeException
        Throws:
        java.lang.RuntimeException
      • adapt

        public void adapt​(RShape shp)
      • adapt

        public void adapt​(RShape shp,
                          float wght,
                          float lngthOffset)
      • polygonize

        public void polygonize()