void Word::CreateUnknownWord(const Word &sourceWord) { FactorCollection &factorCollection = FactorCollection::Instance(); for (unsigned int currFactor = 0 ; currFactor < MAX_NUM_FACTORS ; currFactor++) { FactorType factorType = static_cast<FactorType>(currFactor); const Factor *sourceFactor = sourceWord[currFactor]; if (sourceFactor == NULL) SetFactor(factorType, factorCollection.AddFactor(Output, factorType, UNKNOWN_FACTOR)); else SetFactor(factorType, factorCollection.AddFactor(Output, factorType, sourceFactor->GetString())); } m_isNonTerminal = sourceWord.IsNonTerminal(); }
void Word::OnlyTheseFactors(const FactorMask &factors) { for (unsigned int currFactor = 0 ; currFactor < MAX_NUM_FACTORS ; currFactor++) { if (!factors[currFactor]) { SetFactor(currFactor, NULL); } } }
void Phrase::MergeFactors(const Phrase ©, const std::vector<FactorType>& factorVec) { UTIL_THROW_IF2(GetSize() != copy.GetSize(), "Both phrases need to be the same size to merge"); for (size_t currPos = 0 ; currPos < GetSize() ; currPos++) for (std::vector<FactorType>::const_iterator i = factorVec.begin(); i != factorVec.end(); ++i) { SetFactor(currPos, *i, copy.GetFactor(currPos, *i)); } }
void Phrase::MergeFactors(const Phrase ©, const std::vector<FactorType>& factorVec) { CHECK(GetSize() == copy.GetSize()); for (size_t currPos = 0 ; currPos < GetSize() ; currPos++) for (std::vector<FactorType>::const_iterator i = factorVec.begin(); i != factorVec.end(); ++i) { SetFactor(currPos, *i, copy.GetFactor(currPos, *i)); } }
void Phrase::OnlyTheseFactors(const FactorMask &factors) { for (unsigned int currFactor = 0 ; currFactor < MAX_NUM_FACTORS ; currFactor++) { if (!factors[currFactor]) { for (size_t pos = 0; pos < GetSize(); ++pos) { SetFactor(pos, currFactor, NULL); } } } }
void Unit::SetBonus(int i, int value, bool first) { int diff = 0; switch(i) { case 0: bonushealth = value; if (first == false) SetFactor(0,GetFactor(0)); break; case 1: bonusmana = value; if (first == false) SetFactor(1,GetFactor(1)); break; case 2: bonusstrength = value; //diff = value - bonusstrength; //SetDamage(GetDamage() + diff); if (first == false) SetFactor(2,GetFactor(2)); break; case 3: bonusmagic = value; //int diff = value - bonusstrength; //SetDamage(GetDamage() + diff); break; case 4: bonusagility = value; //diff = value - bonusagility; //(GetSpeed() + diff); if (first == false) SetFactor(4,GetFactor(4)); break; case 5: bonusdefense = value; SetDefence(bonusdefense); break; default: break; } }
void Word::CreateUnknownWord(const Word &sourceWord) { FactorCollection &factorCollection = FactorCollection::Instance(); m_isNonTerminal = sourceWord.IsNonTerminal(); // const std::string& factorDelimiter = StaticData::Instance().GetFactorDelimiter(); unsigned int stop = max_fax(); for (unsigned int currFactor = 0 ; currFactor < stop; currFactor++) { FactorType factorType = static_cast<FactorType>(currFactor); const Factor *sourceFactor = sourceWord[currFactor]; if (sourceFactor == NULL) SetFactor(factorType, factorCollection.AddFactor(Output, factorType, UNKNOWN_FACTOR, m_isNonTerminal)); else SetFactor(factorType, factorCollection.AddFactor(Output, factorType, sourceFactor->GetString(), m_isNonTerminal)); } m_isOOV = true; }
void Phrase::MergeFactors(const Phrase ©) { UTIL_THROW_IF2(GetSize() != copy.GetSize(), "Both phrases need to be the same size to merge"); size_t size = GetSize(); const size_t maxNumFactors = MAX_NUM_FACTORS; for (size_t currPos = 0 ; currPos < size ; currPos++) { for (unsigned int currFactor = 0 ; currFactor < maxNumFactors ; currFactor++) { FactorType factorType = static_cast<FactorType>(currFactor); const Factor *factor = copy.GetFactor(currPos, factorType); if (factor != NULL) SetFactor(currPos, factorType, factor); } } }
void Phrase::MergeFactors(const Phrase ©) { CHECK(GetSize() == copy.GetSize()); size_t size = GetSize(); const size_t maxNumFactors = MAX_NUM_FACTORS; for (size_t currPos = 0 ; currPos < size ; currPos++) { for (unsigned int currFactor = 0 ; currFactor < maxNumFactors ; currFactor++) { FactorType factorType = static_cast<FactorType>(currFactor); const Factor *factor = copy.GetFactor(currPos, factorType); if (factor != NULL) SetFactor(currPos, factorType, factor); } } }
void Phrase::MergeFactors(const Phrase ©) { assert(GetSize() == copy.GetSize()); size_t size = GetSize(); const size_t maxNumFactors = StaticData::Instance().GetMaxNumFactors(this->GetDirection()); for (size_t currPos = 0 ; currPos < size ; currPos++) { for (unsigned int currFactor = 0 ; currFactor < maxNumFactors ; currFactor++) { FactorType factorType = static_cast<FactorType>(currFactor); const Factor *factor = copy.GetFactor(currPos, factorType); if (factor != NULL) SetFactor(currPos, factorType, factor); } } }
void TFireWorkController::VInit(irr::u32 lifeSpan, irr::f32 factor) { SetLifeSpan(lifeSpan); SetFactor(factor); //disable the scene node if(mGameObject) { GComponentId compId = mGameObject->GetComponentIdByIndex(GC_IRRNODE_IDX); GIrrlichtComponent* ncomp = mGameObject->GetComponent<GIrrlichtComponent>(compId); if(ncomp) ncomp->mNode->setVisible(false); } }
void Phrase::MergeFactors(const Phrase ©, FactorType factorType) { UTIL_THROW_IF2(GetSize() != copy.GetSize(), "Both phrases need to be the same size to merge"); for (size_t currPos = 0 ; currPos < GetSize() ; currPos++) SetFactor(currPos, factorType, copy.GetFactor(currPos, factorType)); }
void Phrase::MergeFactors(const Phrase ©, FactorType factorType) { CHECK(GetSize() == copy.GetSize()); for (size_t currPos = 0 ; currPos < GetSize() ; currPos++) SetFactor(currPos, factorType, copy.GetFactor(currPos, factorType)); }
void mitk::OverwriteSliceImageFilter::GenerateData() { // // this is the place to implement the major part of undo functionality (bug #491) // here we have to create undo/do operations // // WHO is the operation actor? This object may not be destroyed ever (design of undo stack)! // -> some singleton method of this filter? // // neccessary additional objects: // - something that executes the operations // - the operation class (must hold a binary diff or something) // - observer commands to know when the image is deleted (no further action then, perhaps even remove the operations // from the undo stack) // Image::ConstPointer input = ImageToImageFilter::GetInput(0); Image::Pointer input3D = ImageToImageFilter::GetInput(0); Image::ConstPointer slice = m_SliceImage; if (input.IsNull() || slice.IsNull()) return; switch (m_SliceDimension) { default: case 2: m_Dimension0 = 0; m_Dimension1 = 1; break; case 1: m_Dimension0 = 0; m_Dimension1 = 2; break; case 0: m_Dimension0 = 1; m_Dimension1 = 2; break; } if (slice->GetDimension() < 2 || input->GetDimension() > 4 || slice->GetDimension(0) != input->GetDimension(m_Dimension0) || slice->GetDimension(1) != input->GetDimension(m_Dimension1) || m_SliceIndex >= input->GetDimension(m_SliceDimension)) { itkExceptionMacro("Slice and image dimensions differ or slice index is too large. Sorry, cannot work like this."); return; } if (input->GetDimension() == 4) { ImageTimeSelector::Pointer timeSelector = ImageTimeSelector::New(); timeSelector->SetInput(input); timeSelector->SetTimeNr(m_TimeStep); timeSelector->UpdateLargestPossibleRegion(); input3D = timeSelector->GetOutput(); } if (m_SliceDifferenceImage.IsNull() || m_SliceDifferenceImage->GetDimension(0) != m_SliceImage->GetDimension(0) || m_SliceDifferenceImage->GetDimension(1) != m_SliceImage->GetDimension(1)) { m_SliceDifferenceImage = mitk::Image::New(); mitk::PixelType pixelType(mitk::MakeScalarPixelType<short signed int>()); m_SliceDifferenceImage->Initialize(pixelType, 2, m_SliceImage->GetDimensions()); } // MITK_INFO << "Overwriting slice " << m_SliceIndex << " in dimension " << m_SliceDimension << " at time step " << // m_TimeStep << std::endl; // this will do a long long if/else to find out both pixel types AccessFixedDimensionByItk(input3D, ItkImageSwitch, 3); SegmentationInterpolationController *interpolator = SegmentationInterpolationController::InterpolatorForImage(input); if (interpolator) { interpolator->BlockModified(true); interpolator->SetChangedSlice(m_SliceDifferenceImage, m_SliceDimension, m_SliceIndex, m_TimeStep); } if (m_CreateUndoInformation) { // create do/undo operations (we don't execute the doOp here, because it has already been executed during // calculation of the diff image auto doOp = new ApplyDiffImageOperation(OpTEST, const_cast<Image *>(input.GetPointer()), m_SliceDifferenceImage, m_TimeStep, m_SliceDimension, m_SliceIndex); auto undoOp = new ApplyDiffImageOperation(OpTEST, const_cast<Image *>(input.GetPointer()), m_SliceDifferenceImage, m_TimeStep, m_SliceDimension, m_SliceIndex); undoOp->SetFactor(-1.0); OperationEvent *undoStackItem = new OperationEvent(DiffImageApplier::GetInstanceForUndo(), doOp, undoOp, this->EventDescription(m_SliceDimension, m_SliceIndex, m_TimeStep)); OperationEvent::IncCurrObjectEventId(); UndoController::GetCurrentUndoModel()->SetOperationEvent(undoStackItem); } // this image is modified (good to know for the renderer) input->Modified(); if (interpolator) { interpolator->BlockModified(false); } }