public class GeometryBuffer
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
GeometryBuffer.GeometryType
The Enum GeometryType.
|
| Modifier and Type | Field and Description |
|---|---|
int[] |
index
The indexes.
|
int |
indexCurrentPos
The current index position.
|
int |
pointNextPos
The next position to insert a point in points array (equal to array size).
|
float[] |
points
The points.
|
GeometryBuffer.GeometryType |
type
The current geometry type.
|
| Constructor and Description |
|---|
GeometryBuffer() |
GeometryBuffer(float[] points,
int[] index)
Instantiates a new geometry buffer.
|
GeometryBuffer(GeometryBuffer buffer) |
GeometryBuffer(int numPoints,
int numIndices)
Instantiates a new geometry buffer.
|
| Modifier and Type | Method and Description |
|---|---|
GeometryBuffer |
addPoint(float x,
float y)
Adds a point with the coordinate x, y.
|
void |
addPoint(Point p)
Add a
Point. |
void |
addPoint(PointF p)
Add a
PointF. |
float |
area()
Calculates geometry area, only polygon outer ring is taken into account.
|
GeometryBuffer |
clear()
Reset buffer.
|
int[] |
ensureIndexSize(int size,
boolean copy)
Ensure index size.
|
float[] |
ensurePointSize(int size,
boolean copy)
Ensure that 'points' array can hold the number of points.
|
int |
getNumPoints()
Get the number of 2D points.
|
PointF |
getPoint(int i) |
void |
getPoint(int i,
PointF out) |
int |
getPointsSize()
Get the used size of points array.
|
float |
getPointX(int i) |
float |
getPointY(int i) |
float |
isClockwise() |
boolean |
isLine() |
boolean |
isPoint() |
boolean |
isPoly() |
boolean |
isTris() |
static GeometryBuffer |
makeCircle(float x,
float y,
float radius,
int segments) |
static GeometryBuffer |
makeCircle(GeometryBuffer g,
float x,
float y,
float radius,
int segments) |
void |
removeLastPoint()
Remove the last point.
|
void |
reverse()
Reverse the order of points for lines and polygons.
|
GeometryBuffer |
scale(float scaleX,
float scaleY)
Scale.
|
void |
setPoint(int pos,
float x,
float y)
Sets the point x,y at position pos.
|
void |
simplify(float minSqDist,
boolean keepLines)
Remove points with distance less than minSqDist
TODO could avoid superfluous copying
|
void |
startHole()
Starts a new polygon hole (inner ring).
|
GeometryBuffer |
startLine()
Start a new line.
|
void |
startPoints()
Set geometry type for points.
|
GeometryBuffer |
startPolygon()
Start a new polygon.
|
java.lang.String |
toString() |
GeometryBuffer |
translate(float dx,
float dy)
Translate.
|
public float[] points
POLY/LINE: store point in order of polygon with points[2 * n + 0] = x; points[2 * n + 1] = y; n is a N.
MESH: store points anywhere with points[3 * n + 0] = x; points[3 * n + 1] = y; points[3 * n + 2] = z; n ∈ ℕ0.
public int[] index
POLY/LINE: store 2 * number of points of each polygon / line. Point is (x, y).
MESH: store point indices of triangle (p1, p2, p3) with index[3 * n + 0] = p1; index[3 * n + 1] = p2; index[3 * n + 2] = p3; n ∈ ℕ0. Point p is (x, y, z).
public int indexCurrentPos
public int pointNextPos
public GeometryBuffer.GeometryType type
public GeometryBuffer()
public GeometryBuffer(int numPoints,
int numIndices)
numPoints - the num of expected 2D pointsnumIndices - the num of expected indicespublic GeometryBuffer(float[] points,
int[] index)
points - the pointsindex - the indexpublic GeometryBuffer(GeometryBuffer buffer)
buffer - the buffer to copypublic void getPoint(int i,
PointF out)
out - PointF to set coordinates to.i - the 2D point position.public float getPointX(int i)
i - the 2D point position.public float getPointY(int i)
i - the 2D point position.public PointF getPoint(int i)
i - the 2D point position.public int getNumPoints()
public int getPointsSize()
public GeometryBuffer clear()
public GeometryBuffer addPoint(float x, float y)
x - the x ordinatey - the y ordinatepublic boolean isPoly()
public boolean isLine()
public boolean isPoint()
public boolean isTris()
public void setPoint(int pos,
float x,
float y)
pos - the 2D point positionx - the x coordinate (abscissa)y - the y coordinate (ordinate)public void startPoints()
public GeometryBuffer startLine()
public GeometryBuffer startPolygon()
public void startHole()
public GeometryBuffer translate(float dx, float dy)
dx - the x translation.dy - the y translation.public GeometryBuffer scale(float scaleX, float scaleY)
scaleX - the x scale.scaleY - the y scale.public float[] ensurePointSize(int size,
boolean copy)
size - the number of points to holdcopy - the current data when array is reallocatedpublic int[] ensureIndexSize(int size,
boolean copy)
size - the sizecopy - the copypublic void simplify(float minSqDist,
boolean keepLines)
minSqDist - keepLines - keep endpoint when line would
otherwise collapse into a single pointpublic float area()
GeometryUtils.area(float[], int)public float isClockwise()
GeometryUtils.isClockwise(float[], int).public void removeLastPoint()
public void reverse()
public java.lang.String toString()
toString in class java.lang.Objectpublic static GeometryBuffer makeCircle(float x, float y, float radius, int segments)
public static GeometryBuffer makeCircle(GeometryBuffer g, float x, float y, float radius, int segments)