private double interpolate_value( final UnstructuredVolumeObject volume, final int index0, final int index1) throws KVSException { Buffer buf = volume.values(); float[] coords = volume.coords(); final float value0 = this.substitute_plane_equation(new Vector3f(coords, 3 * index0)); final float value1 = this.substitute_plane_equation(new Vector3f(coords, 3 * index1)); final float ratio = kvs.core.util.Math.abs(value0 / (value1 - value0)); if (buf instanceof ByteBuffer) { ByteBuffer values = (ByteBuffer) buf; return (values.get(index0) + ratio * (values.get(index1) - values.get(index0))); } else if (buf instanceof ShortBuffer) { ShortBuffer values = (ShortBuffer) buf; return (values.get(index0) + ratio * (values.get(index1) - values.get(index0))); } else if (buf instanceof IntBuffer) { IntBuffer values = (IntBuffer) buf; return (values.get(index0) + ratio * (values.get(index1) - values.get(index0))); } else if (buf instanceof LongBuffer) { LongBuffer values = (LongBuffer) buf; return (values.get(index0) + ratio * (values.get(index1) - values.get(index0))); } else if (buf instanceof FloatBuffer) { FloatBuffer values = (FloatBuffer) buf; return (values.get(index0) + ratio * (values.get(index1) - values.get(index0))); } else if (buf instanceof DoubleBuffer) { DoubleBuffer values = (DoubleBuffer) buf; return (values.get(index0) + ratio * (values.get(index1) - values.get(index0))); } else if (buf instanceof CharBuffer) { CharBuffer values = (CharBuffer) buf; return (values.get(index0) + ratio * (values.get(index1) - values.get(index0))); } else { throw new KVSException("Unsupported data type"); } }
private Vector3f interpolate_vertex(final Vector3f vertex0, final Vector3f vertex1) { float value0 = this.substitute_plane_equation(vertex0); float value1 = this.substitute_plane_equation(vertex1); float ratio = kvs.core.util.Math.abs(value0 / (value1 - value0)); return (vertex0.mul(1.0f - ratio).add(vertex1.mul(ratio))); }
private double interpolate_value( final StructuredVolumeObject volume, final Vector3f vertex0, final Vector3f vertex1) throws KVSException { Buffer buf = volume.values(); final int line_size = volume.nnodesPerLine(); final int slice_size = volume.nnodesPerSlice(); final float value0 = this.substitute_plane_equation(vertex0); final float value1 = this.substitute_plane_equation(vertex1); final float ratio = kvs.core.util.Math.abs(value0 / (value1 - value0)); final int index0 = (int) (vertex0.getX() + vertex0.getY() * line_size + vertex0.getZ() * slice_size); final int index1 = (int) (vertex1.getX() + vertex1.getY() * line_size + vertex1.getZ() * slice_size); if (buf instanceof ByteBuffer) { ByteBuffer values = (ByteBuffer) buf; return (values.get(index0) + ratio * (values.get(index1) - values.get(index0))); } else if (buf instanceof ShortBuffer) { ShortBuffer values = (ShortBuffer) buf; return (values.get(index0) + ratio * (values.get(index1) - values.get(index0))); } else if (buf instanceof IntBuffer) { IntBuffer values = (IntBuffer) buf; return (values.get(index0) + ratio * (values.get(index1) - values.get(index0))); } else if (buf instanceof LongBuffer) { LongBuffer values = (LongBuffer) buf; return (values.get(index0) + ratio * (values.get(index1) - values.get(index0))); } else if (buf instanceof FloatBuffer) { FloatBuffer values = (FloatBuffer) buf; return (values.get(index0) + ratio * (values.get(index1) - values.get(index0))); } else if (buf instanceof DoubleBuffer) { DoubleBuffer values = (DoubleBuffer) buf; return (values.get(index0) + ratio * (values.get(index1) - values.get(index0))); } else if (buf instanceof CharBuffer) { CharBuffer values = (CharBuffer) buf; return (values.get(index0) + ratio * (values.get(index1) - values.get(index0))); } else { throw new KVSException("Unsupported data type"); } }