Ejemplo n.º 1
0
bool NormalizeData::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
   if (pInArgList == NULL || pOutArgList == NULL)
   {
      return false;
   }
   if (!extractInputArgs(pInArgList))
   {
      return false;
   }

   mProgress.report("Begin normalization conversion.", 1, NORMAL);

   { // scope the lifetime
      RasterElement *pResult = static_cast<RasterElement*>(
         Service<ModelServices>()->getElement(mResultName, TypeConverter::toString<RasterElement>(), NULL));
      if (pResult != NULL)
      {
         Service<ModelServices>()->destroyElement(pResult);
      }
   }
   ModelResource<RasterElement> pResult(RasterUtilities::createRasterElement(mResultName,
      mInput.mpDescriptor->getRowCount(), mInput.mpDescriptor->getColumnCount(), mInput.mpDescriptor->getBandCount(),
      FLT8BYTES, mInput.mpDescriptor->getInterleaveFormat(), mInput.mpDescriptor->getProcessingLocation() == IN_MEMORY));
   mInput.mpResult = pResult.get();
   if (mInput.mpResult == NULL)
   {
      mProgress.report("Unable to create result data set.", 0, ERRORS, true);
      return false;
   }
   mInput.mpResultDescriptor = static_cast<const RasterDataDescriptor*>(mInput.mpResult->getDataDescriptor());
   mInput.mpAbortFlag = &mAbortFlag;
   NormalizeDataThreadOutput outputData;
   mta::ProgressObjectReporter reporter("Normalizing", mProgress.getCurrentProgress());
   mta::MultiThreadedAlgorithm<NormalizeDataThreadInput, NormalizeDataThreadOutput, NormalizeDataThread>     
          alg(Service<ConfigurationSettings>()->getSettingThreadCount(), mInput, outputData, &reporter);
   switch(alg.run())
   {
   case mta::SUCCESS:
      if (!mAbortFlag)
      {
         mProgress.report("Normalization complete.", 100, NORMAL);
         if (!displayResult())
         {
            return false;
         }
         pResult.release();
         mProgress.upALevel();
         return true;
      }
      // fall through
   case mta::ABORT:
      mProgress.report("Normalization aborted.", 0, ABORT, true);
      return false;
   case mta::FAILURE:
      mProgress.report("Normalization failed.", 0, ERRORS, true);
      return false;
   }
   return true; // make the compiler happy
}
void setResultForContribution<FieldValuePluginFunction>(
    const fvMesh &mesh,
    ExpressionResult &result,
    const scalarField &values
) {
    autoPtr<volScalarField> pResult(
        new volScalarField(
            IOobject(
                "contributionFrom_", // +Driver::driverName(),
                mesh.time().timeName(),
                mesh,
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            mesh,
            dimensionedScalar("contribution",dimless,0)
        )
    );

#ifdef FOAM_NO_DIMENSIONEDINTERNAL_IN_GEOMETRIC
    const_cast<scalarField&>(pResult->internalField().field())
#else
    pResult->internalField()
#endif
        =values;
    pResult->correctBoundaryConditions();

    result.setObjectResult(pResult);
}
void stepsSinceChangePluginFunction<FaFieldValuePluginFunction>::doEvaluation() {
    scalar elapsed=StateMachine::machine(machineName_).stepsSinceChange();

    autoPtr<areaScalarField> pResult(
        new areaScalarField(
            IOobject(
                "stepsSinceChange_",
                this->mesh().time().timeName(),
                this->mesh(),
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            FaCommonValueExpressionDriver::faRegionMesh(this->mesh()),
            dimensionedScalar(
                "stepsSinceChange",
                dimless,
                elapsed
            )
        )
    );

    pResult->correctBoundaryConditions();

    result().setObjectResult(pResult);
}
Ejemplo n.º 4
0
CDownloadableResourcePtr CAntiCheatManager::GetDownloadableResource()
{
	CDownloadableResourcePtr pResult(NULL);
	CDownloadMgr *pMgr=g_pGame->GetDownloadMgr();
	if (pMgr)
	{
		pResult=pMgr->FindResourceByName("anticheatconfig");
	}
	return pResult;
}
Ejemplo n.º 5
0
CDownloadableResourcePtr CDataPatchDownloader::GetDownloadableResource()
{
	CDownloadableResourcePtr	pResult(NULL);
	CDownloadMgr							*pMgr=g_pGame->GetDownloadMgr();
	if (pMgr)
	{
		pResult=pMgr->FindResourceByName("datapatch");
	}
	return pResult;
}
    void DocumentSourceCommandFutures::getNextDocument() {
        while(true) {
            if (!pBsonSource.get()) {
                /* if there aren't any more futures, we're done */
                if (iterator == listEnd) {
                    pCurrent.reset();
                    return;
                }

                /* grab the next command result */
                shared_ptr<Future::CommandResult> pResult(*iterator);
                ++iterator;

                /* try to wait for it */
                if (!pResult->join()) {
                    error() << "sharded pipeline failed on shard: " <<
                        pResult->getServer() << " error: " <<
                        pResult->result() << endl;
                    errmsg += "-- mongod pipeline failed: ";
                    errmsg += pResult->result().toString();

                    /* move on to the next command future */
                    continue;
                }

                /* grab the result array out of the shard server's response */
                BSONObj shardResult(pResult->result());
                BSONObjIterator objIterator(shardResult);
                while(objIterator.more()) {
                    BSONElement element(objIterator.next());
                    const char *pFieldName = element.fieldName();

                    /* find the result array and quit this loop */
                    if (strcmp(pFieldName, "result") == 0) {
                        pBsonSource = DocumentSourceBsonArray::create(
                            &element, pExpCtx);
                        newSource = true;
                        break;
                    }
                }
            }

            /* if we're done with this shard's results, try the next */
            if (pBsonSource->eof() ||
                (!newSource && !pBsonSource->advance())) {
                pBsonSource.reset();
                continue;
            }

            pCurrent = pBsonSource->getCurrent();
            newSource = false;
            return;
        }
    }
tmp<Field<T> > filterFieldValues(
    const Field<T> &orig,
    const boolList &mask,
    label size
) {
    tmp<Field<T> > pResult(
        new Field<T>(
            size,
            pTraits<T>::zero
        )
    );
    Field<T> &result=const_cast<Field<T>&>(pResult());
    label cnt=0;
    forAll(orig,i)
    {
        if(mask[i]) {
            if(cnt>=size) {
                FatalErrorIn("filterFieldValues")
                    << "Mask seems to have more elements than " << size
                        << endl
                        << exit(FatalError);
            }
            result[cnt]=orig[i];
            cnt++;
        }
    }
    if(cnt!=size) {
        FatalErrorIn("filterFieldValues")
            << "Inconsistent amount of elements in mask " << cnt << nl
                << "Need: " << size
                << endl
                << exit(FatalError);

    }
    return pResult;
}
Ejemplo n.º 8
0
    intrusive_ptr<Document> DocumentSourceGroup::makeDocument(
        const GroupsType::iterator &rIter) {
        vector<intrusive_ptr<Accumulator> > *pGroup = &rIter->second;
        const size_t n = vFieldName.size();
        intrusive_ptr<Document> pResult(Document::create(1 + n));

        /* add the _id field */
        pResult->addField(Document::idName, rIter->first);

        /* add the rest of the fields */
        for(size_t i = 0; i < n; ++i) {
	    intrusive_ptr<const Value> pValue((*pGroup)[i]->getValue());
	    if (pValue->getType() != Undefined)
		pResult->addField(vFieldName[i], pValue);
	}

        return pResult;
    }
Ejemplo n.º 9
0
		int WINAPI strike(::WQEvent* pEvent, LPVOID lpUserParam) {
			std::unique_ptr<Result::promise_ptr> pResult(static_cast<Result::promise_ptr*>(lpUserParam));
			assert(pResult);
			Result::promise_ptr& result(*pResult);
			assert(result);

			assert(pEvent != NULL);
			switch (pEvent->EventType) {
			case eWQResponse:
			case eWQErrorReport:
				result->set_value(new Wind::Event(*pEvent));
				return true;
			default: {
					std::ostringstream buffer;
					buffer << "<WQ> unsupported strike response: " << *pEvent;
					result->set_exception(std::make_exception_ptr(std::runtime_error(buffer.str())));
					return false;
				}
			}
		}
Ejemplo n.º 10
0
bool AoiLogical::displayResult()
{
    if (mpResult == NULL || mpView == NULL)
    {
        return false;
    }

    ModelResource<AoiElement> pResult(mResultName);
    if (pResult.get() == NULL || pResult->addPoints(mpResult) == NULL)
    {
        mProgress.report("Unable to create result AOI.", 0, ERRORS, true);
        return false;
    }
    UndoLock lock(mpView);
    AoiLayer* pLayer = static_cast<AoiLayer*>(mpView->createLayer(AOI_LAYER, pResult.get()));
    if (pLayer == NULL)
    {
        mProgress.report("Unable to display result.", 0, ERRORS, true);
        return false;
    }
    pResult.release();
    return true;
}
void setResultForContribution<FaFieldValuePluginFunction>(
    const fvMesh &mesh,
    ExpressionResult &result,
    const scalarField &values
) {
    autoPtr<areaScalarField> pResult(
        new areaScalarField(
            IOobject(
                "contributionFrom_", // +Driver::driverName(),
                mesh.time().timeName(),
                mesh,
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            FaCommonValueExpressionDriver::faRegionMesh(mesh),
            dimensionedScalar("contribution",dimless,0)
        )
    );

    pResult->internalField()=values;
    pResult->correctBoundaryConditions();

    result.setObjectResult(pResult);
}
void stepsSinceChangePluginFunction<FieldValuePluginFunction>::doEvaluation()
{
    scalar elapsed=StateMachine::machine(machineName_).stepsSinceChange();

    autoPtr<volScalarField> pResult(
        new volScalarField(
            IOobject(
                "stepsSinceChange_",
                this->mesh().time().timeName(),
                this->mesh(),
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            this->mesh(),
            dimensionedScalar(
                "stepsSinceChange",
                dimless,
                elapsed
            )
        )
    );

    result().setObjectResult(pResult);
}
Ejemplo n.º 13
0
bool ConvolutionFilterShell::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
   if (pInArgList == NULL || pOutArgList == NULL)
   {
      return false;
   }
   if (!extractInputArgs(pInArgList))
   {
      return false;
   }
   if (!populateKernel() || mInput.mKernel.Nrows() % 2 == 0 || mInput.mKernel.Ncols() % 2 == 0)
   {
      mProgress.report("Invalid kernel.", 0, ERRORS, true);
      return false;
   }
   BitMaskIterator iterChecker((mpAoi == NULL) ? NULL : mpAoi->getSelectedPoints(), 0, 0,
      mInput.mpDescriptor->getColumnCount() - 1, mInput.mpDescriptor->getRowCount() - 1);
   EncodingType resultType = mInput.mForceFloat ? EncodingType(FLT8BYTES) : mInput.mpDescriptor->getDataType();
   if (resultType == INT4SCOMPLEX)
   {
      resultType = INT4SBYTES;
   }
   else if (resultType == FLT8COMPLEX)
   {
      resultType = FLT8BYTES;
   }
   if (!isBatch())
   {
      RasterElement* pResult = static_cast<RasterElement*>(
         Service<ModelServices>()->getElement(mResultName, TypeConverter::toString<RasterElement>(), NULL));
      if (pResult != NULL)
      {
         if (QMessageBox::question(Service<DesktopServices>()->getMainWidget(), "Result data set exists",
            "The result data set already exists. Would you like to replace it?",
            QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::No)
         {
            return false;
         }
         Service<ModelServices>()->destroyElement(pResult);
      }
   }
   mProgress.report("Begin convolution matrix execution.", 0, NORMAL);

   ModelResource<RasterElement> pResult(RasterUtilities::createRasterElement(
      mResultName, iterChecker.getNumSelectedRows(), iterChecker.getNumSelectedColumns(),
      mInput.mBands.size(), resultType, mInput.mpDescriptor->getInterleaveFormat(),
      mInput.mpDescriptor->getProcessingLocation() == IN_MEMORY));
   pResult->copyClassification(mInput.mpRaster);
   pResult->getMetadata()->merge(mInput.mpDescriptor->getMetadata()); //copy original metadata
   //chip metadata by bands
   vector<DimensionDescriptor> orgBands = mInput.mpDescriptor->getBands();
   vector<DimensionDescriptor> newBands;
   newBands.reserve(mInput.mBands.size());
   for (unsigned int index = 0; index < mInput.mBands.size(); ++index)
   {
      unsigned int selectedBand = mInput.mBands[index];
      if (selectedBand < orgBands.size())
      {
         newBands.push_back(orgBands[selectedBand]);
      }
   }
   RasterUtilities::chipMetadata(pResult->getMetadata(), mInput.mpDescriptor->getRows(),
      mInput.mpDescriptor->getColumns(), newBands);
   mInput.mpResult = pResult.get();
   if (mInput.mpResult == NULL)
   {
      mProgress.report("Unable to create result data set.", 0, ERRORS, true);
      return false;
   }
   mInput.mpAbortFlag = &mAborted;
   mInput.mpIterCheck = &iterChecker;
   ConvolutionFilterThreadOutput outputData;
   mta::ProgressObjectReporter reporter("Convolving", mProgress.getCurrentProgress());
   mta::MultiThreadedAlgorithm<ConvolutionFilterThreadInput,
                               ConvolutionFilterThreadOutput,
                               ConvolutionFilterThread>
          alg(mta::getNumRequiredThreads(iterChecker.getNumSelectedRows()), mInput, outputData, &reporter);
   switch(alg.run())
   {
   case mta::SUCCESS:
      if (!isAborted())
      {
         mProgress.report("Convolution filter complete.", 100, NORMAL);
         SpatialDataView* pView = displayResult();
         if (Service<ApplicationServices>()->isInteractive() && pView == NULL)
         {
            return false;
         }
         pOutArgList->setPlugInArgValue("View", pView);

         pResult.release();
         mProgress.upALevel();
         return true;
      }
      // fall through
   case mta::ABORT:
      mProgress.report("Convolution filter aborted.", 0, ABORT, true);
      return false;
   case mta::FAILURE:
      mProgress.report("Convolution filter failed.", 0, ERRORS, true);
      return false;
   default:
      VERIFY(false); // can't happen
   }
}
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 StaticMeshComponentUPtr RenderComponentFactory::CreateStaticMeshComponent(const MeshCSPtr& in_model, const MaterialCSPtr& in_material)
 {
     StaticMeshComponentUPtr pResult(new StaticMeshComponent());
     pResult->AttachMesh(in_model, in_material);
     return pResult;
 }
Ejemplo n.º 15
0
/*++

Routine Name:

    CPTManager::MergeTicket

Routine Description:

    This routine merges a PrintTicket (supplied as a IXMLDOMDocument2 pointer) into
    the DOM representation of the PrintTicket at the requested scope

Arguments:

    ptScope - The scope at which the PrintTicket is to be merged
    pPT     - Pointer to an IXMLDOMDocument2 interface containing the PrintTicket to be merged

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CPTManager::MergeTicket(
    _In_ CONST EPrintTicketScope ptScope,
    _In_ CONST IXMLDOMDocument2* pPT
    )
{
    HRESULT hr = S_OK;

    if (SUCCEEDED(hr = CHECK_POINTER(pPT, E_POINTER)))
    {
        CComPtr<IXMLDOMDocument2> pPTLevelUp(NULL);
        CComPtr<IXMLDOMDocument2> pResult(NULL);

        switch (ptScope)
        {
            case kPTJobScope:
            {
                pPTLevelUp = m_pDefaultPT;
            }
            break;

            case kPTDocumentScope:
            {
                pPTLevelUp = m_pJobPT;
            }
            break;

            case kPTPageScope:
            {
                pPTLevelUp = m_pDocPT;
            }
            break;

            default:
            {
                RIP("Unrecognised PT scope\n");

                hr = E_INVALIDARG;
            }
            break;
        }

        ASSERTMSG(pPTLevelUp != NULL, "PrintTicket at the level up has not been set (check part handler is attempting to)\n");

        if (SUCCEEDED(hr) &&
            SUCCEEDED(hr = CHECK_POINTER(pPTLevelUp, E_PENDING)) &&
            SUCCEEDED(hr = GetMergedTicket(ptScope, pPT, pPTLevelUp, &pResult)))
        {
            switch (ptScope)
            {
                case kPTJobScope:
                {
                    m_pJobPT = pResult;
                }
                break;

                case kPTDocumentScope:
                {
                    m_pDocPT = pResult;
                }
                break;

                case kPTPageScope:
                {
                    m_pPagePT = pResult;
                }
                break;
            }
        }
    }

    ERR_ON_HR(hr);
    return hr;
}