Ejemplo n.º 1
0
	void
	fill_host(thrust::host_vector<TType> &v)
	{
		int s = size();
		v.resize(s);
		thrust::copy(mBuffer.begin(), mBuffer.begin() + s, v.begin());
	}
Ejemplo n.º 2
0
// copy scoring data to host, converting to io::AlignmentResult
void GPUOutputBatch::readback_scores(thrust::host_vector<io::AlignmentResult>& output,
                                     const AlignmentMate mate,
                                     const AlignmentScore score) const
{
    // copy alignment data into a staging buffer
    thrust::host_vector<io::BestAlignments> best_data_staging;
    nvbio::cuda::thrust_copy_vector(best_data_staging, best_data_dvec, count);

    // convert the contents of the staging buffer into io::AlignmentResult
    output.resize(count);
    for(uint32 c = 0; c < count; c++)
    {
        io::BestAlignments&      old_best_aln = best_data_staging[c];
        io::Alignment&           old_aln = (score == BEST_SCORE ? old_best_aln.m_a1 : old_best_aln.m_a2);
        io::AlignmentResult&    new_aln = output[c];

        if (score == BEST_SCORE)
        {
            new_aln.best[mate] = old_aln;
        } else {
            new_aln.second_best[mate] = old_aln;
        }

        if (mate == MATE_2)
        {
            new_aln.is_paired_end = true;
        }
    }
}
Ejemplo n.º 3
0
void GLWindow::paintGL()
{
    timer->stop();

    if (frame_count == 0) gettimeofday(&begin, 0);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    if (wireframe) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    else glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective( cameraFOV, 1.0, 1.0, grid_size*4.0);

    // set view matrix for 3D scene
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();

    qrot.getRotMat(rotationMatrix);
    glMultMatrixf(rotationMatrix);

//    glTranslatef(-(grid_size-1)/2, -(grid_size-1)/2, -(grid_size-1)/2);
    size_t num_bytes;  GLenum drawType = GL_TRIANGLES;

#ifdef TANGLE
    #ifdef USE_INTEROP
        isosurface->vboResources[0] = quads_pos_res;  isosurface->vboResources[1] = quads_color_res;  isosurface->vboResources[2] = quads_normal_res;
        isosurface->minIso = 31.0f;  isosurface->maxIso = 500.0f;  isosurface->useInterop = true;
        isosurface->vboSize = buffer_size;
    #endif
        (*isosurface)();
    #ifndef USE_INTEROP
        vertices.assign(isosurface->vertices_begin(), isosurface->vertices_end());
        normals.assign(isosurface->normals_begin(), isosurface->normals_end());
        colors.assign(thrust::make_transform_iterator(isosurface->scalars_begin(), color_map<float>(31.0f, 500.0f)),
                      thrust::make_transform_iterator(isosurface->scalars_end(), color_map<float>(31.0f, 500.0f)));
     #endif
#endif

#ifdef CUTPLANE
    #ifdef USE_INTEROP
        cutplane->vboResources[0] = quads_pos_res;  cutplane->vboResources[1] = quads_color_res;  cutplane->vboResources[2] = quads_normal_res;
        cutplane->minIso = 0.0f;  cutplane->maxIso = 1.0f;  cutplane->useInterop = true;
        cutplane->vboSize = buffer_size;
    #endif
    (*cutplane)();
    #ifndef USE_INTEROP
        vertices.assign(cutplane->vertices_begin(), cutplane->vertices_end());
        normals.assign(cutplane->normals_begin(), cutplane->normals_end());
        colors.assign(thrust::make_transform_iterator(cutplane->scalars_begin(), color_map<float>(0.0f, 1.0f)),
                      thrust::make_transform_iterator(cutplane->scalars_end(), color_map<float>(0.0f, 1.0f)));
    #endif
#endif

#ifdef THRESHOLD
    #ifdef USE_INTEROP
        threshold->vboResources[0] = quads_pos_res;  threshold->vboResources[1] = quads_color_res;  threshold->vboResources[2] = quads_normal_res;
        threshold->minThresholdRange = 4.0f;  threshold->maxThresholdRange = 1600.0f;  threshold->useInterop = true;
        threshold->vboSize = buffer_size;
    #endif
    (*threshold)();
    #ifndef USE_INTEROP
        vertices.resize(threshold->vertices_end() - threshold->vertices_begin());
        normals.resize(threshold->normals_end() - threshold->normals_begin());
        thrust::device_vector<float4> device_colors(vertices.size());
//        thrust::copy(thrust::make_transform_iterator(threshold->vertices_begin(), tuple2float4()),
//                     thrust::make_transform_iterator(threshold->vertices_end(), tuple2float4()), vertices.begin());
        thrust::copy(threshold->vertices_begin(),
                     threshold->vertices_end(),
                     vertices.begin());
        thrust::copy(threshold->normals_begin(), threshold->normals_end(), normals.begin());
        thrust::transform(threshold->scalars_begin(), threshold->scalars_end(), device_colors.begin(), color_map<float>(4.0f, 1600.0f));
        colors = device_colors;
    #endif
    drawType = GL_QUADS;
#endif

#ifdef USE_INTEROP
    glBindBuffer(GL_ARRAY_BUFFER, quads_vbo[0]);
    glVertexPointer(4, GL_FLOAT, 0, 0);

    glBindBuffer(GL_ARRAY_BUFFER, quads_vbo[1]);
    glNormalPointer(GL_FLOAT, 0, 0);

    glBindBuffer(GL_ARRAY_BUFFER, quads_vbo[2]);
    glColorPointer(4, GL_FLOAT, 0, 0);

    glDrawArrays(drawType, 0, buffer_size/sizeof(float4));
#else
    glColorPointer(4, GL_FLOAT, 0, &colors[0]);
    glNormalPointer(GL_FLOAT, 0, &normals[0]);
    glVertexPointer(4, GL_FLOAT, 0, &vertices[0]);
    glDrawArrays(drawType, 0, vertices.size());
#endif

    glPopMatrix();

    gettimeofday(&end, 0);
    timersub(&end, &begin, &diff);
    frame_count++;
    float seconds = diff.tv_sec + 1.0E-6*diff.tv_usec;
    if (seconds > 0.5f)
    {
      char title[256];
      sprintf(title, "Marching Cube, fps: %2.2f", float(frame_count)/seconds);
      std::cout << title << std::endl;
      seconds = 0.0f;
      frame_count = 0;
    }

    timer->start(1);
}
Ejemplo n.º 4
0
 static void resize( thrust::host_vector< T > &x , const thrust::host_vector< T > &y )
 {
     x.resize( y.size() );
 }