Example #1
0
vtkDataSet *
avtLowerResolutionVolumeFilter::ExecuteData(vtkDataSet *ds, int, std::string)
{
    StackTimer t("avtLowerResolutionVolumeFilter::ExecuteData");

    vtkDataSet *rv = ds;
    // If we're not doing linear scaling then we have to create a copy dataset
    // whose scalars are transformed by the appropriate scaling rule.
    if(atts.GetScaling() != VolumeAttributes::Linear)
    {
        // Get the array that we're "scaling".
        vtkDataArray *src = VolumeGetScalar(ds, NULL);
        if(src == 0)
        {
            EXCEPTION0(ImproperUseException);
        }

        // Create a dataset copy and a new data array that we can store
        // the transformed values in.
        rv = ds->NewInstance();
        rv->ShallowCopy(ds);
        vtkDataArray *dest = src->NewInstance();
        dest->SetNumberOfTuples(src->GetNumberOfTuples());
        dest->SetName(src->GetName());

        // Transform the data.
        if (atts.GetScaling() == VolumeAttributes::Log)
        {
            TRY
            {
                VolumeLogTransform(atts, src, dest);
            }
            CATCH(VisItException)
            {
                dest->Delete();
                rv->Delete();
                RETHROW;
            }
            ENDTRY
        }
Example #2
0
void
avtVolumeRenderer::Initialize(vtkDataSet *ds)
{
    StackTimer t("avtVolumeRenderer::Initialize");

    vtkDataArray *data = 0, *opac = 0;
    if(!VolumeGetScalars(atts, ds, data, opac))
        return;

    VolumeGetVariableExtents(atts, data,
        this->varmin, this->varmax, 
        this->vmin, this->vmax, this->vsize);

    // Get the opacity variable's extents.
    VolumeGetOpacityExtents(atts, opac,
        this->omin, this->omax, this->osize);

    // calculate gradient
    if (ds->GetDataObjectType() == VTK_RECTILINEAR_GRID)
    {
        if (atts.GetLightingFlag() && gm == NULL) // make sure the gradient was invalidated first
        { 
            vtkRectilinearGrid *grid = (vtkRectilinearGrid*)ds;
            int dims[3];
            grid->GetDimensions(dims);

            int nels = dims[0] * dims[1] * dims[2];
            gx  = new float[nels];
            gy  = new float[nels];
            gz  = new float[nels];
            gm  = new float[nels];
            gmn = new float[nels];
            hs = NULL;
            float ghostval = omax+osize;
            gm_max = VolumeCalculateGradient(atts, grid, opac, gx, gy, gz, gm, gmn, ghostval);
        }
    }
    else
    {
        // If we have a lighting+no gradient then calculate the gradient.
        // Also do it if we have a default compact variable name since setting
        // the hs variable happens in that case and its generation is tied to
        // gradient calculation.
        if(gm == NULL)
        {
            int nels = ds->GetNumberOfPoints();
            gx  = new float[nels];
            gy  = new float[nels];
            gz  = new float[nels];
            gm  = new float[nels];
            gmn = new float[nels];
            hs = new float[nels];
            float ghostval = omax+osize;

            bool calcHS = atts.GetCompactVariable() == "default";
            if(!calcHS)
            {
                vtkDataArray *compactSupport = 
                    VolumeGetScalar(ds, atts.GetCompactVariable().c_str());
                if (compactSupport != NULL)
                {   //assign h values
                    for (int i = 0; i<nels; i++)    
                        hs[i] = fabs(compactSupport->GetTuple1(i));
                }
                else
                    calcHS = true;
            }

            gm_max = VolumeCalculateGradient_SPH(ds, opac, 
                gx, gy, gz, gm, gmn, hs, calcHS, ghostval);
            
            //Set the extents for the compact support variables;
            hs_size = nels;
            hs_min = hs[0]; hs_max = hs[0];
            for (int i = 0; i < nels; i++)
            {
                if ( hs[i] < hs_min )
                    hs_min = hs[i];
                if ( hs[i] > hs_max )
                    hs_max = hs[i];
            }
        }
    }

    data->Delete();
    opac->Delete();
    initialized = true;
}