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 1250 by gezelter, Fri Jun 4 21:00:20 2004 UTC

# Line 25 | Line 25 | int StuntDouble::getObjType(){
25  
26   */
27  
28 + StuntDouble::~StuntDouble(){
29 +  map<string, GenericData*>::iterator iter;
30 +
31 +  for(iter = properties.begin(); iter != properties.end(); ++iter ){
32 +    delete iter->second;
33 +    properties.erase(iter);
34 +  }
35 +    
36 + }
37 +
38   int StuntDouble::getObjType(){
39    return objType;
40   }
# Line 273 | Line 283 | void StuntDouble::getTrq(double trq[3]){
283      }
284   }
285  
286 + void StuntDouble::getQ(double q[4] ){
287 +  switch (objType)
288 +    {
289 +    case OT_ATOM:
290 +      sprintf( painCave.errMsg,
291 +               "StuntDouble::getJ was called for a regular atom.\n"
292 +               "\tRegular Atoms don't have angular momentum.  Be smarter.\n");
293 +      painCave.isFatal = 0;
294 +      simError();
295 +      // Return zeros.
296 +      q[0] = 0;
297 +      q[1] = 0;
298 +      q[2] = 0;
299 +      q[3] = 0;
300 +      break;
301 +    case OT_DATOM:
302 +      ((DirectionalAtom*)this)->getQ(q);
303 +    break;
304 +    case OT_RIGIDBODY:
305 +      ((RigidBody*)this)->getQ(q);
306 +    break;
307 +    default:
308 +      sprintf( painCave.errMsg,
309 +               "Unrecognized ObjType (%d) in StuntDouble::getJ.\n",
310 +               objType );
311 +      painCave.isFatal = 1;
312 +      simError();    
313 +  }
314 + }
315 +
316 + void StuntDouble::setQ(double q[4] ){
317 +  switch (objType)
318 +    {
319 +    case OT_ATOM:
320 +      sprintf( painCave.errMsg,
321 +               "StuntDouble::setJ was called for a regular atom.\n"
322 +               "\tRegular Atoms don't have angular momentum.  Be smarter.\n");
323 +      painCave.isFatal = 1;
324 +      simError();
325 +      break;
326 +    case OT_DATOM:
327 +      ((DirectionalAtom*)this)->setJ(q);
328 +    break;
329 +    case OT_RIGIDBODY:
330 +      ((RigidBody*)this)->setJ(q);
331 +    break;
332 +    default:
333 +      sprintf( painCave.errMsg,
334 +               "Unrecognized ObjType (%d) in StuntDouble::setJ.\n",
335 +               objType );
336 +      painCave.isFatal = 1;
337 +      simError();    
338 +    }
339 + }
340   void StuntDouble::getTrq(double trq[3]){
341    switch (objType)
342      {
# Line 463 | Line 527 | void StuntDouble::getEulerAngles(double eulers[3]){
527      default:
528        sprintf( painCave.errMsg,
529                 "Unrecognized ObjType (%d) in StuntDouble::getEulerAngles.\n",
530 +               objType );
531 +      painCave.isFatal = 1;
532 +      simError();    
533 +  }
534 + }
535 +
536 + double StuntDouble::getZangle(){
537 +  switch (objType)
538 +    {
539 +    case OT_ATOM:
540 +      sprintf( painCave.errMsg,
541 +               "StuntDouble::getZangle was called for a regular atom.\n"
542 +               "\tRegular Atoms don't have zAngles.  Be smarter.\n");
543 +      painCave.isFatal = 0;
544 +      simError();
545 +      // Return zeros.
546 +      return 0;
547 +      break;
548 +    case OT_DATOM:
549 +      return ((DirectionalAtom*)this)->getZangle();
550 +    break;
551 +    case OT_RIGIDBODY:
552 +      return ((RigidBody*)this)->getZangle();
553 +    break;
554 +    default:
555 +      sprintf( painCave.errMsg,
556 +               "Unrecognized ObjType (%d) in StuntDouble::getZangle.\n",
557 +               objType );
558 +      painCave.isFatal = 1;
559 +      simError();    
560 +      return 0;
561 +  }
562 + }
563 +
564 + void StuntDouble::setZangle(double zAngle){
565 +  switch (objType)
566 +    {
567 +    case OT_ATOM:
568 +      sprintf( painCave.errMsg,
569 +               "StuntDouble::setZangle was called for a regular atom.\n"
570 +               "\tRegular Atoms don't have zAngles.  Be smarter.\n");
571 +      painCave.isFatal = 1;
572 +      simError();
573 +      break;
574 +    case OT_DATOM:
575 +      ((DirectionalAtom*)this)->setZangle(zAngle);
576 +    break;
577 +    case OT_RIGIDBODY:
578 +      ((RigidBody*)this)->setZangle(zAngle);
579 +    break;
580 +    default:
581 +      sprintf( painCave.errMsg,
582 +               "Unrecognized ObjType (%d) in StuntDouble::setZangle.\n",
583                 objType );
584        painCave.isFatal = 1;
585        simError();    
586 +    }
587 + }
588 +
589 + void StuntDouble::addZangle(double zAngle){
590 +  switch (objType)
591 +    {
592 +    case OT_ATOM:
593 +      sprintf( painCave.errMsg,
594 +               "StuntDouble::addZangle was called for a regular atom.\n"
595 +               "\tRegular Atoms don't have zAngles.  Be smarter.\n");
596 +      painCave.isFatal = 1;
597 +      simError();
598 +      break;
599 +    case OT_DATOM:
600 +      ((DirectionalAtom*)this)->addZangle(zAngle);
601 +    break;
602 +    case OT_RIGIDBODY:
603 +      ((RigidBody*)this)->addZangle(zAngle);
604 +    break;
605 +    default:
606 +      sprintf( painCave.errMsg,
607 +               "Unrecognized ObjType (%d) in StuntDouble::addZangle.\n",
608 +               objType );
609 +      painCave.isFatal = 1;
610 +      simError();    
611 +    }
612 + }
613 +
614 + void StuntDouble::addProperty(GenericData* data){
615 +  map<string, GenericData*>::iterator result;
616 +  result = properties.find(data->getID());
617 +  
618 +  //we can't simply use  properties[prop->getID()] = prop,
619 +  //it will cause memory leak if we already contain a propery which has the same name of prop
620 +  
621 +  if(result != properties.end()){
622 +    delete (*result).second;
623 +    (*result).second = data;      
624    }
625 +  else
626 +    properties[data->getID()] = data;
627 +
628 +  
629   }
630 + void StuntDouble::removeProperty(const string& propName){
631 +  map<string, GenericData*>::iterator result;
632 +    
633 +  result = properties.find(propName);
634 +  
635 +  if(result != properties.end()){
636 +    delete result->second;
637 +    properties.erase(result);
638 +    
639 +  }
640 +  
641 + }
642 + GenericData* StuntDouble::getProperty(const string& propName){
643 +  map<string, GenericData*>::iterator result;
644 +  
645 +  
646 +  result = properties.find(propName);
647 +  
648 +  if(result != properties.end())
649 +    return (*result).second;  
650 +  else  
651 +    return NULL;    
652 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines