CellsField* MultiDLA::markClusters(const CellsField* fld) { // Hoshen-Kopelman method returns field with marked clusters CellsField* result = new CellsField(fld->size(), fld->nullPnt(), fld->radius() * 2); FieldElement cluster_lbl = 0; size_t dims = fld->nullPnt().defDims(); MCoordVec neigh; for (size_t d = dims; d != 0; --d) { MCoord c; c.setCoord(d - 1, -1); neigh.push_back(c); } std::map<FieldElement, FieldElement> substitute; for (Counter cntr(fld->size(), fld->nullPnt()); cntr.isNext(); cntr.next()) { if (!fld->isSet(cntr.current())) { continue; } std::set<FieldElement> labels; for (size_t d = 0; d < dims; ++d) { MCoord current = cntr.current() + neigh[d]; if (!result->isElementInField(current)) { continue; } FieldElement lbl = result->elementVal(current); if (lbl != 0) { labels.insert(lbl); } } if (labels.empty()) { ++cluster_lbl; result->setElementVal(cntr.current(), cluster_lbl); } else { std::set<FieldElement>::iterator it = labels.begin(); FieldElement min_lbl = *it; FieldElement deepest = deepestMark(substitute, min_lbl); result->setElementVal(cntr.current(), deepest); for (++it; it != labels.end(); ++it) { substitute[*it] = deepestMark(substitute, deepest); } } } for (Counter cntr(fld->size(), fld->nullPnt()); cntr.isNext(); cntr.next()) { if (!fld->isSet(cntr.current())) { continue; } FieldElement curr_lbl = result->element(cntr.current()); if (substitute[curr_lbl] != 0) { result->setElementVal(cntr.current(), substitute[curr_lbl]); } } return result; }
// --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // TBool WlanTxRateAdaptation::SetRates( TUint8 aPolicyId, WHA::TRate aRateBitmask ) { OsTracePrint( KTxRateAdapt, (TUint8*) ("UMAC: WlanTxRateAdaptation::SetRates(): aPolicyId: 0x%08x"), aPolicyId); OsTracePrint( KTxRateAdapt, (TUint8*) ("UMAC: WlanTxRateAdaptation::SetRates(): aRateBitmask: 0x%08x"), aRateBitmask); // make the list of rates; but 1st clear the list Reset( iPolicy[aPolicyId - 1] ); // make rates from bitmask const TUint32 cntr_end( 32 ); TUint32 cntr( 0 ); for ( TUint32 bit = 1 ; cntr != cntr_end ; (bit <<= 1) ) { if ( aRateBitmask & bit ) { // rate is to be set if ( !AppendRate( aPolicyId - 1, aRateBitmask & bit ) ) { return EFalse; } } ++cntr; } // if we got this far, the rates are now in the list return ETrue; }
std::vector<MCoordVec>* MultiDLA::extractClusters(CellsField* MarkedFld) { std::map<FieldElement, MCoordVec> clusters; for (Counter cntr(MarkedFld->size(), MarkedFld->nullPnt()); cntr.isNext(); cntr.next()) { FieldElement lbl = MarkedFld->elementVal(cntr.current()); if (lbl == 0) { continue; } clusters[lbl].push_back(cntr.current()); // cout << cntr.Current() << " to lbl " << lbl << endl; } std::vector<MCoordVec>* result = new std::vector<MCoordVec>(clusters.size()); size_t i = 0; for (auto it = clusters.begin(); it != clusters.end(); ++it, ++i) { result->at(i).insert(result->at(i).begin(), it->second.begin(), it->second.end()); } return result; }
/*! This function will be automatically called under Unix platform when the current library instance is loading into process. Here comes the calling of a system installing method to initialize all system dependant routines and resourses. */ extern "C" void _init(void) { CALL // Allocate new shared library. loc_pSharedLibrary = (SHARED_LIBRARY_CLASS*)malloc(sizeof(SHARED_LIBRARY_CLASS)); if (loc_pSharedLibrary == 0) { WARNING(STR("DLL loading: Cannot allocate the current shared library.")); exit(-1); } // Create new shared library. cntr (loc_pSharedLibrary) SHARED_LIBRARY_CLASS(); // Load shared library. if (!loc_pSharedLibrary->onLoad()) { WARNING(STR("DLL loading: Cannot load the current shared library.")); loc_pSharedLibrary->~ISharedLibrary(); free(loc_pSharedLibrary); loc_pSharedLibrary = 0; exit(-1); } }
virtual sf::Vector2<float> offset() { sf::Vector2<float> cntr(-x+w/2,-y+h/2); return cntr; }