// Move the BDD nodes in the cone >= fromLevel to toLevel. // After the move, there will be no BDD nodes between [fromLevel, toLevel). // Return the resulted BDD node. // // [Note] If (fromLevel > toLevel) ==> move down // If (fromLevel < toLevel) ==> move up // // Before the move, need to make sure: // 1. (thisLevel - fromLevel) < abs(fromLevel - toLevel) // 2. There is no node < fromLevel (except for the terminal node). // // [Note] If (move up), there is no node above toLevel in the beginning. // // If any of the above is violated, isMoved will be set to false, // no move will be made, and return (*this). // BddNodeV BddNodeV::nodeMove(unsigned fromLevel, unsigned toLevel, bool& isMoved) const { assert(fromLevel > 1); if (int(getLevel() - fromLevel) >= abs(int(fromLevel - toLevel)) || containNode(fromLevel - 1, 1)) { isMoved = false; return (*this); } isMoved = true; map<size_t, size_t> moveMap; return nodeMoveRecur(fromLevel, toLevel, moveMap); }
void zoneManager::update(map<string, ofPtr<clamourNode> > tNodes) { appReactions.clear(); //implement scheduled commands vector<eventComm>::iterator e_it = mFutureEvents.begin(); while(e_it != mFutureEvents.end()) { if(e_it->execAt == ofGetFrameNum()) { if(mZones.find(e_it->ownerIndex) != mZones.end()){ implementReaction(e_it->r, mZones[e_it->ownerIndex]); } e_it = mFutureEvents.erase(e_it); } else { ++e_it; } } map<string, ofPtr<zone> >::iterator z_it; map<string, ofPtr<clamourNode> >::iterator n_it; //call update method here which resets closed zones and increments reactions etc for(z_it = mZones.begin(); z_it != mZones.end(); ++z_it) { z_it->second->update(); z_it->second->updateEvents(); z_it->second->updateDrawData(); if(getOffTrig(z_it->second)) { offReact(z_it->second); } } //find node intersections n_it = tNodes.begin(); while(n_it != tNodes.end()) { if(n_it->second->getIsSleeping()) { if(n_it->second->getZonePair()) { if(!n_it->second->getZonePair()->getIsClosedIn()) { n_it->second->getZonePair()->removeNode(n_it->second); n_it->second->resetZonePair(); } } ++n_it; continue; } for(z_it = mZones.begin(); z_it != mZones.end(); ++z_it) { if(z_it->second->getIsClosedIn()) { if(n_it->second->getZonePair() == z_it->second) { //only for already captured nodes containNode(n_it->second, z_it->second); continue; // mustn't allow other reactions } } if(checkInZone(n_it->second, z_it->second)) { if(n_it->second->getZonePair() == z_it->second) { break; //already in the zone } //new nodes inside the zone if(z_it->second->getIsClosedOut()) { // cout << "repell \n"; repellNode(n_it->second, z_it->second); } else { if(n_it->second->getZonePair()) { //incase the node has jumped straight from one zone to the next n_it->second->getZonePair()->removeNode(n_it->second); n_it->second->resetZonePair(); } n_it->second->setZonePair(z_it->second); z_it->second->addNode(n_it->second); //now update zone reactions if(getOnTrig(z_it->second))onReact(z_it->second); break; //no need to check any more zones for this node } } else if(n_it->second->getZonePair() == z_it->second) { z_it->second->removeNode(n_it->second); n_it->second->resetZonePair(); } } ++n_it; } }