Ejemplo n.º 1
0
          void add(Func ai_funcion)
          {

            size_t index (GetTag<Visitable,Base>()); // Use the class tag as index.
            //std::cout << "add index " << index <<" " << typeid(Visitable).name()<<" "<< std::endl;

            if ( index >= m_vtable.size() )
            {// el indice esta fuera de la tabla ...

              // Buscamos la funcion relacionada con la clase base.
              const size_t base_tag (GetTag<Base,Base>());

              //Obtenemos el puntero de la funcion relacionada con la clase base si existe o 0 si no,
              Func base_function( ( base_tag >= m_vtable.size() )? 0 : m_vtable[base_tag]);

              // Ahora expandimos la tabla utilizando el puntero a la funcion de la clase base como elemento
              // por defecto.
              m_vtable.resize( index + 1, base_function);
            }

            // ahora que lo tenemos todo listo
            // asignamos la funcion al indice adecuado.
            m_vtable[index] = ai_funcion;
          }
Ejemplo n.º 2
0
    virtual void run(Voxel& voxel, VoxelData& data)
    {
        if(voxel.b0_index == 0 && voxel.half_sphere)
            data.space[0] *= 0.5;
        // add rotation from QSDR or gradient nonlinearity
        if(voxel.qsdr || !voxel.grad_dev.empty())
        {
            if(!voxel.qsdr) // grad_dev already multiplied in interpolate_dwi routine
            {
                // correction for gradient nonlinearity
                // new_bvecs = (I+grad_dev) * bvecs;
                for(unsigned int i = 0; i < 9; ++i)
                    data.jacobian[i] = voxel.grad_dev[i][data.voxel_index];
                tipl::mat::transpose(data.jacobian.begin(),tipl::dim<3,3>());
            }
            std::vector<float> sinc_ql_(data.odf.size()*data.space.size());
            for (unsigned int j = 0,index = 0; j < data.odf.size(); ++j)
            {
                tipl::vector<3,float> from(voxel.ti.vertices[j]);
                from.rotate(data.jacobian);
                from.normalize();
                if(voxel.r2_weighted)
                    for (unsigned int i = 0; i < data.space.size(); ++i,++index)
                        sinc_ql_[index] = base_function(q_vectors_time[i]*from);
                else
                    for (unsigned int i = 0; i < data.space.size(); ++i,++index)
                        sinc_ql_[index] = boost::math::sinc_pi(q_vectors_time[i]*from);

            }
            tipl::mat::vector_product(&*sinc_ql_.begin(),&*data.space.begin(),&*data.odf.begin(),
                                          tipl::dyndim(data.odf.size(),data.space.size()));
        }
        else
            tipl::mat::vector_product(&*sinc_ql.begin(),&*data.space.begin(),&*data.odf.begin(),
                                    tipl::dyndim(data.odf.size(),data.space.size()));
    }