Exemple #1
0
	PooledTextureRef SSR::BuildHZB(const Ptr<Texture> & depthTex)
	{
		auto texDesc = depthTex->GetDesc();
		texDesc.format = RENDER_FORMAT_R16_FLOAT;
		texDesc.bindFlag = TEXTURE_BIND_SHADER_RESOURCE | TEXTURE_BIND_RENDER_TARGET;
		texDesc.mipLevels = 0;

		auto hzb0Ref = TexturePool::Instance().FindFree({ TEXTURE_2D, texDesc });
		auto hzb1Ref = TexturePool::Instance().FindFree({ TEXTURE_2D, texDesc });

		auto hzb0 = hzb0Ref->Get()->Cast<Texture>();
		auto hzb1 = hzb1Ref->Get()->Cast<Texture>();

		Transform(
			depthTex->GetShaderResourceView(0, 1, 0, 1, false, RENDER_FORMAT_R24_UNORM_X8_TYPELESS), 
			hzb0Ref->Get()->Cast<Texture>()->GetRenderTargetView(0, 0, 1));

		auto rc = Global::GetRenderEngine()->GetRenderContext();

		auto ps = Shader::FindOrCreate<HZBBuildPS>();

		for (int32_t mipLevel = 1; mipLevel < hzb0->GetDesc().mipLevels; ++mipLevel)
		{
			auto & mipSize = hzb0->GetMipSize(mipLevel - 1);
			auto w = mipSize.x();
			auto h = mipSize.y();
			float4 screenSize = float4((float)w, (float)h, 1.0f / (float)w, 1.0f / (float)h);

			ps->SetScalar("screenSize", screenSize);
			ps->SetScalar("mipLevel", (float)(mipLevel - 1));
			ps->SetSRV("depthTex", hzb0->GetShaderResourceView());
			ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get());

			ps->Flush();

			auto & targetMipSize = hzb0->GetMipSize(mipLevel);

			DrawQuad({ hzb1->GetRenderTargetView(mipLevel, 0, 1) });

			hzb1->CopyTo(hzb0, mipLevel, 0, 0, 0, 0, mipLevel, 0);
		}

		return hzb0Ref;
	}
avtDataObject_p
avtOriginalDataSpatialExtentsQuery::ApplyFilters(avtDataObject_p inData)
{
    avtDataRequest_p dataRequest = inData->GetOriginatingSource()->
        GetGeneralContract()->GetDataRequest();

    std::string dbVar = ParsingExprList::GetRealVariable(
                       queryAtts.GetVariables()[0]);
    avtDataRequest_p new_dataRequest = new avtDataRequest(dataRequest,
                                                                dbVar.c_str());

    avtContract_p contract = 
        new avtContract(new_dataRequest, queryAtts.GetPipeIndex()); 

    avtDataObject_p retObj;
    CopyTo(retObj, inData);
    retObj->Update(contract);
    return retObj;
}
// May Trigger GC, but parameter value will be protected
HRESULT CLR_RT_HeapBlock_Queue::Enqueue( CLR_RT_HeapBlock* value )
{
    NATIVE_PROFILE_CLR_CORE();
    TINYCLR_HEADER();

    CLR_RT_HeapBlock_Array* array    = GetArray();
    CLR_INT32               size     = GetSize();
    CLR_INT32               tail     = GetTail();
    CLR_INT32               capacity = array->m_numOfElements;

    if(size == capacity)
    {
        // Set new capacity
        CLR_RT_HeapBlock newArrayHB;
        
        // Protect value from GC, in case CreateInstance triggers one
        CLR_RT_HeapBlock valueHB; valueHB.SetObjectReference( value );
        CLR_RT_ProtectFromGC gc( valueHB );

        capacity *= 2;

        TINYCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( newArrayHB, capacity, g_CLR_RT_WellKnownTypes.m_Object ));

        array = newArrayHB.DereferenceArray();

        CopyTo( array, 0 );

        tail = size;

        SetArray( array );
        SetHead ( 0     );
        SetTail ( tail  );
    }

    ((CLR_RT_HeapBlock*)array->GetElement( tail ))->SetObjectReference( value );

    SetTail( (tail + 1) % capacity );

    SetSize( size + 1 );

    TINYCLR_NOCLEANUP();
}
Exemple #4
0
bool FileEntry::Extract(const StringRef& outDir) const
{
	auto path = Path::Combine(outDir, mPath);
	Directory::CreateDirectoryForFile(path);
	FileStream dest(path, FileOpenMode::DestoryWriteOrCreate, FileDataType::Binary);
	if (!dest.IsOpen())
	{
		Log::FormatError("Cannot create {}", path);
		return false;
	}

	auto readStream = Read(FileDataType::Binary);
	auto writeSize = readStream->CopyTo(dest);
	auto extractSize = ExtractedSize();
	if (writeSize!= extractSize)
	{
		Log::FormatError("Cannot Extract {}", path);
		return false;
	}
	return true;
}
// ****************************************************************************
//  Method: avtConnComponentsVolumeQuery::ApplyFilters
//
//  Purpose:
//      Applies the filters to the input.
//
//  Programmer: Cyrus Harrison
//  Creation:   February 2, 2007
//
// ****************************************************************************
avtDataObject_p
avtConnComponentsVolumeQuery::ApplyFilters(avtDataObject_p inData)
{
    // Create an artificial pipeline.
    avtDataset_p ds;
    CopyTo(ds, inData);
    avtSourceFromAVTDataset termsrc(ds);
    avtDataObject_p dob = termsrc.GetOutput();


    // add either areaFilter, or volumeFilter based on input dimension
    int topo = GetInput()->GetInfo().GetAttributes().GetTopologicalDimension();
    if (topo == 2)
    {
        if (GetInput()->GetInfo().GetAttributes().GetMeshCoordType() != AVT_XY)
        {
            debug5 << "ConnComponentsVolume query using RevolvedVolume" 
                   << endl;
            revolvedVolumeFilter->SetInput(dob);
            dob = revolvedVolumeFilter->GetOutput();
        }
    }
    else
    {
        debug5 << "ConnComponentsVolume query using Volume" << endl;
        volumeFilter->SetInput(dob);
        dob = volumeFilter->GetOutput();
    }

    cclFilter->SetInput(dob);
    dob = cclFilter->GetOutput();

    avtContract_p contract = 
        inData->GetOriginatingSource()->GetGeneralContract();

    cclFilter->GetOutput()->Update(contract);

    return cclFilter->GetOutput();
}
Exemple #6
0
    IFACEMETHODIMP CanvasSwapChainFactory::CreateForCoreWindowWithDpi(
        ICanvasResourceCreator* resourceCreator,
        ICoreWindow* coreWindow,
        float dpi,
        ICanvasSwapChain** swapChain)
    {
        return ExceptionBoundary(
            [&]
            {
                CheckInPointer(resourceCreator);
                CheckAndClearOutPointer(swapChain);

                ComPtr<ICanvasDevice> device;
                ThrowIfFailed(resourceCreator->get_Device(&device));

                auto newCanvasSwapChain = CanvasSwapChain::CreateNew(
                    device.Get(),
                    coreWindow,
                    dpi);

                ThrowIfFailed(newCanvasSwapChain.CopyTo(swapChain));
            });
    }
avtCurvePlot::avtCurvePlot()
{
    curveLegend = new avtCurveLegend;
    curveLegend->SetTitle("Curve");

    CurveFilter = new avtCurveFilter();
    WarpFilter = new avtWarpFilter();
    PolarFilter = new avtPolarToCartesianFilter();
    renderer = new avtOpenGLCurveRenderer;
    avtCustomRenderer_p ren;
    CopyTo(ren, renderer);
    mapper = new avtUserDefinedMapper(ren);
 
    decoMapper = new avtLabeledCurveMapper();

    //
    // This is to allow the legend to reference counted so the behavior can
    // still access it after the plot is deleted.  The legend cannot be
    // reference counted all of the time since we need to know that it is a 
    // CurveLegend.
    //
    curveLegendRefPtr = curveLegend;
}
Exemple #8
0
avtLabelPlot::avtLabelPlot() : avtSurfaceDataPlot()
{
    labelFilter = NULL;
    ghostAndFaceFilter = NULL;
    condenseFilter = NULL;
    normalFilter = NULL;
    labelSubsetsFilter = NULL;

    renderer = new avtOpenGLLabelRenderer;

    varLegend = new avtVariableLegend;
    varLegend->SetTitle("Label");
    vtkLookupTable *lut = vtkLookupTable::New();
    varLegend->SetLookupTable(lut);
    lut->Delete();
    varLegend->SetColorBarVisibility(0);
    varLegend->SetVarRangeVisibility(0);
    varLegendRefPtr = varLegend;

    avtCustomRenderer_p cr;
    CopyTo(cr, renderer);
    labelMapper = new avtLabelsMapper(cr);
}
avtDataObject_p
avtEvalPointExpression::TransformData(avtDataObject_p input)
{
    //
    // Gameplan:  For each point (X,Y,Z), the vector to a point (X0, Y0, Z0)
    // is (X0-X, Y0-Y, Z0-Z).  So we want to move 2*(X0-X, Y0-Y, Z0-Z).
    // Then the final point is (2X0-X, 2Y0-Y, 2Z0-Z).  So set up a transform
    // that does this.
    //
    double X = inputParameters[0];
    double Y = inputParameters[1];
    double Z = inputParameters[2];

    vtkMatrix4x4 *mat = vtkMatrix4x4::New();
    mat->SetElement(0, 0, -1);
    mat->SetElement(1, 1, -1);
    mat->SetElement(2, 2, -1);
    mat->SetElement(0, 3, +2.*X);
    mat->SetElement(1, 3, +2.*Y);
    mat->SetElement(2, 3, +2.*Z);

    avtDataset_p ds;
    CopyTo(ds, input);
    avtSourceFromAVTDataset termsrc(ds);

    avtCustomTransform transform;
    transform.SetMatrix(mat);
    transform.SetInput(termsrc.GetOutput());

    avtDataObject_p output = transform.GetOutput();
    output->Update(GetGeneralContract());

    mat->Delete();

    return output;
}
// ****************************************************************************
//  Method: avtConnComponentsLengthQuery::ApplyFilters
//
//  Purpose:
//      Constructs an artificial pipeline with the connected components and
//      area filters necessary to obtain per component area.
//
//  Programmer: Cyrus Harrison
//  Creation:   Wed Jun 15 13:09:43 PDT 2011
//
// ****************************************************************************
avtDataObject_p
avtConnComponentsLengthQuery::ApplyFilters(avtDataObject_p inData)
{
    // Create an artificial pipeline.
    avtDataset_p ds;
    CopyTo(ds, inData);
    avtSourceFromAVTDataset termsrc(ds);
    avtDataObject_p dob = termsrc.GetOutput();

    // add the area filter to the pipeline
    lengthFilter->SetInput(dob);
    dob = lengthFilter->GetOutput();

    // add the ccl filter to the pipeline
    cclFilter->SetInput(dob);
    dob = cclFilter->GetOutput();

    avtContract_p contract = 
        inData->GetOriginatingSource()->GetGeneralContract();

    cclFilter->GetOutput()->Update(contract);

    return cclFilter->GetOutput();
}
Exemple #11
0
    IFACEMETHODIMP CanvasCommandList::CreateDrawingSession(
        ICanvasDrawingSession** drawingSession)
    {
        return ExceptionBoundary(
            [&]
            {
                CheckAndClearOutPointer(drawingSession);

                if (m_d2dCommandListIsClosed)
                    ThrowHR(E_INVALIDARG, Strings::CommandListCannotBeDrawnToAfterItHasBeenUsed);

                auto& d2dCommandList = GetResource();
                auto& device = m_device.EnsureNotClosed();

                auto deviceContext = As<ICanvasDeviceInternal>(device)->CreateDeviceContextForDrawingSession();
                deviceContext->SetTarget(d2dCommandList.Get());

                auto adapter = std::make_shared<SimpleCanvasDrawingSessionAdapter>(deviceContext.Get());

                auto ds = CanvasDrawingSession::CreateNew(deviceContext.Get(), adapter, device.Get());

                ThrowIfFailed(ds.CopyTo(drawingSession));
            });
    }
Exemple #12
0
THomonymPtr CHomonym::Clone() const
{
    THomonymPtr pRes = new CHomonym(Lang);
    CopyTo(pRes.Get());
    return pRes;
}
void
avtGhostZoneAndFacelistFilter::Execute(void)
{
    int  timingIndex = visitTimer->StartTimer();

    avtDataObject_p dObj = GetInput();
    avtDataValidity   &v = dObj->GetInfo().GetValidity();

    // Make sure this is the latest info.  This changes under very bizarre
    // circumstances.  ['3352].
    avtDataAttributes &a = dObj->GetInfo().GetAttributes();
    useGhostFilter = (a.GetContainsGhostZones()!=AVT_NO_GHOSTS ? true : false);

    avtDataset_p ds; 
    CopyTo(ds, dObj);
    avtSourceFromAVTDataset termsrc(ds);
    avtDataObject_p data = termsrc.GetOutput(); 

    avtContract_p contractForDB = GetGeneralContract();
    avtDataRequest_p wrongVar = contractForDB->GetDataRequest();
    avtDataRequest_p correctVar = new avtDataRequest(wrongVar, pipelineVariable);
    // By copying the "correct var", our mechanism for telling the SIL to
    // not be used is ignored.  So turn it back on.
    correctVar->GetSIL().useRestriction = false;
    correctVar->GetSIL().dataChunk = -1;

    avtContract_p goodSpec = new avtContract(contractForDB, correctVar);
    
    if (useFaceFilter && !useGhostFilter)
    {
        debug5 << "Using facelist filter only." << endl;
        faceFilter->SetInput(data);
        faceFilter->Update(goodSpec);
        GetOutput()->Copy(*(faceFilter->GetOutput()));
    }
    else if (useGhostFilter && !useFaceFilter)
    {
        debug5 << "Using ghostzone filter only." << endl;
        ghostFilter->SetInput(data);
        ghostFilter->Update(goodSpec);
        GetOutput()->Copy(*(ghostFilter->GetOutput()));
    }
    else if (!useGhostFilter && !useFaceFilter)
    {
        debug5 << "Not applying ghost zone or facelist filter." << endl;
        GetOutput()->Copy(*dObj);
    }
    else
    {
        // if we are using all the data, apply the facelist filter first.
        bool faceFirst = v.GetUsingAllDomains() ||
                         (a.GetContainsGhostZones() == AVT_CREATED_GHOSTS);

        if (faceFirst)
        {
            debug5 << "Using facelist filter before ghostzone filter." << endl;

            if (GetInput()->GetInfo().GetAttributes().
                                           GetContainsExteriorBoundaryGhosts())
            {
                debug5 << "But there are exterior boundaries, so doing a ghost"
                       << " before that!" << endl;
                exteriorBoundaryGhostFilter->SetInput(data);
                data = exteriorBoundaryGhostFilter->GetOutput();
            }

            faceFilter->SetInput(data);
            ghostFilter->SetInput(faceFilter->GetOutput());
            ghostFilter->Update(goodSpec);
            GetOutput()->Copy(*(ghostFilter->GetOutput()));
        }
        else
        {
            debug5 << "Using ghostzone filter before facelist filter." << endl;
            ghostFilter->SetInput(data);
            faceFilter->SetInput(ghostFilter->GetOutput());
            faceFilter->Update(goodSpec);
            GetOutput()->Copy(*(faceFilter->GetOutput()));
        }
    }

    visitTimer->StopTimer(timingIndex, "GhostZone And Facelist Filter");
    visitTimer->DumpTimings();
}
void
avtResampleFilter::ResampleInput(void)
{
    int  i, j, k;

    avtDataset_p output = GetTypedOutput();
    double bounds[6] = { 0, 0, 0, 0, 0, 0 };
    bool is3D = GetBounds(bounds);

    debug4 << "Resampling over space: " << bounds[0] << ", " << bounds[1]
           << ": " << bounds[2] << ", " << bounds[3] << ": " << bounds[4]
           << ", " << bounds[5] << endl;
    
    //
    // Our resampling leaves some invalid values in the data range.  The
    // easiest way to bypass this is to get the data range from the input and
    // pass it along (since resampling does not change it in theory).
    //
    double range[2];
    if (GetInput()->GetInfo().GetAttributes().ValidActiveVariable())
    {
        GetDataExtents(range);
        output->GetInfo().GetAttributes().GetDesiredDataExtents()->Set(range);
    }

    avtViewInfo view;
    double scale[3];
    CreateViewFromBounds(view, bounds, scale);

    //
    // What we want the width, height, and depth to be depends on the
    // attributes.
    //
    int width, height, depth;
    GetDimensions(width, height, depth, bounds, is3D);

    //
    // If there are no variables, then just create the mesh and exit.
    //
    bool thereAreNoVariables = 
          (GetInput()->GetInfo().GetAttributes().GetNumberOfVariables() <= 0);
    if (thereAreNoVariables)
    {
        if (PAR_Rank() == 0)
        {
            vtkRectilinearGrid *rg = CreateGrid(bounds, width, height, depth,
                                      0, width, 0, height, cellCenteredOutput, is3D);
            avtDataTree_p tree = new avtDataTree(rg, 0);
            rg->Delete();
            SetOutputDataTree(tree);
        }
        else
        {
            //
            // Putting in a NULL data tree can lead to seg faults, etc.
            //
            avtDataTree_p dummy = new avtDataTree();
            SetOutputDataTree(dummy);
        }

        return;
    }

    //
    // World space is a right-handed coordinate system.  Image space (as used
    // in the sample point extractor) is a left-handed coordinate system.
    // This is because large X is at the right and large Y is at the top.
    // The z-buffer has the closest points at z=0, so Z is going away from the
    // screen ===> left handed coordinate system.  If we reflect across X,
    // then this will account for the difference between the coordinate 
    // systems.
    //
    scale[0] *= -1.;

    //
    // We don't want an Update to go all the way up the pipeline, so make
    // a terminating source corresponding to our input.
    //
    avtDataset_p ds;
    avtDataObject_p dObj = GetInput();
    CopyTo(ds, dObj);
    avtSourceFromAVTDataset termsrc(ds);

    //
    // The sample point extractor expects everything to be in image space.
    //
    avtWorldSpaceToImageSpaceTransform trans(view, scale);
    trans.SetInput(termsrc.GetOutput());

    bool doKernel = 
        (GetInput()->GetInfo().GetAttributes().GetTopologicalDimension() == 0);
    avtSamplePointExtractor extractor(width, height, depth);
    extractor.SendCellsMode(false);
    extractor.Set3DMode(is3D);
    extractor.SetInput(trans.GetOutput());
    if (doKernel)
        extractor.SetKernelBasedSampling(true);
    avtSamplePoints_p samples = extractor.GetTypedOutput();

    //
    // If the selection this filter exists to create has already been handled,
    // or if there are no pieces for this processor to process, then we can skip
    // execution. But, take care to emulate the same collective
    // calls other processors may make before returning.
    //
    if (GetInput()->GetInfo().GetAttributes().GetSelectionApplied(selID))
    {
        debug1 << "Bypassing Resample operator because database plugin "
                  "claims to have applied the selection already" << endl;

        SetOutputDataTree(GetInputDataTree());

        // we can save a lot of time if we know everyone can bypass
        if (UnifyMaximumValue(0) == 0)
            return;

        // here is some dummied up code to match collective calls below
        int effectiveVars = samples->GetNumberOfRealVariables();
        double *ptrtmp = new double[width*height*depth];
        for (int jj = 0; jj < width*height*depth; jj++)
            ptrtmp[jj] = -FLT_MAX;
        for (i = 0 ; i < effectiveVars ; i++)
            Collect(ptrtmp, width*height*depth);
        delete [] ptrtmp;
        return;
    }
    else
    {
        UnifyMaximumValue(1);
    }

    //
    //
    // PROBLEM SIZED WORK OCCURS BEYOND THIS POINT
    // If you add (or remove) collective calls below this point, make sure to
    // put matching sequence into bypass code above
    //
    //

    avtSamplePointCommunicator communicator;
    avtImagePartition partition(width, height, PAR_Size(), PAR_Rank());
    communicator.SetImagePartition(&partition);
    bool doDistributedResample = false;
#ifdef PARALLEL
    doDistributedResample = atts.GetDistributedResample();
#endif

    if (doDistributedResample)
    {
        partition.SetShouldProduceOverlaps(true);
        avtDataObject_p dob;
        CopyTo(dob, samples);
        communicator.SetInput(dob);
        samples = communicator.GetTypedOutput();
    }

    // Always set up an arbitrator, even if user selected random.
    bool arbLessThan = !atts.GetUseArbitrator() || atts.GetArbitratorLessThan();
    std::string arbName = atts.GetArbitratorVarName();
    if (arbName == "default")
        arbName = primaryVariable;
    extractor.SetUpArbitrator(arbName, arbLessThan);

    //
    // Since this is Execute, forcing an update is okay...
    //
    samples->Update(GetGeneralContract());

    if (samples->GetInfo().GetValidity().HasErrorOccurred())
    {
        GetOutput()->GetInfo().GetValidity().ErrorOccurred();
        GetOutput()->GetInfo().GetValidity().SetErrorMessage(
                          samples->GetInfo().GetValidity().GetErrorMessage());
    }

    //
    // Create a rectilinear dataset that is stretched according to the 
    // original bounds.
    //
    int width_start  = 0;
    int width_end    = width;
    int height_start = 0;
    int height_end   = height;
    if (doDistributedResample)
    {
        partition.GetThisPartition(width_start, width_end, height_start, 
                                   height_end);
        width_end += 1;
        height_end += 1;
    }

    //
    // If we have more processors than domains, we have to handle that
    // gracefully.  Communicate how many variables there are so that those
    // that don't have data can play well.
    //
    int realVars  = samples->GetNumberOfRealVariables();
    int numArrays = realVars;
    if (doKernel)
        numArrays++;
    vtkDataArray **vars = new vtkDataArray*[numArrays];
    for (i = 0 ; i < numArrays ; i++)
    {
        vars[i] = vtkDoubleArray::New();
        if (doKernel && (i == numArrays-1))
            vars[i]->SetNumberOfComponents(1);
        else
        {
            vars[i]->SetNumberOfComponents(samples->GetVariableSize(i));
            vars[i]->SetName(samples->GetVariableName(i).c_str());
        }
    }

    if (doKernel)
        samples->GetVolume()->SetUseKernel(true);

    avtImagePartition *ip = NULL;
    if (doDistributedResample)
        ip = &partition;

    // We want all uncovered regions to get the default value.  That is
    // what the first argument of GetVariables is for.  But if the
    // default value is large, then it will screw up the collect call below,
    // which uses MPI_MAX for an all reduce.  So give uncovered regions very
    // small values now (-FLT_MAX) and then replace them later.
    double defaultPlaceholder = -FLT_MAX;
    samples->GetVolume()->GetVariables(defaultPlaceholder, vars, 
                                       numArrays, ip);

    if (!doDistributedResample)
    {
        //
        // Collect will perform the parallel collection.  Does nothing in
        // serial.  This will only be valid on processor 0.
        //
        for (i = 0 ; i < numArrays ; i++)
        {
            double *ptr = (double *) vars[i]->GetVoidPointer(0);
            Collect(ptr, vars[i]->GetNumberOfComponents()*width*height*depth);
        }
    }
    
    // Now replace the -FLT_MAX's with the default value.  (See comment above.)
    for (i = 0 ; i < numArrays ; i++)
    {
        int numTups = vars[i]->GetNumberOfComponents()
                    * vars[i]->GetNumberOfTuples();
        if (numTups > 0)
        {
            double *ptr = (double *) vars[i]->GetVoidPointer(0);
            for (j = 0 ; j < numTups ; j++)
                ptr[j] = (ptr[j] == defaultPlaceholder 
                                 ? atts.GetDefaultVal() 
                                 : ptr[j]);
        }
    }
   
    bool iHaveData = false;
    if (doDistributedResample)
        iHaveData = true;
    if (PAR_Rank() == 0)
        iHaveData = true;
    if (height_end > height)
        iHaveData = false;
    if (iHaveData)
    {
        vtkRectilinearGrid *rg = CreateGrid(bounds, width, height, depth,
                                        width_start, width_end, height_start,
                                        height_end, cellCenteredOutput, is3D);

        if (doKernel)
        {
            double min_weight = avtPointExtractor::GetMinimumWeightCutoff();
            vtkDataArray *weights = vars[numArrays-1];
            int numVals = weights->GetNumberOfTuples();
            for (i = 0 ; i < realVars ; i++)
            {
                for (j = 0 ; j < vars[i]->GetNumberOfComponents() ; j++)
                {
                    for (k = 0 ; k < numVals ; k++)
                    {
                        double weight = weights->GetTuple1(k);
                        if (weight <= min_weight)
                            vars[i]->SetComponent(k, j, atts.GetDefaultVal());
                        else
                            vars[i]->SetComponent(k, j, 
                                         vars[i]->GetComponent(k, j) / weight);
                    }
                }
            }
        }

        //
        // Attach these variables to our rectilinear grid.
        //
        for (i = 0 ; i < realVars ; i++)
        {
            const char *varname = vars[i]->GetName();
            if (strcmp(varname, primaryVariable) == 0)
            {
                if (vars[i]->GetNumberOfComponents() == 3)
                    if (cellCenteredOutput)
                        rg->GetCellData()->SetVectors(vars[i]);
                    else
                        rg->GetPointData()->SetVectors(vars[i]);
                else if (vars[i]->GetNumberOfComponents() == 1)
                {
                    if (cellCenteredOutput)
                    {
                        rg->GetCellData()->AddArray(vars[i]);
                        rg->GetCellData()->SetScalars(vars[i]);
                    }
                    else
                    {
                        rg->GetPointData()->AddArray(vars[i]);
                        rg->GetPointData()->SetScalars(vars[i]);
                    }
                }
                else
               {
                    if (cellCenteredOutput)
                        rg->GetCellData()->AddArray(vars[i]);
                    else
                        rg->GetPointData()->AddArray(vars[i]);
               }
            }
            else
            {
                if (cellCenteredOutput)
                    rg->GetCellData()->AddArray(vars[i]);
                else
                    rg->GetPointData()->AddArray(vars[i]);
            }
        }

        avtDataTree_p tree = new avtDataTree(rg, 0);
        rg->Delete();
        SetOutputDataTree(tree);
    }
    else
    {
        //
        // Putting in a NULL data tree can lead to seg faults, etc.
        //
        avtDataTree_p dummy = new avtDataTree();
        SetOutputDataTree(dummy);
    }

    for (i = 0 ; i < numArrays ; i++)
    {
        vars[i]->Delete();
    }
    delete [] vars;
}
Exemple #15
0
void
avtSurfCompPrepFilter::Execute(void)
{
    avtDataObject_p dObj = GetInput();
    avtDataset_p ds;
    CopyTo(ds, dObj);
    avtSourceFromAVTDataset termsrc(ds);
    avtDataObject_p data = termsrc.GetOutput();

    //
    // To do our sampling, we will first convert to the appropriate coordinate
    // system -- cartesian, cylindrical, or spherical.
    //
    avtCoordSystemConvert toCoordSys;
    toCoordSys.SetInputCoordSys(avtCoordSystemConvert::CARTESIAN);
    switch (atts.GetCoordSystem())
    {
      case SurfCompPrepAttributes::Cartesian:
        toCoordSys.SetOutputCoordSys(avtCoordSystemConvert::CARTESIAN);
        break;
      case SurfCompPrepAttributes::Cylindrical:
        toCoordSys.SetOutputCoordSys(avtCoordSystemConvert::CYLINDRICAL);
        break;
      case SurfCompPrepAttributes::Spherical:
        toCoordSys.SetOutputCoordSys(avtCoordSystemConvert::SPHERICAL);
        break;
    }
    toCoordSys.SetInput(data);

    //
    // The extractor only extracts sample points within the view frustum
    // {(-1., 1.), (-1., 1.), (0., 1)}.  So transform our data into that space.
    //
    avtSimilarityTransformFilter transToFrustum;
    SimilarityTransformAttributes st_atts;
    st_atts.SetDoScale(1);
    st_atts.SetDoTranslate(1);
    switch (atts.GetCoordSystem())
    {
      case SurfCompPrepAttributes::Cartesian:
      {
        double X1 = atts.GetXStart();
        double X2 = atts.GetXStop();
        double center = (X1 + X2) / 2;
        double range = X2 - X1;
        range = (range == 0. ? 1 : range); 
        double scale = 2. / range;
        st_atts.SetScaleX(scale);
        st_atts.SetTranslateX(-center*scale);
        double Y1 = atts.GetYStart();
        double Y2 = atts.GetYStop();
        center = (Y1 + Y2) / 2;
        range = Y2 - Y1;
        range = (range == 0. ? 1 : range); 
        scale = 2. / range;
        st_atts.SetTranslateY(-center*scale);
        st_atts.SetScaleY(scale);
        double Z1 = atts.GetZStart();
        double Z2 = atts.GetZStop();
        center = (Z1 + Z2) / 2;
        range = Z2 - Z1;
        range = (range == 0. ? 1 : range); 
        scale = 1. / range;
        st_atts.SetScaleZ(scale);
        st_atts.SetTranslateZ(0.5-center*scale);
        break;
      }  
      case SurfCompPrepAttributes::Cylindrical:
      {
        double X1 = atts.GetThetaStart() * DegreesToRadians();
        double X2 = atts.GetThetaStop() * DegreesToRadians();
        double center = (X1 + X2) / 2;
        double range = X2 - X1;
        range = (range == 0. ? 1 : range); 
        double scale = 2. / range;
        st_atts.SetScaleX(scale);
        st_atts.SetTranslateX(-center*scale);
        double Y1 = atts.GetZStart();
        double Y2 = atts.GetZStop();
        center = (Y1 + Y2) / 2;
        range = Y2 - Y1;
        range = (range == 0. ? 1 : range); 
        scale = 2. / range;
        st_atts.SetScaleY(scale);
        st_atts.SetTranslateY(-center*scale);
        double Z1 = atts.GetStartRadius();
        double Z2 = atts.GetEndRadius();
        center = (Z1 + Z2) / 2;
        range = Z2 - Z1;
        range = (range == 0. ? 1 : range); 
        scale = 1. / range;
        st_atts.SetScaleZ(scale);
        st_atts.SetTranslateZ(0.5-center*scale);
        break;
      }
      case SurfCompPrepAttributes::Spherical:
      {
        double X1 = atts.GetThetaStart() * DegreesToRadians();
        double X2 = atts.GetThetaStop() * DegreesToRadians();
        double center = (X1 + X2) / 2;
        double range = X2 - X1;
        range = (range == 0. ? 1 : range); 
        double scale = 2. / range;
        st_atts.SetScaleX(scale);
        st_atts.SetTranslateX(-center*scale);
        double Y1 = atts.GetPhiStart() * DegreesToRadians();
        double Y2 = atts.GetPhiStop() * DegreesToRadians();
        center = (Y1 + Y2) / 2;
        range = Y2 - Y1;
        range = (range == 0. ? 1 : range); 
        scale = 2. / range;
        st_atts.SetScaleY(scale);
        st_atts.SetTranslateY(-center*scale);
        double Z1 = atts.GetStartRadius();
        double Z2 = atts.GetEndRadius();
        center = (Z1 + Z2) / 2;
        range = Z2 - Z1;
        range = (range == 0. ? 1 : range); 
        scale = 1. / range;
        st_atts.SetScaleZ(scale);
        st_atts.SetTranslateZ(0.5-center*scale);
        break;
      }
    }
    transToFrustum.SetAtts(&st_atts);
    transToFrustum.SetInput(toCoordSys.GetOutput());

    //
    // The sample point extractor will do the actually extracting.  The number
    // of samples in each dimension depends on the attributes and what
    // coordinate system we are in.
    //
    int numX = 0;
    int numY = 0;
    int numZ = 0;
    switch (atts.GetCoordSystem())
    {
      case SurfCompPrepAttributes::Cartesian:
      {
         numX = atts.GetXSteps();
         numY = atts.GetYSteps();
         numZ = atts.GetZSteps();
         break;
      }  
      case SurfCompPrepAttributes::Cylindrical:
      {
         numX = atts.GetThetaSteps();
         numY = atts.GetZSteps();
         numZ = atts.GetRadiusSteps();
         break;
      }
      case SurfCompPrepAttributes::Spherical:
      {
         numX = atts.GetThetaSteps();
         numY = atts.GetPhiSteps();
         numZ = atts.GetRadiusSteps();
         break;
      }
    }
    avtSamplePointExtractor extractor(numX, numY, numZ);
    extractor.SetInput(transToFrustum.GetOutput());
    avtDataObject_p dob = extractor.GetOutput();

    avtImagePartition imagePartition(numX, numY);

#ifdef PARALLEL
    //
    // If we are in parallel, we will need to communicate the sample points
    // so that we can correctly infer the surface in the next step.
    //
    avtSamplePointCommunicator sampCommunicator;
    sampCommunicator.SetImagePartition(&imagePartition);
    sampCommunicator.SetInput(dob);
    dob = sampCommunicator.GetOutput();
#else
    //
    // The sample communicator will make this gets called, so we only need
    // to call this if we are not using that module.
    //
    int *dummy = new int[numY];
    for (int i = 0 ; i < numY ; i++)
        dummy[i] = 500;
    imagePartition.EstablishPartitionBoundaries(dummy);
    delete [] dummy;
#endif

    //
    // The sample point to surface filter will determine a surface from the
    // sample points.  The surface can be the front surface, the back
    // surface, and the middle surface.  The output surface will still be
    // in the image frustum.
    // 
    SurfaceType st = NOT_SPECIFIED;
    switch (atts.GetSurfaceType())
    {
      case SurfCompPrepAttributes::Closest:
        st = FRONT_SURFACE;
        break;
      case SurfCompPrepAttributes::Average:
        st = MIDDLE_SURFACE;
        break;
      case SurfCompPrepAttributes::Farthest:
        st = BACK_SURFACE;
        break;
    }
    avtSamplePointToSurfaceFilter sampsToSurface;
    sampsToSurface.SetImagePartition(&imagePartition);
    sampsToSurface.SetSurfaceType(st);
    sampsToSurface.SetInput(dob);

    //
    // Now transform the data out of the image frustum and back into the
    // coordinate system space.
    //
    avtSimilarityTransformFilter outOfFrustum;
    st_atts.SetDoScale(1);
    st_atts.SetDoTranslate(1);
    switch (atts.GetCoordSystem())
    {
      case SurfCompPrepAttributes::Cartesian:
      {
        double X1 = atts.GetXStart();
        double X2 = atts.GetXStop();
        double center = (X1 + X2) / 2;
        double range = X2 - X1;
        range = (range == 0. ? 1 : range); 
        double scale = range / 2.;
        st_atts.SetTranslateX(center);
        st_atts.SetScaleX(scale);
        double Y1 = atts.GetYStart();
        double Y2 = atts.GetYStop();
        center = (Y1 + Y2) / 2;
        range = Y2 - Y1;
        range = (range == 0. ? 1 : range); 
        scale = range / 2.;
        st_atts.SetScaleY(scale);
        st_atts.SetTranslateY(center);
        double Z1 = atts.GetZStart();
        double Z2 = atts.GetZStop();
        center = (Z1 + Z2) / 2;
        range = Z2 - Z1;
        range = (range == 0. ? 1 : range); 
        scale = range;
        st_atts.SetScaleZ(scale);
        st_atts.SetTranslateZ(center - 0.5*scale);
        break;
      }  
      case SurfCompPrepAttributes::Cylindrical:
      {
        double X1 = atts.GetThetaStart() * DegreesToRadians();
        double X2 = atts.GetThetaStop() * DegreesToRadians();
        double center = (X1 + X2) / 2;
        double range = X2 - X1;
        range = (range == 0. ? 1 : range); 
        double scale = range / 2.;
        st_atts.SetScaleX(scale);
        st_atts.SetTranslateX(center);
        double Y1 = atts.GetZStart();
        double Y2 = atts.GetZStop();
        center = (Y1 + Y2) / 2;
        range = Y2 - Y1;
        range = (range == 0. ? 1 : range); 
        scale = range / 2.;
        st_atts.SetScaleY(scale);
        st_atts.SetTranslateY(center);
        double Z1 = atts.GetStartRadius();
        double Z2 = atts.GetEndRadius();
        center = (Z1 + Z2) / 2;
        range = Z2 - Z1;
        range = (range == 0. ? 1 : range); 
        scale = range;
        st_atts.SetScaleZ(scale);
        st_atts.SetTranslateZ(center - 0.5*scale);
        break;
      }
      case SurfCompPrepAttributes::Spherical:
      {
        double X1 = atts.GetThetaStart() * DegreesToRadians();
        double X2 = atts.GetThetaStop() * DegreesToRadians();
        double center = (X1 + X2) / 2;
        st_atts.SetTranslateX(center);
        double range = X2 - X1;
        range = (range == 0. ? 1 : range); 
        double scale = range / 2.;
        st_atts.SetScaleX(scale);
        double Y1 = atts.GetPhiStart() * DegreesToRadians();
        double Y2 = atts.GetPhiStop() * DegreesToRadians();
        center = (Y1 + Y2) / 2;
        st_atts.SetTranslateY(center);
        range = Y2 - Y1;
        range = (range == 0. ? 1 : range); 
        scale = range / 2.;
        st_atts.SetScaleY(scale);
        double Z1 = atts.GetStartRadius();
        double Z2 = atts.GetEndRadius();
        center = (Z1 + Z2) / 2;
        range = Z2 - Z1;
        range = (range == 0. ? 1 : range); 
        scale = range;
        st_atts.SetScaleZ(scale);
        st_atts.SetTranslateZ(center - 0.5*scale);
        break;
      }
    }
    outOfFrustum.SetAtts(&st_atts);
    outOfFrustum.SetInput(sampsToSurface.GetOutput());

    //
    // We are now back in the coordinate system.  Let's get back to Cartesian
    // coordinates.
    //
    avtCoordSystemConvert backToCartesian;
    switch (atts.GetCoordSystem())
    {
      case SurfCompPrepAttributes::Cartesian:
        backToCartesian.SetInputCoordSys(avtCoordSystemConvert::CARTESIAN);
        break;
      case SurfCompPrepAttributes::Cylindrical:
        backToCartesian.SetInputCoordSys(avtCoordSystemConvert::CYLINDRICAL);
        break;
      case SurfCompPrepAttributes::Spherical:
        backToCartesian.SetInputCoordSys(avtCoordSystemConvert::SPHERICAL);
        break;
    }
    backToCartesian.SetOutputCoordSys(avtCoordSystemConvert::CARTESIAN);
    backToCartesian.SetInput(outOfFrustum.GetOutput());

    //
    // The last few hundred lines of code have set up a network.  Now force
    // that network to execute.
    //
    backToCartesian.Update(GetGeneralContract());

    //
    // Now copy the output of that execution to be the output of this filter.
    //
    GetOutput()->Copy(*(backToCartesian.GetOutput()));
}
Exemple #16
0
		void String::CopyTo(Vector<char>& vector, int startIndex) const
		{
			CopyTo(0, vector, startIndex, vector.Length);
		}
Exemple #17
0
int main (int argc, char **argv)
{	
	

	char pname[MAXPATHNAMELEN];
	char *temp_buff;
	int pid;

	struct my_msg msg;
	struct read_struct msg_read;
	struct read_struct msg_write;
	struct stat_struct msg_stat;
	struct old_new msg_link;
	struct Stat res_stat;
	struct readlink msg_readlink;
	struct seek_struct msg_seek;

	printf("\nYFS: Started File Server");
	Initialize_Server();

	if (Fork() == 0) {
	printf("\nCHILD\n");
	pid=Exec(argv[1],argv);
	printf("\nval returned by exec is %d",pid);
	return 0;
    	}
    	else
	 printf("\nPARENT\n");

	while(1)
	{
		pid=Receive(&msg);
		//printf("\nInside while");
		switch(msg.type)
		{	case CREATE:		//for create,type=1,data2=inode of current dir,ptr=ptr to path
			{	printf("\nInside Server Create");

				CopyFrom(pid,(void *)pname,msg.ptr,MAXPATHNAMELEN);
				msg.data2=Server_Create(pname,msg.data2);
				printf("\nInside Server Returning %d",msg.data2);
				if(msg.data2!=ERROR)
					msg.type=0;
				else
					msg.type=ERROR;
				printf("\nInside Server Returning %d",msg.type);

				Reply(&msg,pid);
				break;
			}
			case OPEN:		//for Open,type=1,data2=inode of current dir,ptr=ptr to path
			{
				CopyFrom(pid,(void *)pname,msg.ptr,MAXPATHNAMELEN);
				msg.data2=Server_Open(pname,msg.data2);
				printf("\nVal returned by open is %d\n",msg.data2);
				if(msg.data2!=ERROR)
					msg.type=0;
				else
					msg.type=ERROR;

				printf("\nInside Server Returning %d\n",msg.type);
				Reply(&msg,pid);
				break;
			}
			case MKDIR:		//for MkDir,type=1,data2=inode of current dir,ptr=ptr to path
			{
				CopyFrom(pid,(void *)pname,msg.ptr,MAXPATHNAMELEN);
				msg.data2=Server_MkDir(pname,msg.data2);
				printf("\nInside Server MkDir with name as %s and curr inode %d\n",pname,msg.data2);
				if(msg.data2!=ERROR)
					msg.type=0;
				else
					msg.type=ERROR;

				Reply(&msg,pid);
				break;
			}
			case CHDIR:		//for ChDir,type=1,data2=inode of current dir,ptr=ptr to new dir
			{
				CopyFrom(pid,(void *)pname,msg.ptr,MAXPATHNAMELEN);
				printf("\nInside Server ChDir with name as %s and curr inode %d\n",pname,msg.data2);
				msg.data2=Server_ChDir(pname,msg.data2);
				if(msg.data2!=ERROR)
					msg.type=0;
				else
					msg.type=ERROR;
				Reply(&msg,pid);
				break;
			}
			case RMDIR:		//for ChDir,type=1,data2=inode of current dir,ptr=ptr to dir
			{
				CopyFrom(pid,(void *)pname,msg.ptr,MAXPATHNAMELEN);
				msg.type=Server_RmDir(pname,msg.data2);
				Reply((void *)&msg,pid);
				break;
			}
			case READ:
			{	
				CopyFrom(pid,(void *)&msg_read,msg.ptr,sizeof(struct read_struct));
				temp_buff=(char *)malloc(msg_read.len+1);
				msg.type=Server_Read(msg.data2,msg_read.len,msg_read.offset,temp_buff);
				CopyTo(pid,msg_read.buff,temp_buff,msg_read.len);
				printf("\nInside Server ReturningRead %d",msg.type);
				printf("\n");
				Reply((void *)&msg,pid);
				//free(temp_buff);
				break;
			}
			case WRITE:
			{	printf("\nInside write in while");
				CopyFrom(pid,(void *)&msg_write,msg.ptr,sizeof(struct read_struct));
				temp_buff=(char *)malloc(msg_write.len+1);
				temp_buff[msg_write.len]='\0';
				CopyFrom(pid,temp_buff,msg_write.buff,msg_write.len);
				printf("\nData for writing is %s and len =%d",temp_buff,msg_write.len);
				msg.type=Server_Write(msg.data2,msg_write.len,msg_write.offset,temp_buff);
				//
				//free(temp_buff);
				Reply((void *)&msg,pid);
				
				break;
			}
			case STAT:
			{
			
				CopyFrom(pid,(void *)&msg_stat,msg.ptr,sizeof(struct stat_struct));
				msg.type=Server_Stat(msg.data2,msg_stat.pathname,&res_stat);
				if(msg.type!=ERROR)
					CopyTo(pid,(void *)msg_stat.statbuf,(void *)&res_stat,sizeof(struct Stat));
				Reply(&msg,pid);
				break;
			}
			
			case LINK:
			{
				CopyFrom(pid,(void *)&msg_link,msg.ptr,sizeof(struct old_new));
				msg.data2=Server_Link(msg.data2,msg_link.oldname,msg_link.newname);
				if(msg.data2==ERROR)
					msg.type=ERROR;
				else
					msg.type=0;
				Reply(&msg,pid);
				break;
			}
			case UNLINK:
			{
				temp_buff=(char *)malloc(MAXPATHNAMELEN*sizeof(char));
				CopyFrom(pid,(void *)temp_buff,msg.ptr,MAXPATHNAMELEN);
				msg.type=Server_UnLink(msg.data2,temp_buff);
				Reply(&msg,pid);
				free(temp_buff);
				break;
			}
			case READLINK:
			{
				CopyFrom(pid,(void *)&msg_readlink,msg.ptr,sizeof(struct readlink));
				temp_buff=(char *)malloc(msg_readlink.len+1);
				msg.type=Server_ReadLink(msg.data2,msg_readlink.pathname,msg_readlink.len,temp_buff);
				CopyTo(pid,msg_readlink.buf,temp_buff,msg_readlink.len);
				Reply(&msg,pid);
				break;
			}
			case SYMLINK:
			{
				CopyFrom(pid,(void *)&msg_link,msg.ptr,sizeof(struct old_new));
				msg.data2=Server_SymLink(msg.data2,msg_link.oldname,msg_link.newname);
				if(msg.data2==ERROR)
					msg.type=ERROR;
				else
					msg.type=0;
				Reply(&msg,pid);
				break;
			}
			case SEEK:
			{
				CopyFrom(pid,(void *)&msg_seek,msg.ptr,sizeof(struct stat_struct));
				msg.type=Server_Seek(msg.data2,msg_seek.curr_offset,msg_seek.new_offset,msg_seek.whence);
				Reply(&msg,pid);
				break;
			}
			case SHUTDOWN:
			{	//Server_Sync();
				TtyPrintf(0,"\nShutting Down Yalnix File Server!");
				msg.type=0;
				Reply((void *)&msg,pid);
				Exit(0);
				break;
			}
			case SYNC:
			{
			Reply((void *)&msg,pid);
			//Server_sync();
			
			break;
			}
			default:
			{
				msg.type=ERROR;
				Reply(&msg,pid);
				break;
			}

		}
	Reply(&msg,pid);
	}
	printf("\nExiting Yfs");
	return 0;;
	
}
Exemple #18
0
size_t ByteQueue::Walker::Peek(byte &outByte) const
{
	ArraySink sink(&outByte, 1);
	return (size_t)CopyTo(sink, 1);
}
Exemple #19
0
void
BufferCanvas::Commit(Canvas &other)
{
  assert(IsDefined());
  assert(active);
  assert(GetWidth() == other.GetWidth());
  assert(GetHeight() == other.GetHeight());

  if (frame_buffer != nullptr) {
    assert(OpenGL::translate.x == 0);
    assert(OpenGL::translate.y == 0);

    frame_buffer->Unbind();

    /* restore the old viewport */

    assert(OpenGL::translate == RasterPoint(0, 0));

#ifdef HAVE_GLES
    /* there's no glPopAttrib() on GL/ES; emulate it */
    glViewport(old_viewport[0], old_viewport[1],
               old_viewport[2], old_viewport[3]);
#else
    glPopAttrib();
#endif

#ifdef USE_GLSL
    OpenGL::projection_matrix = old_projection_matrix;
    OpenGL::UpdateShaderProjectionMatrix();
#else
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
#endif

    OpenGL::translate = old_translate;
    OpenGL::viewport_size = old_size;

#ifdef USE_GLSL
    glVertexAttrib4f(OpenGL::Attribute::TRANSLATE,
                     OpenGL::translate.x, OpenGL::translate.y, 0, 0);
#endif

#ifdef SOFTWARE_ROTATE_DISPLAY
    OpenGL::display_orientation = old_orientation;
#endif

    /* copy frame buffer to screen */
    CopyTo(other);
  } else {
    assert(offset == other.offset);

    /* copy screen to texture */
    CopyToTexture(*texture, GetRect());
  }

#ifndef NDEBUG
  active = false;
#endif
}
void __array<T>::System_Collections_Generic_ICollectionT1_CopyTo(__array<T>* dest, int32_t pos) 
{
	CopyTo(dest, pos);
}
void
WeatherTerrainRenderer::Draw(Canvas &canvas,
                             const WindowProjection &projection,
                             const Angle sunazimuth)
{
  bool do_water = false;
  unsigned height_scale;
  const int interp_levels = 5;
  const bool is_terrain = false;
  const bool do_shading = is_terrain;
  const COLORRAMP *color_ramp;

  switch (weather->GetParameter()) {
  case 1: // wstar
    height_scale = 2; // max range 256*(2**2) = 1024 cm/s = 10 m/s
    color_ramp = &weather_colors[0][0];
    break;

  case 2: // bl wind spd
    height_scale = 3;
    color_ramp = &weather_colors[1][0];
    break;

  case 3: // hbl
    height_scale = 4;
    color_ramp = &weather_colors[2][0];
    break;

  case 4: // dwcrit
    height_scale = 4;
    color_ramp = &weather_colors[2][0];
    break;

  case 5: // blcloudpct
    do_water = true;
    height_scale = 0;
    color_ramp = &weather_colors[3][0];
    break;

  case 6: // sfctemp
    height_scale = 0;
    color_ramp = &weather_colors[4][0];
    break;

  case 7: // hwcrit
    height_scale = 4;
    color_ramp = &weather_colors[2][0];
    break;

  case 8: // wblmaxmin
    height_scale = 1; // max range 256*(1**2) = 512 cm/s = 5.0 m/s
    color_ramp = &weather_colors[5][0];
    break;

  case 9: // blcwbase
    height_scale = 4;
    color_ramp = &weather_colors[2][0];
    break;

  default:
    TerrainRenderer::Draw(canvas, projection, sunazimuth);
    return;
  }

  const RasterMap *map = weather->GetMap();
  if (map == NULL) {
    TerrainRenderer::Draw(canvas, projection, sunazimuth);
    return;
  }

  if (color_ramp != last_color_ramp) {
    raster_renderer.ColorTable(color_ramp, do_water,
                               height_scale, interp_levels);
    last_color_ramp = color_ramp;
  }

  raster_renderer.ScanMap(*map, projection);

  raster_renderer.GenerateImage(is_terrain, do_shading, height_scale,
                                TerrainContrast, TerrainBrightness,
                                sunazimuth);

  CopyTo(canvas, projection.GetScreenWidth(), projection.GetScreenHeight());

  ScanSpotHeights();
}
VCNDirectionalLight* VCNDirectionalLight::Copy() const
{
  VCNDirectionalLight* nodeCopy = VCNNodeCore::GetInstance()->CreateNode<VCNDirectionalLight>();
  CopyTo( nodeCopy );
  return nodeCopy;
}
Exemple #23
0
unsigned int ByteQueue::Walker::Peek(byte &outByte) const
{
	ArraySink sink(&outByte, 1);
	return CopyTo(sink, 1);
}
avtDataObject_p
IceTNetworkManager::Render(
    bool checkThreshold, intVector networkIds,
    bool getZBuffer, int annotMode, int windowID,
    bool leftEye)
{
    int t0 = visitTimer->StartTimer();
    DataNetwork *origWorkingNet = workingNet;
    avtDataObject_p retval;

    EngineVisWinInfo &viswinInfo = viswinMap[windowID];
    viswinInfo.markedForDeletion = false;
    VisWindow *viswin = viswinInfo.viswin;
    std::vector<avtPlot_p>& imageBasedPlots = viswinInfo.imageBasedPlots;

    renderings = 0;

    TRY
    {
        this->StartTimer();

        RenderSetup(windowID, networkIds, getZBuffer,
            annotMode, leftEye, checkThreshold);

        bool plotDoingTransparencyOutsideTransparencyActor = false;
        for(size_t i = 0 ; i < networkIds.size() ; i++)
        {
            workingNet = NULL;
            UseNetwork(networkIds[i]);
            if(this->workingNet->GetPlot()->ManagesOwnTransparency())
            {
                plotDoingTransparencyOutsideTransparencyActor = true;
            }
        }
        workingNet = NULL;

        // We can't easily figure out a compositing order, which IceT requires
        // in order to properly composite transparent geometry.  Thus if there
        // is some transparency, fallback to our parent implementation.
        avtTransparencyActor* trans = viswin->GetTransparencyActor();
        bool transparenciesExist = trans->TransparenciesExist()
                           ||  plotDoingTransparencyOutsideTransparencyActor;
        if (transparenciesExist)
        {
            debug2 << "Encountered transparency: falling back to old "
                      "SR / compositing routines." << std::endl;

            retval = NetworkManager::RenderInternal();
        }
        else
        {
            bool needZB = !imageBasedPlots.empty() ||
                          renderState.shadowMap  ||
                          renderState.depthCues;

            // Confusingly, we need to set the input to be *opposite* of what VisIt
            // wants.  This is due to (IMHO) poor naming in the IceT case; on the
            // input side:
            //     ICET_DEPTH_BUFFER_BIT set:     do Z-testing
            //     ICET_DEPTH_BUFFER_BIT not set: do Z-based compositing.
            // On the output side:
            //     ICET_DEPTH_BUFFER_BIT set:     readback of Z buffer is allowed
            //     ICET_DEPTH_BUFFER_BIT not set: readback of Z does not work.
            // In VisIt's case, we calculated a `need Z buffer' predicate based
            // around the idea that we need the Z buffer to do Z-compositing.
            // However, IceT \emph{always} needs the Z buffer internally -- the
            // flag only differentiates between `compositing' methodologies
            // (painter-style or `over' operator) on input.
            GLenum inputs = ICET_COLOR_BUFFER_BIT;
            GLenum outputs = ICET_COLOR_BUFFER_BIT;
            // Scratch all that, I guess.  That might be the correct way to go
            // about things in the long run, but IceT only gives us back half an
            // image if we don't set the depth buffer bit.  The compositing is a
            // bit wrong, but there's not much else we can do..
            // Consider removing the `hack' if a workaround is found.
            if (/*hack*/true/*hack*/) // || !this->MemoMultipass(viswin))
            {
                inputs |= ICET_DEPTH_BUFFER_BIT;
            }
            if(needZB)
            {
                outputs |= ICET_DEPTH_BUFFER_BIT;
            }
            ICET(icetInputOutputBuffers(inputs, outputs));

            // If there is a backdrop image, we need to tell IceT so that it can
            // composite correctly.
            if(viswin->GetBackgroundMode() != AnnotationAttributes::Solid)
            {
                ICET(icetEnable(ICET_CORRECT_COLORED_BACKGROUND));
            }
            else
            {
                ICET(icetDisable(ICET_CORRECT_COLORED_BACKGROUND));
            }

            if (renderState.renderOnViewer)
            {
                RenderCleanup();
                avtDataObject_p dobj = NULL;
                CATCH_RETURN2(1, dobj);
            }

            debug5 << "Rendering " << viswin->GetNumPrimitives()
                   << " primitives." << endl;

            int width, height, width_start, height_start;
            // This basically gets the width and the height.
            // The distinction is for 2D rendering, where we only want the
            // width and the height of the viewport.
            viswin->GetCaptureRegion(width_start, height_start, width, height,
                                     renderState.viewportedMode);

            this->TileLayout(width, height);

            CallInitializeProgressCallback(this->RenderingStages());

            // IceT mode is different from the standard network manager; we don't
            // need to create any compositor or anything: it's all done under the
            // hood.
            // Whether or not to do multipass rendering (opaque first, translucent
            // second) is all handled in the callback; from our perspective, we
            // just say draw, read back the image, and post-process it.

            // IceT sometimes omits large parts of Curve plots when using the
            // REDUCE strategy. Use a different compositing strategy for Curve
            // plots to avoid the problem.
            if(viswin->GetWindowMode() == WINMODE_CURVE)
                ICET(icetStrategy(ICET_STRATEGY_VTREE));
            else
                ICET(icetStrategy(ICET_STRATEGY_REDUCE));

            ICET(icetDrawFunc(render));
            ICET(icetDrawFrame());

            // Now that we're done rendering, we need to post process the image.
            debug3 << "IceTNM: Starting readback." << std::endl;
            avtImage_p img = this->Readback(viswin, needZB);

            // Now its essentially back to the same behavior as our parent:
            //  shadows
            //  depth cueing
            //  post processing

            if (renderState.shadowMap)
                this->RenderShadows(img);

            if (renderState.depthCues)
                this->RenderDepthCues(img);

            // If the engine is doing more than just 3D annotations,
            // post-process the composited image.
            RenderPostProcess(img);

            CopyTo(retval, img);
        }

        RenderCleanup();
    }
    CATCHALL
    {
        RenderCleanup();
        RETHROW;
    }
    ENDTRY

    workingNet = origWorkingNet;
    visitTimer->StopTimer(t0, "Ice-T Render");
    return retval;
}
Exemple #25
0
unsigned int ByteQueue::Walker::Peek(byte *outString, unsigned int peekMax) const
{
	ArraySink sink(outString, peekMax);
	return CopyTo(sink, peekMax);
}
avtImage_p
avtVolumeFilter::RenderImageRaycastingSLIVR(avtImage_p opaque_image,
                             const WindowAttributes &window)
{
    //
    // We need to create a dummy pipeline with the volume renderer that we
    // can force to execute within our "Execute".  Start with the source.
    //
    avtSourceFromAVTDataset termsrc(GetTypedInput());

    //
    // Set up the volume renderer.
    //
    avtRayTracer *software = new avtRayTracer;
    software->SetInput(termsrc.GetOutput());
    software->InsertOpaqueImage(opaque_image);

    unsigned char vtf[4*256];
    atts.GetTransferFunction(vtf);
    avtOpacityMap om(256);

    om.SetTableFloat(vtf, 256, atts.GetOpacityAttenuation()*2.0 - 1.0, atts.GetRendererSamples());
    
    double actualRange[2];
    bool artificialMin = atts.GetUseColorVarMin();
    bool artificialMax = atts.GetUseColorVarMax();
    if (!artificialMin || !artificialMax)
    {
        GetDataExtents(actualRange, primaryVariable);
        UnifyMinMax(actualRange, 2);
    }

    double range[2];
    range[0] = (artificialMin ? atts.GetColorVarMin() : actualRange[0]);
    range[1] = (artificialMax ? atts.GetColorVarMax() : actualRange[1]);

    if (atts.GetScaling() == VolumeAttributes::Log)
    {
        if (artificialMin)
            if (range[0] > 0)
                range[0] = log10(range[0]);
        if (artificialMax)
            if (range[1] > 0)
                range[1] = log10(range[1]);
    }
    else if (atts.GetScaling() == VolumeAttributes::Skew)
    {
        if (artificialMin)
        {
            double newMin = vtkSkewValue(range[0], range[0], range[1],
                                         atts.GetSkewFactor());
            range[0] = newMin;
        }
        if (artificialMax)
        {
            double newMax = vtkSkewValue(range[1], range[0], range[1],
                                         atts.GetSkewFactor());
            range[1] = newMax;
        }
    }
    om.SetMin(range[0]);
    om.SetMax(range[1]);
    
   

    //
    // Determine which variables to use and tell the ray function.
    //
    VarList vl;
    avtDataset_p input = GetTypedInput();
    avtDatasetExaminer::GetVariableList(input, vl);

    int primIndex = -1;
    int opacIndex = -1;

    int count = 0;
    char gradName[128];
    const char *gradvar = atts.GetOpacityVariable().c_str();
    if (strcmp(gradvar, "default") == 0)
        gradvar = primaryVariable;
    // This name is explicitly sent to the avtGradientExpression in
    // the avtVolumePlot.
    SNPRINTF(gradName, 128, "_%s_gradient", gradvar);

    for (int i = 0 ; i < vl.nvars ; i++)
    {
        if ((strstr(vl.varnames[i].c_str(), "vtk") != NULL) &&
            (strstr(vl.varnames[i].c_str(), "avt") != NULL))
            continue;

        if (vl.varnames[i] == primaryVariable)
        {
            primIndex = count;
        }
        if (vl.varnames[i] == atts.GetOpacityVariable())
        {
            opacIndex = count;
        }
       // if (vl.varnames[i] == gradName)
       // {
       //     gradIndex = count;
       // }
        count += vl.varsizes[i];
    }

    if (primIndex == -1)
    {
        if (vl.nvars <= 0)
        {
            debug1 << "Could not locate primary variable "
                   << primaryVariable << ", assuming that we are running "
                   << "in parallel and have more processors than domains."
                   << endl;
        }
        else
        {
            EXCEPTION1(InvalidVariableException, primaryVariable);
        }
    }
    if (opacIndex == -1)
    {
        if (atts.GetOpacityVariable() == "default")
        {
            opacIndex = primIndex;
        }
        else if (vl.nvars <= 0)
        {
            debug1 << "Could not locate opacity variable "
                   << atts.GetOpacityVariable().c_str() << ", assuming that we "
                   << "are running in parallel and have more processors "
                   << "than domains." << endl;
        }
        else
        {
            EXCEPTION1(InvalidVariableException,atts.GetOpacityVariable());
        }
    }
   

    //
    // Set up lighting
    //
    avtFlatLighting fl;
    avtLightingModel *lm = &fl;

    if (atts.GetLightingFlag())
        software->SetLighting(true);
    else
        software->SetLighting(false);



    avtCompositeRF *compositeRF = new avtCompositeRF(lm, &om, &om);
    
    double *matProp = atts.GetMaterialProperties();
    double materialPropArray[4];
    materialPropArray[0] = matProp[0];
    materialPropArray[1] = matProp[1];
    materialPropArray[2] = matProp[2];
    materialPropArray[3] = matProp[3];

    software->SetMatProperties(materialPropArray);

    software->SetRayCastingSLIVR(true);
    software->SetTrilinear(false);

    software->SetTransferFn(&om);
    software->SetRayFunction(compositeRF);            // unsure about this one. RayFunction seems important
    software->SetSamplesPerRay(atts.GetSamplesPerRay());

    const int *size = window.GetSize();
    software->SetScreen(size[0], size[1]);

    const View3DAttributes &view = window.GetView3D();
    avtViewInfo vi;
    CreateViewInfoFromViewAttributes(vi, view);

    avtDataObject_p inputData = GetInput();
    int width_,height_,depth_;
    if (GetLogicalBounds(inputData, width_,height_,depth_))      
    {
        double viewDirection[3];
        int numSlices;
        
        viewDirection[0] = (view.GetViewNormal()[0] > 0)? view.GetViewNormal()[0]: -view.GetViewNormal()[0];
        viewDirection[1] = (view.GetViewNormal()[1] > 0)? view.GetViewNormal()[1]: -view.GetViewNormal()[1];
        viewDirection[2] = (view.GetViewNormal()[2] > 0)? view.GetViewNormal()[2]: -view.GetViewNormal()[2];

        numSlices = (width_*viewDirection[0] + height_*viewDirection[1] + depth_*viewDirection[2]) * atts.GetRendererSamples();

        software->SetSamplesPerRay(numSlices);
        debug5 << "RayCastingSLIVR - slices: "<< numSlices << " : " << width_ << " ,  " << height_  << " , " << depth_ << endl;
    }

    software->SetView(vi);

    double view_dir[3];
    view_dir[0] = vi.focus[0] - vi.camera[0];
    view_dir[1] = vi.focus[1] - vi.camera[1];
    view_dir[2] = vi.focus[2] - vi.camera[2];
    double mag = sqrt(view_dir[0]*view_dir[0] + view_dir[1]*view_dir[1]
                      + view_dir[2]*view_dir[2]);
    if (mag != 0.) // only 0 if focus and camera are the same
    {
        view_dir[0] /= mag;
        view_dir[1] /= mag;
        view_dir[2] /= mag;
    }
    software->SetViewDirection(view_dir);
    software->SetViewUp(vi.viewUp);
    
    double tempLightDir[3];
    tempLightDir[0] = ((window.GetLights()).GetLight(0)).GetDirection()[0];
    tempLightDir[1] = ((window.GetLights()).GetLight(0)).GetDirection()[1];
    tempLightDir[2] = ((window.GetLights()).GetLight(0)).GetDirection()[2];
    software->SetLightDirection(tempLightDir);


    vtkCamera *camera = vtkCamera::New();
    vi.SetCameraFromView(camera);
    vtkMatrix4x4 *cameraMatrix = camera->GetViewTransformMatrix();

    double modelViewMatrix[16];
    modelViewMatrix[0] = cameraMatrix->GetElement(0,0);
    modelViewMatrix[1] = cameraMatrix->GetElement(0,1);
    modelViewMatrix[2] = cameraMatrix->GetElement(0,2);
    modelViewMatrix[3] = cameraMatrix->GetElement(0,3);

    modelViewMatrix[4] = cameraMatrix->GetElement(1,0);
    modelViewMatrix[5] = cameraMatrix->GetElement(1,1);
    modelViewMatrix[6] = cameraMatrix->GetElement(1,2);
    modelViewMatrix[7] = cameraMatrix->GetElement(1,3);

    modelViewMatrix[8]  = cameraMatrix->GetElement(2,0);
    modelViewMatrix[9]  = cameraMatrix->GetElement(2,1);
    modelViewMatrix[10] = cameraMatrix->GetElement(2,2);
    modelViewMatrix[11] = cameraMatrix->GetElement(2,3);

    modelViewMatrix[12] = cameraMatrix->GetElement(3,0);
    modelViewMatrix[13] = cameraMatrix->GetElement(3,1);
    modelViewMatrix[14] = cameraMatrix->GetElement(3,2);
    modelViewMatrix[15] = cameraMatrix->GetElement(3,3);
    software->SetModelViewMatrix(modelViewMatrix);

    //
    // Set the volume renderer's background color and mode from the
    // window attributes.
    //
    software->SetBackgroundMode(window.GetBackgroundMode());
    software->SetBackgroundColor(window.GetBackground());
    software->SetGradientBackgroundColors(window.GetGradBG1(),
                                          window.GetGradBG2());

    //
    // Do the funny business to force an update. ... and called avtDataObject
    //
    avtDataObject_p dob = software->GetOutput();
    dob->Update(GetGeneralContract());

    //
    // Free up some memory and clean up.
    //
    delete software;
    avtRay::SetArbitrator(NULL);

    delete compositeRF;

    //
    // Copy the output of the volume renderer to our output.
    //
    avtImage_p output;
    CopyTo(output, dob);
    return  output;
}
Exemple #27
0
size_t ByteQueue::Walker::Peek(byte *outString, size_t peekMax) const
{
	ArraySink sink(outString, peekMax);
	return (size_t)CopyTo(sink, peekMax);
}
avtImage_p
avtVolumeFilter::RenderImage(avtImage_p opaque_image,
                             const WindowAttributes &window)
{
  if (atts.GetRendererType() == VolumeAttributes::RayCastingSLIVR){
        return RenderImageRaycastingSLIVR(opaque_image,window);
    }
    

    //
    // We need to create a dummy pipeline with the volume renderer that we
    // can force to execute within our "Execute".  Start with the source.
    //
    avtSourceFromAVTDataset termsrc(GetTypedInput());


    //
    // Set up the volume renderer.
    //
    avtRayTracer *software = new avtRayTracer;
    software->SetInput(termsrc.GetOutput());
    software->InsertOpaqueImage(opaque_image);
    software->SetRayCastingSLIVR(false);

    unsigned char vtf[4*256];
    atts.GetTransferFunction(vtf);
    avtOpacityMap om(256);
    if ((atts.GetRendererType() == VolumeAttributes::RayCasting) && (atts.GetSampling() == VolumeAttributes::Trilinear))
        om.SetTable(vtf, 256, atts.GetOpacityAttenuation()*2.0 - 1.0, atts.GetRendererSamples());
    else
        om.SetTable(vtf, 256, atts.GetOpacityAttenuation());
    double actualRange[2];
    bool artificialMin = atts.GetUseColorVarMin();
    bool artificialMax = atts.GetUseColorVarMax();
    if (!artificialMin || !artificialMax)
    {
        GetDataExtents(actualRange, primaryVariable);
        UnifyMinMax(actualRange, 2);
    }
    double range[2];
    range[0] = (artificialMin ? atts.GetColorVarMin() : actualRange[0]);
    range[1] = (artificialMax ? atts.GetColorVarMax() : actualRange[1]);
    if (atts.GetScaling() == VolumeAttributes::Log)
    {
        if (artificialMin)
            if (range[0] > 0)
                range[0] = log10(range[0]);
        if (artificialMax)
            if (range[1] > 0)
                range[1] = log10(range[1]);
    }
    else if (atts.GetScaling() == VolumeAttributes::Skew)
    {
        if (artificialMin)
        {
            double newMin = vtkSkewValue(range[0], range[0], range[1],
                                         atts.GetSkewFactor());
            range[0] = newMin;
        }
        if (artificialMax)
        {
            double newMax = vtkSkewValue(range[1], range[0], range[1],
                                         atts.GetSkewFactor());
            range[1] = newMax;
        }
    }
    om.SetMin(range[0]);
    om.SetMax(range[1]);

    if (atts.GetRendererType() == VolumeAttributes::RayCastingIntegration)
    {
        if (!artificialMin)
            range[0] = 0.;
        if (!artificialMax)
        {
/* Don't need this code, because the rays will be in depth ... 0->1.
            double bounds[6];
            GetSpatialExtents(bounds);
            UnifyMinMax(bounds, 6);
            double diag = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) +
                               (bounds[3]-bounds[2])*(bounds[3]-bounds[2]) +
                               (bounds[5]-bounds[4])*(bounds[5]-bounds[4]));
            range[1] = (actualRange[1]*diag) / 2.;
 */
            range[1] = (actualRange[1]) / 4.;
        }
    }

    //
    // Determine which variables to use and tell the ray function.
    //
    VarList vl;
    avtDataset_p input = GetTypedInput();
    avtDatasetExaminer::GetVariableList(input, vl);
    int primIndex = -1;
    int opacIndex = -1;
    int gradIndex = -1;
    int count = 0;
    char gradName[128];
    const char *gradvar = atts.GetOpacityVariable().c_str();
    if (strcmp(gradvar, "default") == 0)
        gradvar = primaryVariable;
    // This name is explicitly sent to the avtGradientExpression in
    // the avtVolumePlot.
    SNPRINTF(gradName, 128, "_%s_gradient", gradvar);

    for (int i = 0 ; i < vl.nvars ; i++)
    {
        if ((strstr(vl.varnames[i].c_str(), "vtk") != NULL) &&
            (strstr(vl.varnames[i].c_str(), "avt") != NULL))
            continue;

        if (vl.varnames[i] == primaryVariable)
        {
            primIndex = count;
        }
        if (vl.varnames[i] == atts.GetOpacityVariable())
        {
            opacIndex = count;
        }
        if (vl.varnames[i] == gradName)
        {
            gradIndex = count;
        }
        count += vl.varsizes[i];
    }

    if (primIndex == -1)
    {
        if (vl.nvars <= 0)
        {
            debug1 << "Could not locate primary variable "
                   << primaryVariable << ", assuming that we are running "
                   << "in parallel and have more processors than domains."
                   << endl;
        }
        else
        {
            EXCEPTION1(InvalidVariableException, primaryVariable);
        }
    }
    if (opacIndex == -1)
    {
        if (atts.GetOpacityVariable() == "default")
        {
            opacIndex = primIndex;
        }
        else if (vl.nvars <= 0)
        {
            debug1 << "Could not locate opacity variable "
                   << atts.GetOpacityVariable().c_str() << ", assuming that we "
                   << "are running in parallel and have more processors "
                   << "than domains." << endl;
        }
        else
        {
            EXCEPTION1(InvalidVariableException,atts.GetOpacityVariable());
        }
    }
    if (  atts.GetRendererType() != VolumeAttributes::RayCastingIntegration &&
          atts.GetLightingFlag() &&
          gradIndex == -1)
    {
        if (vl.nvars <= 0)
        {
            debug1 << "Could not locate gradient variable, assuming that we "
                   << "are running in parallel and have more processors "
                   << "than domains." << endl;
        }
        else
        {
            EXCEPTION1(InvalidVariableException,gradName);
        }
    }

    int newPrimIndex = UnifyMaximumValue(primIndex);
    if (primIndex >= 0 && newPrimIndex != primIndex)
    {
        //
        // We shouldn't ever have different orderings for our variables.
        //
        EXCEPTION1(InvalidVariableException, primaryVariable);
    }
    primIndex = newPrimIndex;

    int newOpacIndex = UnifyMaximumValue(opacIndex);
    if (opacIndex >= 0 && newOpacIndex != opacIndex)
    {
        //
        // We shouldn't ever have different orderings for our variables.
        //
        EXCEPTION1(InvalidVariableException, atts.GetOpacityVariable());
    }
    opacIndex = newOpacIndex;

    int newGradIndex = UnifyMaximumValue(gradIndex);
    if (gradIndex >= 0 && newGradIndex != gradIndex)
    {
        //
        // We shouldn't ever have different orderings for our variables.
        //
        EXCEPTION1(InvalidVariableException, gradName);
    }
    gradIndex = newGradIndex;

    //
    // Set up lighting
    //
    avtFlatLighting fl;
    avtLightingModel *lm = &fl;
    double gradMax = 0.0, lightingPower = 1.0;
    if (atts.GetLowGradientLightingReduction() != VolumeAttributes::Off)
    {
        gradMax = atts.GetLowGradientLightingClampValue();
        if (atts.GetLowGradientLightingClampFlag() == false)
        {
            double gradRange[2] = {0,0};
            GetDataExtents(gradRange, gradName);
            gradMax = gradRange[1];
        }
        switch (atts.GetLowGradientLightingReduction())
        {
          case VolumeAttributes::Lowest:   lightingPower = 1./16.; break;
          case VolumeAttributes::Lower:    lightingPower = 1./8.;  break;
          case VolumeAttributes::Low:      lightingPower = 1./4.;  break;
          case VolumeAttributes::Medium:   lightingPower = 1./2.;  break;
          case VolumeAttributes::High:     lightingPower = 1.;     break;
          case VolumeAttributes::Higher:   lightingPower = 2.;     break;
          case VolumeAttributes::Highest:  lightingPower = 4.;     break;
          default: break;
        }
    }
    avtPhong phong(gradMax, lightingPower);
    if (atts.GetLightingFlag())
    {
        lm = &phong;
    }
    else
    {
        lm = &fl;
    }

    avtOpacityMap *om2 = NULL;
    if (primIndex == opacIndex)
    {
        // Note that we are forcing the color variables range onto the
        // opacity variable.
        om2 = &om;
    }
    else
    {
        om2 = new avtOpacityMap(256);
        om2->SetTable(vtf, 256, atts.GetOpacityAttenuation());
        double range[2];

        bool artificialMin = atts.GetUseOpacityVarMin();
        bool artificialMax = atts.GetUseOpacityVarMax();
        if (!artificialMin || !artificialMax)
        {
            InputSetActiveVariable(atts.GetOpacityVariable().c_str());
            avtDatasetExaminer::GetDataExtents(input, range);
            UnifyMinMax(range, 2);
            InputSetActiveVariable(primaryVariable);
        }
        range[0] = (artificialMin ? atts.GetOpacityVarMin() : range[0]);
        range[1] = (artificialMax ? atts.GetOpacityVarMax() : range[1]);
        om2->SetMin(range[0]);
        om2->SetMax(range[1]);
        // LEAK!!
    }
    avtCompositeRF *compositeRF = new avtCompositeRF(lm, &om, om2);
    if (atts.GetRendererType() == VolumeAttributes::RayCasting && atts.GetSampling() == VolumeAttributes::Trilinear){
        compositeRF->SetTrilinearSampling(true);
        double *matProp = atts.GetMaterialProperties();
        double materialPropArray[4];
        materialPropArray[0] = matProp[0];
        materialPropArray[1] = matProp[1];
        materialPropArray[2] = matProp[2];
        materialPropArray[3] = matProp[3];
        compositeRF->SetMaterial(materialPropArray);
    }
    else
        compositeRF->SetTrilinearSampling(false);
    avtIntegrationRF *integrateRF = new avtIntegrationRF(lm);

    compositeRF->SetColorVariableIndex(primIndex);
    compositeRF->SetOpacityVariableIndex(opacIndex);
    if (atts.GetLightingFlag())
        compositeRF->SetGradientVariableIndex(gradIndex);
    integrateRF->SetPrimaryVariableIndex(primIndex);
    integrateRF->SetRange(range[0], range[1]);
    if (atts.GetSampling() == VolumeAttributes::KernelBased)
    {
        software->SetKernelBasedSampling(true);
        compositeRF->SetWeightVariableIndex(count);
    }

    if (atts.GetRendererType() == VolumeAttributes::RayCasting && atts.GetSampling() == VolumeAttributes::Trilinear)
        software->SetTrilinear(true);
    else
        software->SetTrilinear(false);
    
    if (atts.GetRendererType() == VolumeAttributes::RayCastingIntegration)
        software->SetRayFunction(integrateRF);
    else
        software->SetRayFunction(compositeRF);

    software->SetSamplesPerRay(atts.GetSamplesPerRay());

    const int *size = window.GetSize();
    software->SetScreen(size[0], size[1]);

    const View3DAttributes &view = window.GetView3D();
    avtViewInfo vi;
    CreateViewInfoFromViewAttributes(vi, view);

    avtDataObject_p inputData = GetInput();
    int width_,height_,depth_;
    if (GetLogicalBounds(inputData, width_,height_,depth_))      
    {
        // if we have logical bounds, compute the slices automatically
        double viewDirection[3];
        int numSlices;
        
        viewDirection[0] = (view.GetViewNormal()[0] > 0)? view.GetViewNormal()[0]: -view.GetViewNormal()[0];
        viewDirection[1] = (view.GetViewNormal()[1] > 0)? view.GetViewNormal()[1]: -view.GetViewNormal()[1];
        viewDirection[2] = (view.GetViewNormal()[2] > 0)? view.GetViewNormal()[2]: -view.GetViewNormal()[2];

        numSlices = (width_*viewDirection[0] + height_*viewDirection[1] + depth_*viewDirection[2]) * atts.GetRendererSamples();

        if (atts.GetRendererType() == VolumeAttributes::RayCasting && atts.GetSampling() == VolumeAttributes::Trilinear)
            software->SetSamplesPerRay(numSlices);
    }
    software->SetView(vi);
    if (atts.GetRendererType() == VolumeAttributes::RayCastingIntegration)
    {
        integrateRF->SetDistance(view.GetFarPlane()-view.GetNearPlane());
        integrateRF->SetWindowSize(size[0], size[1]);
    }

    double view_dir[3];
    view_dir[0] = vi.focus[0] - vi.camera[0];
    view_dir[1] = vi.focus[1] - vi.camera[1];
    view_dir[2] = vi.focus[2] - vi.camera[2];
    double mag = sqrt(view_dir[0]*view_dir[0] + view_dir[1]*view_dir[1]
                      + view_dir[2]*view_dir[2]);
    if (mag != 0.) // only 0 if focus and camera are the same
    {
        view_dir[0] /= mag;
        view_dir[1] /= mag;
        view_dir[2] /= mag;
    }
    lm->SetViewDirection(view_dir);
    lm->SetViewUp(vi.viewUp);
    lm->SetLightInfo(window.GetLights());
    const RenderingAttributes &render_atts = window.GetRenderAtts();
    if (render_atts.GetSpecularFlag())
    {
        lm->SetSpecularInfo(render_atts.GetSpecularFlag(),
                            render_atts.GetSpecularCoeff(),
                            render_atts.GetSpecularPower());
    }

    //
    // Set the volume renderer's background color and mode from the
    // window attributes.
    //
    software->SetBackgroundMode(window.GetBackgroundMode());
    software->SetBackgroundColor(window.GetBackground());
    software->SetGradientBackgroundColors(window.GetGradBG1(),
                                          window.GetGradBG2());

    //
    // We have to set up a sample point "arbitrator" to allow small cells
    // to be included in the final picture.
    //
    avtOpacityMapSamplePointArbitrator arb(om2, opacIndex);
    avtRay::SetArbitrator(&arb);

    //
    // Do the funny business to force an update.
    //
    avtDataObject_p dob = software->GetOutput();
    dob->Update(GetGeneralContract());

    if (atts.GetRendererType() == VolumeAttributes::RayCastingIntegration)
        integrateRF->OutputRawValues("integration.data");

    //
    // Free up some memory and clean up.
    //
    delete software;
    avtRay::SetArbitrator(NULL);
    delete compositeRF;
    delete integrateRF;

    //
    // Copy the output of the volume renderer to our output.
    //
    avtImage_p output;
    CopyTo(output, dob);
    return  output;
}
void __array<T>::System_Collections_ICollection_CopyTo(::CoreLib::System::Array* dest, int32_t length) 	
{
	CopyTo(dest, length);
}
::ActiveEffect* DispelEffect::Clone() const
{
    ::ActiveEffect* neweff = Make(caster,magicItem,(OBME::EffectItem*)effectItem); 
    CopyTo(*neweff); 
    return neweff;
}