From 1051aacc7c2e89d08cbb533a36b2795d654bd3bd Mon Sep 17 00:00:00 2001 From: Gustl22 Date: Tue, 19 Mar 2019 15:06:54 +0100 Subject: [PATCH] GeometryBuffer minor improvements (#703) --- vtm/src/org/oscim/core/GeometryBuffer.java | 35 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/vtm/src/org/oscim/core/GeometryBuffer.java b/vtm/src/org/oscim/core/GeometryBuffer.java index 0a5f63f1..6b9cc82b 100644 --- a/vtm/src/org/oscim/core/GeometryBuffer.java +++ b/vtm/src/org/oscim/core/GeometryBuffer.java @@ -107,7 +107,7 @@ public class GeometryBuffer { /** * Instantiates a new geometry buffer. * - * @param numPoints the num of expected points + * @param numPoints the num of expected 2D points * @param numIndices the num of expected indices */ public GeometryBuffer(int numPoints, int numIndices) { @@ -152,6 +152,7 @@ public class GeometryBuffer { /** * @param out PointF to set coordinates to. + * @param i the 2D point position. * @return when out is null a temporary PointF is * returned which belongs to GeometryBuffer. */ @@ -160,16 +161,25 @@ public class GeometryBuffer { out.y = points[(i << 1) + 1]; } + /** + * @param i the 2D point position. + * @return the x-coordinate of point. + */ public float getPointX(int i) { return points[(i << 1)]; } + /** + * @param i the 2D point position. + * @return the y-coordinate of point. + */ public float getPointY(int i) { return points[(i << 1) + 1]; } /** - * @return PointF belongs to GeometryBuffer. + * @param i the 2D point position. + * @return the PointF that belongs to GeometryBuffer. */ public PointF getPoint(int i) { PointF out = mTmpPoint; @@ -178,10 +188,25 @@ public class GeometryBuffer { return out; } + /** + * Get the number of 2D points. + * + * @return the number of 2D points. + */ public int getNumPoints() { return pointNextPos >> 1; } + /** + * Get the used size of points array. + * Equal to the next position to insert point in points array. + * + * @return the size of point array. + */ + public int getPointsSize() { + return pointNextPos; + } + /** * Reset buffer. */ @@ -229,9 +254,9 @@ public class GeometryBuffer { /** * Sets the point x,y at position pos. * - * @param pos the pos - * @param x the x ordinate - * @param y the y ordinate + * @param pos the 2D point position + * @param x the x coordinate (abscissa) + * @param y the y coordinate (ordinate) */ public void setPoint(int pos, float x, float y) { points[(pos << 1) + 0] = x;