java.nio.DoubleBuffer#position ( )源码实例Demo

下面列出了java.nio.DoubleBuffer#position ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: JavaAV   文件: Image.java
public static void copy(DoubleBuffer srcBuf, int srcStep, DoubleBuffer dstBuf, int dstStep) {
	int w = Math.min(srcStep, dstStep);
	int srcLine = srcBuf.position();
	int dstLine = dstBuf.position();

	while (srcLine < srcBuf.capacity() && dstLine < dstBuf.capacity()) {
		srcBuf.position(srcLine);
		dstBuf.position(dstLine);

		w = Math.min(Math.min(w, srcBuf.remaining()), dstBuf.remaining());

		for (int x = 0; x < w; x++) {
			double in = srcBuf.get();
			double out = in;

			dstBuf.put(out);
		}

		srcLine += srcStep;
		dstLine += dstStep;
	}
}
 
源代码2 项目: java   文件: DoubleNioDataBuffer.java
@Override
public DoubleDataBuffer slice(long index, long size) {
  Validator.sliceArgs(this, index, size);
  DoubleBuffer sliceBuf = buf.duplicate();
  sliceBuf.position((int)index);
  sliceBuf.limit((int)index + (int)size);
  return new DoubleNioDataBuffer(sliceBuf.slice());
}
 
源代码3 项目: Word2VecJava   文件: SearcherImpl.java
private double[] getVectorOrNull(final String word) {
final Integer index = word2vectorOffset.get(word);
  if(index == null)
	return null;

final DoubleBuffer vectors = model.vectors.duplicate();
double[] result = new double[model.layerSize];
vectors.position(index);
vectors.get(result);
return result;
 }
 
源代码4 项目: OSPREY3   文件: VectorAlgebra.java
public static void copy(double[] src, int srcOffset, DoubleBuffer dest, int destOffset) {
	dest.position(destOffset);
	dest.put(src, srcOffset, 3);
}
 
源代码5 项目: OSPREY3   文件: VectorAlgebra.java
public static void copy(DoubleBuffer src, int srcOffset, double[] dest, int destOffset) {
	src.position(srcOffset);
	dest[destOffset + 0] = src.get();
	dest[destOffset + 1] = src.get();
	dest[destOffset + 2] = src.get();
}
 
源代码6 项目: bazel   文件: NioBufferInvocations.java
public static DoubleBuffer getDoubleBufferPosition(DoubleBuffer buffer, int position) {
  return buffer.position(position);
}
 
源代码7 项目: BIMserver   文件: GeometryRunner.java
private BufferSet appendInvertedGeometry(IntBuffer indicesAsInt, DoubleBuffer verticesAsDouble, FloatBuffer normalsAsFloat, IntBuffer colorIndices) {
	indicesAsInt.position(0);
	normalsAsFloat.position(0);
	
	ByteBuffer newVerticesByteBuffer = ByteBuffer.allocate(verticesAsDouble.capacity() * 16);
	DoubleBuffer newVerticesBuffer = newVerticesByteBuffer.order(ByteOrder.LITTLE_ENDIAN).asDoubleBuffer();
	verticesAsDouble.position(0);
	newVerticesBuffer.put(verticesAsDouble);
	verticesAsDouble.position(0);
	newVerticesBuffer.put(verticesAsDouble);
	
	int nrVertices = verticesAsDouble.capacity() / 3;
	
	ByteBuffer newIntByteBuffer = ByteBuffer.allocate(indicesAsInt.capacity() * 8);
	IntBuffer newIntBuffer = newIntByteBuffer.order(ByteOrder.LITTLE_ENDIAN).asIntBuffer();
	for (int i=0; i<indicesAsInt.capacity(); i+=3) {
		int index1 = indicesAsInt.get();
		int index2 = indicesAsInt.get();
		int index3 = indicesAsInt.get();
		newIntBuffer.put(i, index1);
		newIntBuffer.put(i + 1, index2);
		newIntBuffer.put(i + 2, index3);
		
		// And draw the same triangle again in a different order
		newIntBuffer.put(i + indicesAsInt.capacity(), index1 + nrVertices);
		newIntBuffer.put(i + indicesAsInt.capacity() + 1, index3 + nrVertices);
		newIntBuffer.put(i + indicesAsInt.capacity() + 2, index2 + nrVertices);
	}

	ByteBuffer newNormalsByteBuffer = ByteBuffer.allocate(normalsAsFloat.capacity() * 8);
	FloatBuffer newNormalsBuffer = newNormalsByteBuffer.order(ByteOrder.LITTLE_ENDIAN).asFloatBuffer();
	normalsAsFloat.position(0);
	newNormalsBuffer.put(normalsAsFloat);
	for (int i=0; i<normalsAsFloat.capacity(); i+=3) {
		float[] normal = new float[] {normalsAsFloat.get(i + 0), normalsAsFloat.get(i + 1), normalsAsFloat.get(i + 2)};
		normal = Vector.invert(normal);
		newNormalsBuffer.put(i + normalsAsFloat.capacity(), normal[0]);
		newNormalsBuffer.put(i + 1 + normalsAsFloat.capacity(), normal[1]);
		newNormalsBuffer.put(i + 2 + normalsAsFloat.capacity(), normal[2]);
	}
	
	ByteBuffer newColorsByteBuffer = ByteBuffer.allocate(colorIndices.capacity() * 8);
	IntBuffer newColorsBuffer = newColorsByteBuffer.order(ByteOrder.LITTLE_ENDIAN).asIntBuffer();
	colorIndices.position(0);
	newColorsBuffer.put(colorIndices);
	colorIndices.position(0);
	newColorsBuffer.put(colorIndices);
	
	return new BufferSet(newIntByteBuffer, newVerticesByteBuffer, newNormalsByteBuffer, newColorsByteBuffer);
}
 
源代码8 项目: JOML   文件: Matrix3x2d.java
/**
 * Set the values of this matrix by reading 6 double values from the given {@link DoubleBuffer} in column-major order,
 * starting at its current position.
 * <p>
 * The DoubleBuffer is expected to contain the values in column-major order.
 * <p>
 * The position of the DoubleBuffer will not be changed by this method.
 * 
 * @param buffer
 *              the DoubleBuffer to read the matrix values from in column-major order
 * @return this
 */
public Matrix3x2d set(DoubleBuffer buffer) {
    int pos = buffer.position();
    MemUtil.INSTANCE.get(this, pos, buffer);
    return this;
}