ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/StuntDouble.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/StuntDouble.cpp (file contents):
Revision 1097 by gezelter, Mon Apr 12 20:32:20 2004 UTC vs.
Revision 1118 by tim, Mon Apr 19 03:52:27 2004 UTC

# Line 273 | Line 273 | void StuntDouble::getTrq(double trq[3]){
273      }
274   }
275  
276 + void StuntDouble::getQ(double q[4] ){
277 +  switch (objType)
278 +    {
279 +    case OT_ATOM:
280 +      sprintf( painCave.errMsg,
281 +               "StuntDouble::getJ was called for a regular atom.\n"
282 +               "\tRegular Atoms don't have angular momentum.  Be smarter.\n");
283 +      painCave.isFatal = 0;
284 +      simError();
285 +      // Return zeros.
286 +      q[0] = 0;
287 +      q[1] = 0;
288 +      q[2] = 0;
289 +      q[3] = 0;
290 +      break;
291 +    case OT_DATOM:
292 +      ((DirectionalAtom*)this)->getQ(q);
293 +    break;
294 +    case OT_RIGIDBODY:
295 +      ((RigidBody*)this)->getQ(q);
296 +    break;
297 +    default:
298 +      sprintf( painCave.errMsg,
299 +               "Unrecognized ObjType (%d) in StuntDouble::getJ.\n",
300 +               objType );
301 +      painCave.isFatal = 1;
302 +      simError();    
303 +  }
304 + }
305 +
306 + void StuntDouble::setQ(double q[4] ){
307 +  switch (objType)
308 +    {
309 +    case OT_ATOM:
310 +      sprintf( painCave.errMsg,
311 +               "StuntDouble::setJ was called for a regular atom.\n"
312 +               "\tRegular Atoms don't have angular momentum.  Be smarter.\n");
313 +      painCave.isFatal = 1;
314 +      simError();
315 +      break;
316 +    case OT_DATOM:
317 +      ((DirectionalAtom*)this)->setJ(q);
318 +    break;
319 +    case OT_RIGIDBODY:
320 +      ((RigidBody*)this)->setJ(q);
321 +    break;
322 +    default:
323 +      sprintf( painCave.errMsg,
324 +               "Unrecognized ObjType (%d) in StuntDouble::setJ.\n",
325 +               objType );
326 +      painCave.isFatal = 1;
327 +      simError();    
328 +    }
329 + }
330   void StuntDouble::getTrq(double trq[3]){
331    switch (objType)
332      {
# Line 468 | Line 522 | void StuntDouble::getEulerAngles(double eulers[3]){
522        simError();    
523    }
524   }
525 +
526 + void StuntDouble::addProperty(GenericData* data){
527 +  map<string, GenericData*>::iterator result;
528 +  result = properties.find(data->getID());
529 +  
530 +  //we can't simply use  properties[prop->getID()] = prop,
531 +  //it will cause memory leak if we already contain a propery which has the same name of prop
532 +  
533 +  if(result != properties.end()){
534 +    delete (*result).second;
535 +    (*result).second = data;      
536 +  }
537 +  else
538 +    properties[data->getID()] = data;
539 +
540 +  
541 + }
542 + void StuntDouble::removeProperty(const string& propName){
543 +  map<string, GenericData*>::iterator result;
544 +    
545 +  result = properties.find(propName);
546 +  
547 +  if(result != properties.end())
548 +    properties.erase(result);
549 +  
550 + }
551 + GenericData* StuntDouble::getProperty(const string& propName){
552 +  map<string, GenericData*>::iterator result;
553 +  
554 +  
555 +  result = properties.find(propName);
556 +  
557 +  if(result != properties.end())
558 +    return (*result).second;  
559 +  else  
560 +    return NULL;    
561 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines