Examples of DoubleBuffer


Examples of java.nio.DoubleBuffer

    direct_buffer.position(buffer.position());
    return direct_buffer;
  }

  private static DoubleBuffer doNoCopyWrap(DoubleBuffer buffer) {
    DoubleBuffer direct_buffer = lookupBuffer(buffer);
    direct_buffer.limit(buffer.limit());
    direct_buffer.position(buffer.position());
    return direct_buffer;
  }
View Full Code Here

Examples of java.nio.DoubleBuffer

    CachedBuffers buffers = getCachedBuffers(buffer.remaining()*8);
    return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.double_buffer_little : buffers.double_buffer_big;
  }

  private static DoubleBuffer doWrap(DoubleBuffer buffer) {
    DoubleBuffer direct_buffer = lookupBuffer(buffer);
    direct_buffer.clear();
    int saved_position = buffer.position();
    direct_buffer.put(buffer);
    buffer.position(saved_position);
    direct_buffer.flip();
    return direct_buffer;
  }
View Full Code Here

Examples of java.nio.DoubleBuffer

    // In addition to improving the performance, this also dramatically decreases the
    // lag effect of loading a scene larger than the video RAM. Indeed, when using JVM
    // memory, the sanction is immediate : the scene becomes quite impossible to manipulate.
    // With NIO buffers, there is a progressive degradation of performances when the scene
    // doesn't fit entirely in the 3D card RAM.
    DoubleBuffer nioCoords = ByteBuffer.allocateDirect(triangles.length*3 * 8).order(ByteOrder.nativeOrder()).asDoubleBuffer();
    FloatBuffer nioColors = ByteBuffer.allocateDirect(triangles.length*3 * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
    FloatBuffer nioNormals = ByteBuffer.allocateDirect(triangles.length * 3 * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();

    // Set up the coordinates loaded by the parent method into the
    // NIO buffers.
    // This also expand the geometry. The file is described in indexed mode : triangles
    // are defined by indexing points.
    // Java3D also has an indexed mode, and using it would be immediate.
    // Unfortunately, when using an indexed mode, the triangle vertices are shared by definition.
    // It is thus not possible to change the values for the vertices for only one triangle
    // For example, when highlighting a triangle, it is necessary to modify the colors of
    // this triangle only, not its neighbors.
    // On the other hand, if picking/highlighting was done on vertices only, then modifying
    // all triangles using this vertex could be a good idea.
    // In this example, a triangle is picked, and the closest vertex is also shown, but
    // highlighted only in this triangle. This is not that complicated, but shows potential
    // problems. One should thus be able to easily adapt this example to simpler cases.
    for (int i=0; i<triangles.length; i+=3) {
      int pt = triangles[i];
      nioCoords.put(data[0][pt]);
      nioCoords.put(data[1][pt]);
      nioCoords.put(data[2][pt]);
      pt = triangles[i+1];
      nioCoords.put(data[0][pt]);
      nioCoords.put(data[1][pt]);
      nioCoords.put(data[2][pt]);
      pt = triangles[i+2];
      nioCoords.put(data[0][pt]);
      nioCoords.put(data[1][pt]);
      nioCoords.put(data[2][pt]);
    }

    // Create a triangle array using NIO.
    // Unfortunately, Sun picking utilities don't handle NIO very well, thus
    // we need to overload a method
    TriangleArray ta = new TriangleArray(triangles.length, GeometryArray.BY_REFERENCE|GeometryArray.USE_NIO_BUFFER|GeometryArray.COORDINATES|GeometryArray.NORMALS|GeometryArray.COLOR_3) {
      public double[] getCoordRefDouble() {
        // When picking, tests have shown that NIO buffer copy has no noticeable impact
        // on performance. So, it is actually better to copy the array each time the picking is
        // done than to hog memory with a permanent copy.
        // It is also still better to copy the buffer only when picking rather than at each rendering
        double[] array = new double[getVertexCount()*3];
        DoubleBuffer db = (DoubleBuffer)super.getCoordRefBuffer().getBuffer();
        db.rewind();
        db.get(array); // optimized get
        return array;
      }
    };
      ta.setCoordRefBuffer(new J3DBuffer(nioCoords));

View Full Code Here

Examples of java.nio.DoubleBuffer

      ja[i] = iter.getDoubleNext();
  }

  public ByteBuffer getDataAsByteBuffer() {
    ByteBuffer bb = ByteBuffer.allocate((int)(8*getSize()));
    DoubleBuffer ib = bb.asDoubleBuffer();
    ib.put( (double[]) get1DJavaArray(double.class)); // make sure its in canonical order
    return bb;
  }
View Full Code Here

Examples of java.nio.DoubleBuffer

                    for (int i = 0; i < length; i++) {
                        fb.put((float)vv[i+offset]);
                    }
                    break;
                case CV_64F:
                    DoubleBuffer db = getDoubleBuffer();
                    db.position(index);
                    db.put(vv, offset, length);
                    break;
                default: assert(false);
            }
        }
View Full Code Here

Examples of java.nio.DoubleBuffer

        return out;
    }

    public double[] gluUnProject(float x, float y, float z) {
        DoubleBuffer buffer = BufferUtil.newDoubleBuffer(3);
        glu.gluUnProject(x, y, z, modelMatrix, projMatrix, viewport, buffer);
        return new double[]{buffer.get(0), buffer.get(1), buffer.get(2)};
    }
View Full Code Here

Examples of java.nio.DoubleBuffer

//            graysrc = src;
//        }

        // compute integral images
        cvIntegral(src, sumimage, sqsumimage, null);
        final DoubleBuffer sumbuf = sumimage.getByteBuffer().asDoubleBuffer();
        final DoubleBuffer sqsumbuf = sqsumimage.getByteBuffer().asDoubleBuffer();
        final int sumstep = sumimage.widthStep();
        final int sqsumstep = sqsumimage.widthStep();
        final ByteBuffer srcbuf = src.getByteBuffer();
        final ByteBuffer dstbuf = dst.getByteBuffer();
        final int srcstep = src.widthStep();
        final int dststep = dst.widthStep();

        // try to detect a reasonable maximum and minimum intensity
        // for thresholds instead of simply 0 and 255...
        double totalmean = sumbuf.get((h-1)*sumstep/8 + (w-1)) -
                           sumbuf.get((h-1)*sumstep/8) -
                           sumbuf.get(w-1) + sumbuf.get(0);
        totalmean /= w*h;
        double totalsqmean = sqsumbuf.get((h-1)*sqsumstep/8 + (w-1)) -
                             sqsumbuf.get((h-1)*sqsumstep/8) -
                             sqsumbuf.get(w-1) + sqsumbuf.get(0);
        totalsqmean /= w*h;
        double totalvar = totalsqmean - totalmean*totalmean;
//double totaldev = Math.sqrt(totalvar);
//System.out.println(totaldev);
        final double targetvar = totalvar*varmultiplier;

        //for (int y = 0; y < h; y++) {
        Parallel.loop(0, h, new Looper() {
        public void loop(int from, int to, int looperID) {
            for (int y = from; y < to; y++) {
                for (int x = 0; x < w; x++) {
                    double var = 0, mean = 0, sqmean = 0;
                    int upperlimit = maxwindow;
                    int lowerlimit = minwindow;
                    int window = upperlimit; // start with maxwindow
                    while (upperlimit - lowerlimit > 2) {
                        int x1 = Math.max(x-window/2, 0);
                        int x2 = Math.min(x+window/2+1, w);

                        int y1 = Math.max(y-window/2, 0);
                        int y2 = Math.min(y+window/2+1, h);

                        mean = sumbuf.get(y2*sumstep/8 + x2) -
                               sumbuf.get(y2*sumstep/8 + x1) -
                               sumbuf.get(y1*sumstep/8 + x2) +
                               sumbuf.get(y1*sumstep/8 + x1);
                        mean /= window*window;
                        sqmean = sqsumbuf.get(y2*sqsumstep/8 + x2) -
                                           sqsumbuf.get(y2*sqsumstep/8 + x1) -
                                           sqsumbuf.get(y1*sqsumstep/8 + x2) +
                                           sqsumbuf.get(y1*sqsumstep/8 + x1);
                        sqmean /= window*window;
                        var = sqmean - mean*mean;

                        // if we're at maximum window size, but variance is
                        // too low anyway, let's break out immediately
View Full Code Here

Examples of java.nio.DoubleBuffer

                for (int i = 0; i < sb.capacity(); i++) {
                    db.put(i, (int)Math.max(Math.min(sb.get(i),max),min));
                }
                break; }
            case IPL_DEPTH_64F: {
                DoubleBuffer sb = src.getByteBuffer().asDoubleBuffer();
                DoubleBuffer db = dst.getByteBuffer().asDoubleBuffer();
                for (int i = 0; i < sb.capacity(); i++) {
                    db.put(i, Math.max(Math.min(sb.get(i),max),min));
                }
                break; }
            default: assert(false);
        }
View Full Code Here

Examples of java.nio.DoubleBuffer

          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_DOUBLE_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
          buf = ByteBuffer.allocate(arraySize * 8);
          DoubleBuffer doublebuf = buf.asDoubleBuffer();
          double[] doubleArray = new double[arraySize];
          for (int i = arrayStart; i < arrayStart + arraySize; i++) {
            doubleArray[i - arrayStart] = Double.longBitsToDouble(this.getLongHeap().heap[i]);
          }
          doublebuf.put(doubleArray);
          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        }

      } else if (null != aSofa.getSofaURI()) {
View Full Code Here

Examples of java.nio.DoubleBuffer

            // Make sure the temp file goes away since it can get fairly large
            // for big matrices
            f.deleteOnExit();
            RandomAccessFile raf = new RandomAccessFile(f, "rw");
            FileChannel fc = raf.getChannel();
            DoubleBuffer contextBuffer =
                fc.map(MapMode.READ_WRITE, 0, size).asDoubleBuffer();
            fc.close();
            return new Duple<DoubleBuffer,File>(contextBuffer, f);
        } catch (IOException ioe) {
            throw new IOError(ioe);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.