ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/src/selection/SelectionEvaluator.cpp
(Generate patch)

Comparing trunk/OOPSE-3.0/src/selection/SelectionEvaluator.cpp (file contents):
Revision 1972 by tim, Fri Feb 4 22:39:26 2005 UTC vs.
Revision 1979 by tim, Mon Feb 7 19:13:18 2005 UTC

# Line 49 | Line 49 | SelectionEvaluator::SelectionEvaluator(SimInfo* si) :
49   namespace oopse {
50  
51  
52 < SelectionEvaluator::SelectionEvaluator(SimInfo* si) : info(si), finder(info), isLoaded_(false){
53 <
52 > SelectionEvaluator::SelectionEvaluator(SimInfo* si) : info(si), nameFinder(info), distanceFinder(info), isLoaded_(false){
53 >    nStuntDouble = info->getNGlobalAtoms() + info->getNRigidBodies();
54   }            
55  
56   bool SelectionEvaluator::loadScript(const std::string& filename, const std::string& script) {
# Line 181 | Line 181 | void SelectionEvaluator::instructionDispatchLoop(BitSe
181        case Token::name:
182          stack.push(nameInstruction(boost::any_cast<std::string>(instruction.value)));
183          break;
184 +      case Token::index:
185 +        stack.push(indexInstruction(instruction.value));
186          break;
187        case Token::identifier:
188          stack.push(lookupValue(boost::any_cast<std::string>(instruction.value)));
# Line 211 | Line 213 | BitSet SelectionEvaluator::comparatorInstruction(const
213      float comparisonValue = boost::any_cast<float>(instruction.value);
214      float propertyValue;
215      BitSet bs(nStuntDouble);
216 +    bs.clearAll();
217      
218      SimInfo::MoleculeIterator mi;
219      Molecule* mol;
# Line 277 | Line 280 | void SelectionEvaluator::withinInstruction(const Token
280   }
281  
282   void SelectionEvaluator::withinInstruction(const Token& instruction, BitSet& bs){
283 <
283 >    
284      boost::any withinSpec = instruction.value;
285 +    float distance;
286      if (withinSpec.type() == typeid(float)){
287 <        //
288 <        return;
287 >        distance = boost::any_cast<float>(withinSpec);
288 >    } else if (withinSpec.type() == typeid(int)) {
289 >        distance = boost::any_cast<int>(withinSpec);    
290 >    } else {
291 >        evalError("casting error in withinInstruction");
292 >        bs.clearAll();
293      }
294      
295 <    evalError("Unrecognized within parameter");
295 >    bs = distanceFinder.find(bs, distance);            
296   }
297  
298   void SelectionEvaluator::define() {
# Line 334 | Line 342 | BitSet SelectionEvaluator::lookupValue(const std::stri
342  
343   BitSet SelectionEvaluator::lookupValue(const std::string& variable){
344  
345 +    BitSet bs(nStuntDouble);
346      std::map<std::string, boost::any>::iterator i = variables.find(variable);
347 <
347 >    
348      if (i != variables.end()) {
349          if (i->second.type() == typeid(BitSet)) {
350              return boost::any_cast<BitSet>(i->second);
351          } else if (i->second.type() ==  typeid(std::vector<Token>)){
352 <            BitSet bs = expression(boost::any_cast<std::vector<Token> >(i->second), 2);
352 >            bs = expression(boost::any_cast<std::vector<Token> >(i->second), 2);
353              i->second =  bs; /**@todo fixme */
354              return bs;
355          }
356      } else {
357          unrecognizedIdentifier(variable);
358      }
359 +
360 +    return bs;
361   }
362  
363   BitSet SelectionEvaluator::nameInstruction(const std::string& name){
364      
365 <    return finder.match(name);
365 >    return nameFinder.match(name);
366  
367   }    
368  
# Line 380 | Line 391 | BitSet SelectionEvaluator::evaluate() {
391  
392      return bs;
393   }
394 <        
394 >
395 > BitSet SelectionEvaluator::indexInstruction(const boost::any& value) {
396 >    BitSet bs(nStuntDouble);
397 >
398 >    if (value.type() == typeid(int)) {
399 >        int index = boost::any_cast<int>(value);
400 >        if (index < 0 || index >= bs.size()) {
401 >            invalidIndex(index);
402 >        } else {
403 >            bs.setBitOn(index);
404 >        }
405 >    } else if (value.type() == typeid(std::pair<int, int>)) {
406 >        std::pair<int, int> indexRange= boost::any_cast<std::pair<int, int> >(value);
407 >        assert(indexRange.first <= indexRange.second);
408 >        if (indexRange.first < 0 || indexRange.second >= bs.size()) {
409 >            invalidIndexRange(indexRange);
410 >        }else {
411 >            bs.setRangeOn(indexRange.first, indexRange.second);
412 >        }
413 >    }
414 >
415 >    return bs;
416 > }
417 >
418   //BitSet SelectionEvaluator::evaluate(int frameNo) {
419   //
420   //}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines