ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/selection/SelectionEvaluator.cpp
(Generate patch)

Comparing:
trunk/src/selection/SelectionEvaluator.cpp (file contents), Revision 278 by tim, Tue Feb 1 22:49:23 2005 UTC vs.
branches/development/src/selection/SelectionEvaluator.cpp (file contents), Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC

# Line 6 | Line 6
6   * redistribute this software in source and binary code form, provided
7   * that the following conditions are met:
8   *
9 < * 1. Acknowledgement of the program authors must be made in any
10 < *    publication of scientific results based in part on use of the
11 < *    program.  An acceptable form of acknowledgement is citation of
12 < *    the article in which the program was described (Matthew
13 < *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 < *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 < *    Parallel Simulation Engine for Molecular Dynamics,"
16 < *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 < *
18 < * 2. Redistributions of source code must retain the above copyright
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
12 > * 2. Redistributions in binary form must reproduce the above copyright
13   *    notice, this list of conditions and the following disclaimer in the
14   *    documentation and/or other materials provided with the
15   *    distribution.
# Line 37 | Line 28
28   * arising out of the use of or inability to use software, even if the
29   * University of Notre Dame has been advised of the possibility of
30   * such damages.
31 + *
32 + * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your
33 + * research, please cite the appropriate papers when you publish your
34 + * work.  Good starting points are:
35 + *                                                                      
36 + * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37 + * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 + * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
39 + * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 + * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42  
43 + #include <stack>
44   #include "selection/SelectionEvaluator.hpp"
45 < namespace oopse {
45 > #include "primitives/Atom.hpp"
46 > #include "primitives/DirectionalAtom.hpp"
47 > #include "primitives/RigidBody.hpp"
48 > #include "primitives/Molecule.hpp"
49 > #include "io/ifstrstream.hpp"
50  
51 + namespace OpenMD {
52  
53 < bool SelectionEvaluator::loadScript(const std::string& filename, const std::string& script) {
53 >
54 >  SelectionEvaluator::SelectionEvaluator(SimInfo* si)
55 >    : info(si), nameFinder(info), distanceFinder(info), hullFinder(info),
56 >      indexFinder(info),
57 >      isLoaded_(false){    
58 >      nStuntDouble = info->getNGlobalAtoms() + info->getNGlobalRigidBodies();
59 >    }            
60 >
61 >  bool SelectionEvaluator::loadScript(const std::string& filename,
62 >                                      const std::string& script) {
63 >    clearDefinitionsAndLoadPredefined();
64      this->filename = filename;
65      this->script = script;
66      if (! compiler.compile(filename, script)) {
67 <        error = true;
68 <        errorMessage = compiler.getErrorMessage();
69 <        return false;
67 >      error = true;
68 >      errorMessage = compiler.getErrorMessage();
69 >
70 >      sprintf( painCave.errMsg,
71 >               "SelectionCompiler Error: %s\n", errorMessage.c_str());
72 >      painCave.severity = OPENMD_ERROR;
73 >      painCave.isFatal = 1;
74 >      simError();
75 >      return false;
76      }
77  
78      pc = 0;
79      aatoken = compiler.getAatokenCompiled();
80      linenumbers = compiler.getLineNumbers();
81      lineIndices = compiler.getLineIndices();
82 +
83 +    std::vector<std::vector<Token> >::const_iterator i;  
84 +
85 +    isDynamic_ = false;
86 +    for (i = aatoken.begin(); i != aatoken.end(); ++i) {
87 +      if (containDynamicToken(*i)) {
88 +        isDynamic_ = true;
89 +        break;
90 +      }
91 +    }
92 +
93 +    isLoaded_ = true;
94      return true;
95 < }
95 >  }
96  
97 < void SelectionEvaluator::clearState() {
63 <    for (int i = scriptLevelMax; --i >= 0; )
64 <        stack[i] = null;
65 <    scriptLevel = 0;
97 >  void SelectionEvaluator::clearState() {
98      error = false;
99 <    errorMessage = null;
100 < }
99 >    errorMessage = "";
100 >  }
101  
102 < bool SelectionEvaluator::loadScriptString(const std::string& script) {
102 >  bool SelectionEvaluator::loadScriptString(const std::string& script) {
103      clearState();
104 <    return loadScript(null, script);
105 < }
104 >    return loadScript("", script);
105 >  }
106  
107 < bool SelectionEvaluator::loadScriptFile(const std::string& filename) {
107 >  bool SelectionEvaluator::loadScriptFile(const std::string& filename) {
108      clearState();
109      return loadScriptFileInternal(filename);
110 < }
110 >  }
111  
112 <
113 < void SelectionEvaluator::instructionDispatchLoop(){
114 <
115 <    while ( pc < aatoken.length) {
84 <        statement = aatoken[pc++];
85 <        statementLength = statement.length;
86 <        Token token = statement[0];
87 <        switch (token.tok) {
88 <            case Token.define:
89 <                define();
90 <            break;
91 <            case Token.select:
92 <                select();
93 <            break;
94 <            default:
95 <                unrecognizedCommand(token);
96 <            return;
97 <        }
112 >  bool SelectionEvaluator::loadScriptFileInternal(const std::string & filename) {
113 >    ifstrstream ifs(filename.c_str());
114 >    if (!ifs.is_open()) {
115 >      return false;
116      }
117 < }
118 <
119 <  void SelectionEvaluator::predefine(String script) {
120 <    if (compiler.compile("#predefine", script)) {
121 <      Token [][] aatoken = compiler.getAatokenCompiled();
122 <      if (aatoken.length != 1) {
123 <        viewer.scriptStatus("predefinition does not have exactly 1 command:"
124 <                            + script);
125 <        return;
117 >    
118 >    const int bufferSize = 65535;
119 >    char buffer[bufferSize];
120 >    std::string script;
121 >    while(ifs.getline(buffer, bufferSize)) {
122 >      script += buffer;
123 >    }
124 >    return loadScript(filename, script);
125 >  }
126 >  
127 >  void SelectionEvaluator::instructionDispatchLoop(OpenMDBitSet& bs){
128 >    
129 >    while ( pc < aatoken.size()) {
130 >      statement = aatoken[pc++];
131 >      statementLength = statement.size();
132 >      Token token = statement[0];
133 >      switch (token.tok) {
134 >      case Token::define:
135 >        define();
136 >        break;
137 >      case Token::select:
138 >        select(bs);
139 >        break;
140 >      default:
141 >        unrecognizedCommand(token);
142 >        return;
143        }
109      Token[] statement = aatoken[0];
110      if (statement.length > 2) {
111        int tok = statement[1].tok;
112        if (tok == Token.identifier ||
113            (tok & Token.predefinedset) == Token.predefinedset) {
114          String variable = (String)statement[1].value;
115          variables.put(variable, statement);
116        } else {
117          viewer.scriptStatus("invalid variable name:" + script);
118        }
119      } else {
120        viewer.scriptStatus("bad predefinition length:" + script);
121      }
122    } else {
123      viewer.scriptStatus("predefined set compile error:" + script +
124                          "\ncompile error:" + compiler.getErrorMessage());
144      }
145 +
146    }
147  
148 <
149 <
150 <  BitSet SelectionEvaluator::expression(Token[] code, int pcStart) throws ScriptException {
151 <    int numberOfAtoms = viewer.getAtomCount();
152 <    BitSet bs;
153 <    BitSet[] stack = new BitSet[10];
134 <    int sp = 0;
135 <
136 <    for (int pc = pcStart; ; ++pc) {
148 >  OpenMDBitSet SelectionEvaluator::expression(const std::vector<Token>& code,
149 >                                             int pcStart) {
150 >    OpenMDBitSet bs;
151 >    std::stack<OpenMDBitSet> stack;
152 >  
153 >    for (int pc = pcStart; pc < code.size(); ++pc) {
154        Token instruction = code[pc];
155 <      if (logMessages)
139 <        viewer.scriptStatus("instruction=" + instruction);
155 >
156        switch (instruction.tok) {
157 <      case Token.expressionBegin:
157 >      case Token::expressionBegin:
158          break;
159 <      case Token.expressionEnd:
144 <        break expression_loop;
145 <      case Token.all:
146 <        bs = stack[sp++] = new BitSet(numberOfAtoms);
147 <        for (int i = numberOfAtoms; --i >= 0; )
148 <          bs.set(i);
159 >      case Token::expressionEnd:
160          break;
161 <      case Token.none:
162 <        stack[sp++] = new BitSet();
161 >      case Token::all:
162 >        bs = OpenMDBitSet(nStuntDouble);
163 >        bs.setAll();
164 >        stack.push(bs);            
165          break;
166 <      case Token.opOr:
167 <        bs = stack[--sp];
168 <        stack[sp-1].or(bs);
166 >      case Token::none:
167 >        bs = OpenMDBitSet(nStuntDouble);
168 >        stack.push(bs);            
169          break;
170 <      case Token.opAnd:
171 <        bs = stack[--sp];
172 <        stack[sp-1].and(bs);
170 >      case Token::opOr:
171 >        bs = stack.top();
172 >        stack.pop();
173 >        stack.top() |= bs;
174          break;
175 <      case Token.opNot:
176 <        bs = stack[sp - 1];
177 <        notSet(bs);
175 >      case Token::opAnd:
176 >        bs = stack.top();
177 >        stack.pop();
178 >        stack.top() &= bs;
179          break;
180 <      case Token.within:
181 <        bs = stack[sp - 1];
167 <        stack[sp - 1] = new BitSet();
168 <        withinInstruction(instruction, bs, stack[sp - 1]);
180 >      case Token::opNot:
181 >        stack.top().flip();
182          break;
183 <      case Token.selected:
184 <        stack[sp++] = copyBitSet(viewer.getSelectionSet());
183 >      case Token::within:
184 >        withinInstruction(instruction, stack.top());
185          break;
186 <      case Token.y:
187 <      case Token.amino:
175 <      case Token.backbone:
176 <      case Token.solvent:
177 <      case Token.identifier:
178 <      case Token.sidechain:
179 <      case Token.surface:
180 <        stack[sp++] = lookupIdentifierValue((String)instruction.value);
186 >      case Token::hull:
187 >        stack.push(hull());
188          break;
189 <      case Token.opLT:
190 <      case Token.opLE:
191 <      case Token.opGE:
192 <      case Token.opGT:
193 <      case Token.opEQ:
187 <      case Token.opNE:
188 <        bs = stack[sp++] = new BitSet();
189 <        comparatorInstruction(instruction, bs);
189 >        //case Token::selected:
190 >        //  stack.push(getSelectionSet());
191 >        //  break;
192 >      case Token::name:
193 >        stack.push(nameInstruction(boost::any_cast<std::string>(instruction.value)));
194          break;
195 +      case Token::index:
196 +        stack.push(indexInstruction(instruction.value));
197 +        break;
198 +      case Token::identifier:
199 +        stack.push(lookupValue(boost::any_cast<std::string>(instruction.value)));
200 +        break;
201 +      case Token::opLT:
202 +      case Token::opLE:
203 +      case Token::opGE:
204 +      case Token::opGT:
205 +      case Token::opEQ:
206 +      case Token::opNE:
207 +        stack.push(comparatorInstruction(instruction));
208 +        break;
209        default:
210          unrecognizedExpression();
211        }
212      }
213 <    if (sp != 1)
213 >    if (stack.size() != 1)
214        evalError("atom expression compiler error - stack over/underflow");
215 <    return stack[0];
215 >          
216 >    return stack.top();
217    }
218  
219  
220  
221 <  void SelectionEvaluator::comparatorInstruction(Token instruction, BitSet bs) {
221 >  OpenMDBitSet SelectionEvaluator::comparatorInstruction(const Token& instruction) {
222      int comparator = instruction.tok;
223      int property = instruction.intValue;
224 <    float propertyValue = 0; // just for temperature
225 <    int comparisonValue = ((Integer)instruction.value).intValue();
226 <    int numberOfAtoms = viewer.getAtomCount();
227 <    Frame frame = viewer.getFrame();
228 <    for (int i = 0; i < numberOfAtoms; ++i) {
229 <      Atom atom = frame.getAtomAt(i);
230 <      switch (property) {
231 <      case Token.atomno:
232 <        propertyValue = atom.getAtomNumber();
233 <        break;
234 <      case Token.elemno:
235 <        propertyValue = atom.getElementNumber();
236 <        break;
237 <      case Token.temperature:
238 <        propertyValue = atom.getBfactor100();
239 <        if (propertyValue < 0)
240 <          continue;
222 <        propertyValue /= 100;
223 <        break;
224 <      case Token._atomID:
225 <        propertyValue = atom.getSpecialAtomID();
226 <        if (propertyValue < 0)
227 <          continue;
228 <        break;
229 <      case Token._structure:
230 <        propertyValue = getProteinStructureType(atom);
231 <        if (propertyValue == -1)
232 <          continue;
233 <        break;
234 <      case Token.radius:
235 <        propertyValue = atom.getRasMolRadius();
236 <        break;
237 <      case Token._bondedcount:
238 <        propertyValue = atom.getCovalentBondCount();
239 <        break;
240 <      case Token.model:
241 <        propertyValue = atom.getModelTagNumber();
242 <        break;
243 <      default:
244 <        unrecognizedAtomProperty(property);
224 >    float comparisonValue = boost::any_cast<float>(instruction.value);
225 >    float propertyValue;
226 >    OpenMDBitSet bs(nStuntDouble);
227 >    bs.clearAll();
228 >    
229 >    SimInfo::MoleculeIterator mi;
230 >    Molecule* mol;
231 >    Molecule::AtomIterator ai;
232 >    Atom* atom;
233 >    Molecule::RigidBodyIterator rbIter;
234 >    RigidBody* rb;
235 >
236 >    for (mol = info->beginMolecule(mi); mol != NULL;
237 >         mol = info->nextMolecule(mi)) {
238 >
239 >      for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
240 >        compareProperty(atom, bs, property, comparator, comparisonValue);
241        }
242 <      boolean match = false;
243 <      switch (comparator) {
244 <      case Token.opLT:
245 <        match = propertyValue < comparisonValue;
250 <        break;
251 <      case Token.opLE:
252 <        match = propertyValue <= comparisonValue;
253 <        break;
254 <      case Token.opGE:
255 <        match = propertyValue >= comparisonValue;
256 <        break;
257 <      case Token.opGT:
258 <        match = propertyValue > comparisonValue;
259 <        break;
260 <      case Token.opEQ:
261 <        match = propertyValue == comparisonValue;
262 <        break;
263 <      case Token.opNE:
264 <        match = propertyValue != comparisonValue;
265 <        break;
242 >    
243 >      for (rb = mol->beginRigidBody(rbIter); rb != NULL;
244 >           rb = mol->nextRigidBody(rbIter)) {
245 >        compareProperty(rb, bs, property, comparator, comparisonValue);
246        }
267      if (match)
268        bs.set(i);
247      }
248 +
249 +    return bs;
250    }
251  
252 < void SelectionEvaluator::withinInstruction(Token instruction, BitSet bs, BitSet bsResult)
252 >  void SelectionEvaluator::compareProperty(StuntDouble* sd, OpenMDBitSet& bs,
253 >                                           int property, int comparator,
254 >                                           float comparisonValue) {
255 >    RealType propertyValue = 0.0;
256 >    switch (property) {
257 >    case Token::mass:
258 >      propertyValue = sd->getMass();
259 >      break;
260 >    case Token::charge:
261 >      if (sd->isAtom()){
262 >        Atom* atom = static_cast<Atom*>(sd);
263 >        propertyValue = getCharge(atom);
264 >      } else if (sd->isRigidBody()) {
265 >        RigidBody* rb = static_cast<RigidBody*>(sd);
266 >        RigidBody::AtomIterator ai;
267 >        Atom* atom;
268 >        for (atom = rb->beginAtom(ai); atom != NULL; atom = rb->nextAtom(ai)) {
269 >          propertyValue+=  getCharge(atom);
270 >        }
271 >      }
272 >      break;
273 >    case Token::x:
274 >      propertyValue = sd->getPos().x();
275 >      break;
276 >    case Token::y:
277 >      propertyValue = sd->getPos().y();
278 >      break;
279 >    case Token::z:
280 >      propertyValue = sd->getPos().z();
281 >      break;
282 >    case Token::r:
283 >      propertyValue = sd->getPos().length();
284 >      break;
285 >    default:
286 >      unrecognizedAtomProperty(property);
287 >    }
288 >        
289 >    bool match = false;
290 >    switch (comparator) {
291 >    case Token::opLT:
292 >      match = propertyValue < comparisonValue;
293 >      break;
294 >    case Token::opLE:
295 >      match = propertyValue <= comparisonValue;
296 >      break;
297 >    case Token::opGE:
298 >      match = propertyValue >= comparisonValue;
299 >      break;
300 >    case Token::opGT:
301 >      match = propertyValue > comparisonValue;
302 >      break;
303 >    case Token::opEQ:
304 >      match = propertyValue == comparisonValue;
305 >      break;
306 >    case Token::opNE:
307 >      match = propertyValue != comparisonValue;
308 >      break;
309 >    }
310 >    if (match)
311 >      bs.setBitOn(sd->getGlobalIndex());
312 >    
313 >  }
314  
315 <    Object withinSpec = instruction.value;
316 <    if (withinSpec instanceof Float) {
317 <        withinDistance(((Float)withinSpec).floatValue(), bs, bsResult);
318 <        return;
315 >  void SelectionEvaluator::withinInstruction(const Token& instruction,
316 >                                             OpenMDBitSet& bs){
317 >    
318 >    boost::any withinSpec = instruction.value;
319 >    float distance;
320 >    if (withinSpec.type() == typeid(float)){
321 >      distance = boost::any_cast<float>(withinSpec);
322 >    } else if (withinSpec.type() == typeid(int)) {
323 >      distance = boost::any_cast<int>(withinSpec);    
324 >    } else {
325 >      evalError("casting error in withinInstruction");
326 >      bs.clearAll();
327      }
328 <    evalError("Unrecognized within parameter:" + withinSpec);
329 < }
328 >    
329 >    bs = distanceFinder.find(bs, distance);            
330 >  }
331 >  
332 >  void SelectionEvaluator::define() {
333 >    assert(statement.size() >= 3);
334 >    
335 >    std::string variable = boost::any_cast<std::string>(statement[1].value);
336 >    
337 >    variables.insert(VariablesType::value_type(variable,
338 >                                               expression(statement, 2)));
339 >  }
340 >  
341  
342 <  void SelectionEvaluator::withinDistance(float distance, BitSet bs, BitSet bsResult) {
343 <    Frame frame = viewer.getFrame();
344 <    for (int i = frame.getAtomCount(); --i >= 0; ) {
345 <      if (bs.get(i)) {
346 <        Atom atom = frame.getAtomAt(i);
347 <        AtomIterator iterWithin =
348 <          frame.getWithinIterator(atom, distance);
349 <        while (iterWithin.hasNext())
350 <          bsResult.set(iterWithin.next().getAtomIndex());
342 >  /** @todo */
343 >  void SelectionEvaluator::predefine(const std::string& script) {
344 >    
345 >    if (compiler.compile("#predefine", script)) {
346 >      std::vector<std::vector<Token> > aatoken = compiler.getAatokenCompiled();
347 >      if (aatoken.size() != 1) {
348 >        evalError("predefinition does not have exactly 1 command:"
349 >                  + script);
350 >        return;
351        }
352 +      std::vector<Token> statement = aatoken[0];
353 +      if (statement.size() > 2) {
354 +        int tok = statement[1].tok;
355 +        if (tok == Token::identifier ||
356 +            (tok & Token::predefinedset) == Token::predefinedset) {
357 +          std::string variable = boost::any_cast<std::string>(statement[1].value);
358 +          variables.insert(VariablesType::value_type(variable, statement));
359 +          
360 +        } else {
361 +          evalError("invalid variable name:" + script);
362 +        }
363 +      }else {
364 +        evalError("bad predefinition length:" + script);
365 +      }      
366 +        
367 +    } else {
368 +      evalError("predefined set compile error:" + script +
369 +                "\ncompile error:" + compiler.getErrorMessage());
370      }
371    }
372  
373 <  void SelectionEvaluator::define() throws ScriptException {
374 <    String variable = (String)statement[1].value;
297 <    variables.put(variable, (expression(statement, 2)));
373 >  void SelectionEvaluator::select(OpenMDBitSet& bs){
374 >    bs = expression(statement, 1);
375    }
376 < }
376 >  
377 >  OpenMDBitSet SelectionEvaluator::lookupValue(const std::string& variable){
378 >    
379 >    OpenMDBitSet bs(nStuntDouble);
380 >    std::map<std::string, boost::any>::iterator i = variables.find(variable);
381 >    
382 >    if (i != variables.end()) {
383 >      if (i->second.type() == typeid(OpenMDBitSet)) {
384 >        return boost::any_cast<OpenMDBitSet>(i->second);
385 >      } else if (i->second.type() ==  typeid(std::vector<Token>)){
386 >        bs = expression(boost::any_cast<std::vector<Token> >(i->second), 2);
387 >        i->second =  bs; /**@todo fixme */
388 >        return bs;
389 >      }
390 >    } else {
391 >      unrecognizedIdentifier(variable);
392 >    }
393 >    
394 >    return bs;
395 >  }
396 >  
397 >  OpenMDBitSet SelectionEvaluator::nameInstruction(const std::string& name){    
398 >    return nameFinder.match(name);    
399 >  }    
400  
401 <  void SelectionEvaluator::predefine(Token[] statement) {
402 <    String variable = (String)statement[1].value;
403 <    variables.put(variable, statement);
401 >  bool SelectionEvaluator::containDynamicToken(const std::vector<Token>& tokens){
402 >    std::vector<Token>::const_iterator i;
403 >    for (i = tokens.begin(); i != tokens.end(); ++i) {
404 >      if (i->tok & Token::dynamic) {
405 >        return true;
406 >      }
407 >    }
408 >    
409 >    return false;
410 >  }    
411 >
412 >  void SelectionEvaluator::clearDefinitionsAndLoadPredefined() {
413 >    variables.clear();
414 >    //load predefine
415 >    //predefine();
416    }
417  
418 <  void SelectionEvaluator::select(){
419 <    // NOTE this is called by restrict()
420 <    if (statementLength == 1) {
421 <      viewer.selectAll();
422 <      if (!viewer.getRasmolHydrogenSetting())
311 <        viewer.excludeSelectionSet(getHydrogenSet());
312 <      if (!viewer.getRasmolHeteroSetting())
313 <        viewer.excludeSelectionSet(getHeteroSet());
314 <    } else {
315 <      viewer.setSelectionSet(expression(statement, 1));
418 >  OpenMDBitSet SelectionEvaluator::evaluate() {
419 >    OpenMDBitSet bs(nStuntDouble);
420 >    if (isLoaded_) {
421 >      pc = 0;
422 >      instructionDispatchLoop(bs);
423      }
424 <    viewer.scriptStatus("" + viewer.getSelectionCount() + " atoms selected");
424 >
425 >    return bs;
426    }
427 <  
428 <  }
427 >
428 >  OpenMDBitSet SelectionEvaluator::indexInstruction(const boost::any& value) {
429 >    OpenMDBitSet bs(nStuntDouble);
430 >
431 >    if (value.type() == typeid(int)) {
432 >      int index = boost::any_cast<int>(value);
433 >      if (index < 0 || index >= bs.size()) {
434 >        invalidIndex(index);
435 >      } else {
436 >        bs = indexFinder.find(index);
437 >      }
438 >    } else if (value.type() == typeid(std::pair<int, int>)) {
439 >      std::pair<int, int> indexRange= boost::any_cast<std::pair<int, int> >(value);
440 >      assert(indexRange.first <= indexRange.second);
441 >      if (indexRange.first < 0 || indexRange.second >= bs.size()) {
442 >        invalidIndexRange(indexRange);
443 >      }else {
444 >        bs = indexFinder.find(indexRange.first, indexRange.second);
445 >      }
446 >    }
447 >
448 >    return bs;
449 >  }
450 >
451 >
452 >  OpenMDBitSet SelectionEvaluator::hull() {
453 >    OpenMDBitSet bs(nStuntDouble);
454 >    
455 >    bs = hullFinder.findHull();
456 >    
457 >    return bs;
458 >  }
459 >
460 >
461 >
462 >  RealType SelectionEvaluator::getCharge(Atom* atom) {
463 >    RealType charge =0.0;
464 >    AtomType* atomType = atom->getAtomType();
465 >    if (atomType->isCharge()) {
466 >      GenericData* data = atomType->getPropertyByName("Charge");
467 >      if (data != NULL) {
468 >        DoubleGenericData* doubleData= dynamic_cast<DoubleGenericData*>(data);
469 >
470 >        if (doubleData != NULL) {
471 >          charge = doubleData->getData();
472 >
473 >        } else {
474 >          sprintf( painCave.errMsg,
475 >                   "Can not cast GenericData to DoubleGenericData\n");
476 >          painCave.severity = OPENMD_ERROR;
477 >          painCave.isFatal = 1;
478 >          simError();          
479 >        }
480 >      }
481 >    }
482 >
483 >    return charge;
484 >  }
485 >
486 > }

Comparing:
trunk/src/selection/SelectionEvaluator.cpp (property svn:keywords), Revision 278 by tim, Tue Feb 1 22:49:23 2005 UTC vs.
branches/development/src/selection/SelectionEvaluator.cpp (property svn:keywords), Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines