HE_Mesh  5.1.0
geomerative.RPolygon Class Reference
+ Inheritance diagram for geomerative.RPolygon:

Public Member Functions

 RPolygon (final RPolygon p)
 
 RPolygon (final RPoint[] points)
 
 RPolygon (final RContour newcontour)
 
 RPolygon ()
 
void addClose ()
 
void print ()
 
RPolygon toPolygon ()
 
RShape toShape ()
 
RPoint[] getHandles ()
 
RPoint[] getPoints ()
 
int getType ()
 
void draw (final PApplet g)
 
RPoint getPoint (final float t)
 
RPoint getTangent (final float t)
 
RPoint[] getTangents ()
 
RPoint[][] getPointsInPaths ()
 
RPoint[][] getHandlesInPaths ()
 
RPoint[][] getTangentsInPaths ()
 
boolean contains (final RPoint p)
 
boolean isHole ()
 
- Public Member Functions inherited from geomerative.RGeomElem
abstract void draw (PGraphics g)
 
abstract void draw (PApplet g)
 
void draw ()
 
abstract RPoint getPoint (float t)
 
abstract RPoint getTangent (float t)
 
abstract RPoint[] getHandles ()
 
abstract RPoint[] getPoints ()
 
abstract RPoint[] getTangents ()
 
abstract RPoint[][] getHandlesInPaths ()
 
abstract RPoint[][] getPointsInPaths ()
 
abstract RPoint[][] getTangentsInPaths ()
 
abstract boolean contains (RPoint p)
 
abstract int getType ()
 
abstract RShape toShape ()
 
void print ()
 
void setFill (boolean _fill)
 
void setFill (int _fillColor)
 
void setFill (String str)
 
void setStroke (boolean _stroke)
 
void setStroke (int _strokeColor)
 
void setStroke (String str)
 
void setStrokeWeight (float value)
 
void setStrokeWeight (String str)
 
void setStrokeCap (String str)
 
void setStrokeJoin (String str)
 
void setStrokeAlpha (int opacity)
 
void setStrokeAlpha (String str)
 
void setFillAlpha (int opacity)
 
void setFillAlpha (String str)
 
void setAlpha (float opacity)
 
void setAlpha (int opacity)
 
void setAlpha (String str)
 
RStyle getStyle ()
 
void setStyle (RStyle s)
 
void setName (String str)
 
float[] getCurveLengths ()
 
float getCurveLength ()
 
RPolygon toPolygon ()
 
RMesh toMesh ()
 
void transform (RMatrix m)
 
void transform (float x, float y, float w, float h)
 
boolean isIn (PGraphics g)
 
boolean isIn (PApplet g)
 
RMatrix getCenteringTransf (PGraphics g) throws RuntimeException
 
RMatrix getCenteringTransf (PGraphics g, float margin) throws RuntimeException
 
void centerIn (PGraphics g)
 
void centerIn (PGraphics g, float margin)
 
void centerIn (PGraphics g, float margin, float sclDamping, float trnsDamping) throws RuntimeException
 
void rotate (float angle)
 
void scale (float sx, float sy)
 
void scale (float s)
 

Static Public Member Functions

static RPolygon createCircle (final float x, final float y, final float radius, final int detail)
 
static RPolygon createCircle (final float radius, final int detail)
 
static RPolygon createCircle (final float x, final float y, final float radius)
 
static RPolygon createCircle (final float radius)
 
static RPolygon createRectangle (final float x, final float y, final float w, final float h)
 
static RPolygon createRectangle (final float w, final float h)
 
static RPolygon createStar (final float x, final float y, final float radiusBig, final float radiusSmall, final int spikes)
 
static RPolygon createStar (final float radiusBig, final float radiusSmall, final int spikes)
 
static RPolygon createRing (final float x, final float y, final float radiusBig, final float radiusSmall, final int detail)
 
static RPolygon createRing (final float radiusBig, final float radiusSmall, final int detail)
 
static RPolygon createRing (final float x, final float y, final float radiusBig, final float radiusSmall)
 
static RPolygon createRing (final float radiusBig, final float radiusSmall)
 

Public Attributes

int type = RGeomElem.POLYGON
 
- Public Attributes inherited from geomerative.RGeomElem
float width
 
float height
 
String name = ""
 

Static Public Attributes

static int defaultDetail = 50
 
- Static Public Attributes inherited from geomerative.RGeomElem
static final int SHAPE = 0
 
static final int SUBSHAPE = 1
 
static final int COMMAND = 2
 
static final int POLYGON = 3
 
static final int CONTOUR = 4
 
static final int MESH = 5
 
static final int TRISTRIP = 6
 
static final int GROUP = 7
 
static final int UNKNOWN = 8
 

Protected Member Functions

RPolygon removeOpenContours ()
 
void clear ()
 
void add (final float x, final float y)
 
void add (final RPoint p)
 
void add (final RPolygon p)
 
void add (final RContour c)
 
boolean isEmpty ()
 
RRectangle getBBox ()
 
RPolygon getInnerPoly (final int polyIndex)
 
int getNumInnerPoly ()
 
int getNumPoints ()
 
float getX (final int index)
 
float getY (final int index)
 
void setIsHole (final boolean isHole)
 
boolean isContributing (final int polyIndex)
 
void setContributing (final int polyIndex, final boolean contributes)
 
- Protected Member Functions inherited from geomerative.RGeomElem
void saveContext (PGraphics g)
 
void saveContext (PApplet p)
 
void saveContext ()
 
void restoreContext (PGraphics g)
 
void restoreContext (PApplet p)
 
void restoreContext ()
 
void setContext (PGraphics g)
 
void setContext (PApplet p)
 
void setContext ()
 
void setStyle (RGeomElem p)
 
void setStyle (String styleString)
 
void calculateCurveLengths ()
 
void updateOrigParams ()
 

Private Member Functions

void append (final RContour nextcontour)
 

Related Functions

(Note that these are not member functions.)

RContour[] contours
 
RPoint getCentroid ()
 
int countContours ()
 
void addContour (final RContour c)
 
void addContour ()
 
void addContour (final RPoint[] points)
 
void setContour (final int indContour)
 
void addPoint (final RPoint p)
 
void addPoint (final float x, final float y)
 
void addPoint (final int indContour, final RPoint p)
 
void addPoint (final int indContour, final float x, final float y)
 
RMesh toMesh ()
 
float getArea ()
 
void draw (final PGraphics g)
 
RPolygon intersection (final RPolygon p)
 
RPolygon union (final RPolygon p)
 
RPolygon xor (final RPolygon p)
 
RPolygon diff (final RPolygon p)
 
RPolygon update ()
 

Additional Inherited Members

- Protected Attributes inherited from geomerative.RGeomElem
float[] lenCurves
 
float lenCurve = -1F
 
RStyle style = new RStyle()
 

Detailed Description

RPolygon is a reduced interface for creating, holding and drawing complex polygons. Polygons are groups of one or more contours (RContour). This interface allows us to perform binary operations (difference, xor, union and intersection) on polygons.

RPolygon Geometry

( ) ( ) ( ) ( ) ( ) ( ) ( )

Constructor & Destructor Documentation

geomerative.RPolygon.RPolygon ( final RPolygon  p)

Make a copy of the given polygon.

createPolygon

Parameters
pthe object of which to make a copy
geomerative.RPolygon.RPolygon ( final RPoint[]  points)

Create a new polygon given an array of points.

createPolygon

Parameters
pointsthe points for the new polygon.
geomerative.RPolygon.RPolygon ( final RContour  newcontour)

Create a new polygon given a contour.

Parameters
newcontourthe contour for the new polygon.
geomerative.RPolygon.RPolygon ( )

Create an empty polygon.

Member Function Documentation

void geomerative.RPolygon.add ( final float  x,
final float  y 
)
protected

Add a point to the first inner polygon.

void geomerative.RPolygon.add ( final RPoint  p)
protected

Add a point to the first inner polygon.

void geomerative.RPolygon.add ( final RPolygon  p)
protected

Add an inner polygon to this polygon - assumes that adding polygon does not have any inner polygons.

void geomerative.RPolygon.add ( final RContour  c)
protected

Add an inner polygon to this polygon - assumes that adding polygon does not have any inner polygons.

void geomerative.RPolygon.addClose ( )
void geomerative.RPolygon.append ( final RContour  nextcontour)
private
void geomerative.RPolygon.clear ( )
protected

Use this method to transform the polygon.

RPolygon_transform

Parameters
mRMatrix, the matrix of the affine transformation to apply to the polygon Remove all of the points. Creates an empty polygon.
boolean geomerative.RPolygon.contains ( final RPoint  p)
static RPolygon geomerative.RPolygon.createCircle ( final float  x,
final float  y,
final float  radius,
final int  detail 
)
static

Use this method to create a new circle polygon.

createCircle

Parameters
radiusthe radius of the circle
detailthe number of vertices of the polygon
Returns
RPolygon, the circular polygon newly created
static RPolygon geomerative.RPolygon.createCircle ( final float  radius,
final int  detail 
)
static
static RPolygon geomerative.RPolygon.createCircle ( final float  x,
final float  y,
final float  radius 
)
static
static RPolygon geomerative.RPolygon.createCircle ( final float  radius)
static
static RPolygon geomerative.RPolygon.createRectangle ( final float  x,
final float  y,
final float  w,
final float  h 
)
static

Use this method to create a new rectangle polygon.

createRectangle

Parameters
xthe upper-left corner x coordinate
ythe upper-left corner y coordinate
wthe width
hthe height
Returns
RPolygon, the circular polygon newly created
static RPolygon geomerative.RPolygon.createRectangle ( final float  w,
final float  h 
)
static
static RPolygon geomerative.RPolygon.createRing ( final float  x,
final float  y,
final float  radiusBig,
final float  radiusSmall,
final int  detail 
)
static

Use this method to create a new ring polygon.

createRing

Parameters
radiusBigthe outter radius of the ring polygon
radiusSmallthe inner radius of the ring polygon
detailthe number of vertices on each contour of the ring
Returns
RPolygon, the ring polygon newly created
static RPolygon geomerative.RPolygon.createRing ( final float  radiusBig,
final float  radiusSmall,
final int  detail 
)
static
static RPolygon geomerative.RPolygon.createRing ( final float  x,
final float  y,
final float  radiusBig,
final float  radiusSmall 
)
static
static RPolygon geomerative.RPolygon.createRing ( final float  radiusBig,
final float  radiusSmall 
)
static
static RPolygon geomerative.RPolygon.createStar ( final float  x,
final float  y,
final float  radiusBig,
final float  radiusSmall,
final int  spikes 
)
static

Use this method to create a new starform polygon.

createStar

Parameters
radiusBigthe outter radius of the star polygon
radiusSmallthe inner radius of the star polygon
spikesthe amount of spikes on the star polygon
Returns
RPolygon, the starform polygon newly created
static RPolygon geomerative.RPolygon.createStar ( final float  radiusBig,
final float  radiusSmall,
final int  spikes 
)
static
void geomerative.RPolygon.draw ( final PApplet  g)
RRectangle geomerative.RPolygon.getBBox ( )
protected

Returns the bounding box of the polygon.

RPoint [] geomerative.RPolygon.getHandles ( )

Use this to return the points of the polygon. It returns the points in the way of an array of RPoint.

RPolygon_getHandles

Returns
RPoint[], the points returned in an array.
RPoint [][] geomerative.RPolygon.getHandlesInPaths ( )
RPolygon geomerative.RPolygon.getInnerPoly ( final int  polyIndex)
protected

Returns the polygon at this index.

int geomerative.RPolygon.getNumInnerPoly ( )
protected

Returns the number of inner polygons - inner polygons are assumed to return one here.

int geomerative.RPolygon.getNumPoints ( )
protected

Return the number points of the first inner polygon

RPoint geomerative.RPolygon.getPoint ( final float  t)
RPoint [] geomerative.RPolygon.getPoints ( )

Use this to return the points of the polygon. It returns the points in the way of an array of RPoint.

RPolygon_getPoints

Returns
RPoint[], the points returned in an array.
RPoint [][] geomerative.RPolygon.getPointsInPaths ( )
RPoint geomerative.RPolygon.getTangent ( final float  t)
RPoint [] geomerative.RPolygon.getTangents ( )
RPoint [][] geomerative.RPolygon.getTangentsInPaths ( )
int geomerative.RPolygon.getType ( )

Use this method to get the type of element this is.

RPolygon_getType

Returns
int, will allways return RGeomElem.POLYGON
float geomerative.RPolygon.getX ( final int  index)
protected

Return the X value of the point at the index in the first inner polygon

float geomerative.RPolygon.getY ( final int  index)
protected

Return the Y value of the point at the index in the first inner polygon

boolean geomerative.RPolygon.isContributing ( final int  polyIndex)
protected

Return true if the given inner polygon is contributing to the set operation. This method should NOT be used outside the Clip algorithm.

boolean geomerative.RPolygon.isEmpty ( )
protected

Return true if the polygon is empty

boolean geomerative.RPolygon.isHole ( )

Return true if this polygon is a hole. Holes are assumed to be inner polygons of a more complex polygon.

Exceptions
IllegalStateExceptionif called on a complex polygon.
void geomerative.RPolygon.print ( )
RPolygon geomerative.RPolygon.removeOpenContours ( )
protected

Removes contours with less than 3 points. These are contours that are open. Since close polygons have points[0] == points[-1] and two more points to form a triangle at least. This is useful to avoid the clipping algorithm from breaking.

void geomerative.RPolygon.setContributing ( final int  polyIndex,
final boolean  contributes 
)
protected

Set whether or not this inner polygon is constributing to the set operation. This method should NOT be used outside the Clip algorithm.

void geomerative.RPolygon.setIsHole ( final boolean  isHole)
protected

Set whether or not this polygon is a hole. Cannot be called on a complex polygon.

Exceptions
IllegalStateExceptionif called on a complex polygon.
RPolygon geomerative.RPolygon.toPolygon ( )
RShape geomerative.RPolygon.toShape ( )

Friends And Related Function Documentation

void addContour ( final RContour  c)
related

Add a new contour to the polygon.

addContour

Parameters
cthe contour to be added ( )
void addContour ( )
related

Add an empty contour to the polygon.

addContour ( )

void addContour ( final RPoint[]  points)
related

Add a new contour to the polygon given an array of points.

addContour

Parameters
pointsthe points of the new contour to be added ( )
void addPoint ( final RPoint  p)
related

Add a new point to the current contour.

addPoint

Parameters
pthe point to be added ( ) ( )
void addPoint ( final float  x,
final float  y 
)
related

Add a new point to the current contour.

addPoint

Parameters
xthe x coordinate of the point to be added
ythe y coordinate of the point to be added ( ) ( )
void addPoint ( final int  indContour,
final RPoint  p 
)
related

Add a new point to the selected contour.

addPoint

Parameters
indContourthe index of the contour to which the point will be added
pthe point to be added ( ) ( )
void addPoint ( final int  indContour,
final float  x,
final float  y 
)
related

Add a new point to the selected contour.

addPoint

Parameters
indContourthe index of the contour to which the point will be added
xthe x coordinate of the point to be added
ythe y coordinate of the point to be added ( ) ( )
RContour [] contours
related

Array of RContour objects holding the contours of the polygon.

contours

( ) ( )

int countContours ( )
related

Use this method to count the number of contours in the polygon.

countContours

Returns
int the number contours in the polygon ( )
RPolygon diff ( final RPolygon  p)
related

Use this method to get the difference between this polygon and the polygon passed in as a parameter.

diff

Parameters
pRPolygon, the polygon with which to perform the difference
Returns
RPolygon, the difference of the two polygons ( ) ( ) ( )
void draw ( final PGraphics  g)
related

Use this method to draw the polygon.

drawPolygon

Parameters
gPGraphics, the graphics object on which to draw the polygon ( )
float getArea ( )
related

Use this method to get the area covered by the polygon.

getArea

Returns
float, the area covered by the polygon ( )
RPoint getCentroid ( )
related

Use this method to get the centroid of the element.

RGroup_getCentroid

Returns
RPo the centroid point of the element ( ) ( )
RPolygon intersection ( final RPolygon  p)
related

Use this method to get the intersection of this polygon with the polygon passed in as a parameter.

intersection

Parameters
pRPolygon, the polygon with which to perform the intersection
Returns
RPolygon, the intersection of the two polygons ( ) ( ) ( )
void setContour ( final int  indContour)
related

Use this method to set the current contour to which append points.

addContour ( )

RMesh toMesh ( )
related

Use this method to create a new mesh from a given polygon.

toMesh

Returns
RMesh, the mesh made of tristrips resulting of a tesselation of the polygon ( )
RPolygon union ( final RPolygon  p)
related

Use this method to get the union of this polygon with the polygon passed in as a parameter.

union

Parameters
pRPolygon, the polygon with which to perform the union
Returns
RPolygon, the union of the two polygons ( ) ( ) ( )
RPolygon update ( )
related

Use this method to get a rebuilt version of a given polygon by removing extra points and solving intersecting contours or holes.

RPolygon_update

Returns
RPolygon, the updated polygon ( ) ( ) ( ) ( )
RPolygon xor ( final RPolygon  p)
related

Use this method to get the xor of this polygon with the polygon passed in as a parameter.

xor

Parameters
pRPolygon, the polygon with which to perform the xor
Returns
RPolygon, the xor of the two polygons ( ) ( ) ( )

Member Data Documentation

int geomerative.RPolygon.defaultDetail = 50
static
int geomerative.RPolygon.type = RGeomElem.POLYGON

The documentation for this class was generated from the following file: