MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / getSegment

Method getSegment

ij/src/main/java/ij/gui/ShapeRoi.java:390–400  ·  view source on GitHub ↗

Reads the data of a segment from an array describing the shape at as in a PathIterator. Reading starts at 'index'. The position in the array for the next segment is returned, -1 if the array ends. The segment type and coordinates of the segment are stored into 'seg' (which must have a length of at

(float[] array, float[] seg, int index)

Source from the content-addressed store, hash-verified

388 * The position in the array for the next segment is returned, -1 if the array ends.
389 * The segment type and coordinates of the segment are stored into 'seg' (which must have a length of at least 7) */
390 private static int getSegment(float[] array, float[] seg, int index) {
391 int len = array.length;
392 if (index>=len) return -1;
393 seg[0] = array[index++];
394 int type = (int)seg[0];
395 int nCoords = nCoords(type);
396 if (index+nCoords > len) return -1;
397 for (int i=1; i<=nCoords; i++)
398 seg[i] = array[index++];
399 return index;
400 }
401
402 /** Returns the number of coordinates for the given PathIterator segment type */
403 private static int nCoords(int segmentType) {

Callers 1

makeShapeFromArrayMethod · 0.95

Calls 1

nCoordsMethod · 0.95

Tested by

no test coverage detected