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

Comparing trunk/OOPSE/libBASS/MoleculeStamp.cpp (file contents):
Revision 1216 by gezelter, Tue Jun 1 21:44:54 2004 UTC vs.
Revision 1268 by tim, Fri Jun 11 17:16:21 2004 UTC

# Line 454 | Line 454 | char* MoleculeStamp::checkMe( void ){
454  
455    return NULL;
456   }  
457 +
458 +
459 + //Function Name: isBondInSameRigidBody
460 + //Return true is both atoms of the bond belong to the same rigid body, otherwise return false
461 + bool MoleculeStamp::isBondInSameRigidBody(BondStamp* bond){
462 +  int rbA;
463 +  int rbB;
464 +  int consAtomA;
465 +  int consAtomB;
466 +
467 +  if (!isAtomInRigidBody(bond->getA(),rbA, consAtomA))
468 +    return false;
469 +
470 +  if(!isAtomInRigidBody(bond->getB(),rbB, consAtomB) )
471 +    return false;
472 +
473 +  if(rbB == rbA)
474 +    return true;
475 +  else
476 +    return false;
477 + }
478 +
479 +
480 + // Function Name isAtomInRigidBody
481 + //return false if atom does not belong to a rigid body otherwise return true and set whichRigidBody
482 + //and consAtomIndex
483 + //atomIndex : the index of atom in component
484 + //whichRigidBody: the index of rigidbody in component
485 + //consAtomIndex:  the position of joint atom apears in  rigidbody's definition
486 + bool MoleculeStamp::isAtomInRigidBody(int atomIndex, int& whichRigidBody, int& consAtomIndex){
487 +  RigidBodyStamp* rbStamp;
488 +  int numRb;
489 +  int numAtom;
490 +
491 +  numRb = this->getNRigidBodies();
492 +  
493 +  for(int i = 0 ; i < numRb; i++){
494 +    rbStamp = this->getRigidBody(i);
495 +    numAtom = rbStamp->getNMembers();
496 +    for(int j = 0; j < numAtom; j++)
497 +      if (rbStamp->getMember(j) == atomIndex){
498 +        whichRigidBody = i;
499 +        consAtomIndex = j;
500 +        return true;
501 +      }
502 +  }
503 +
504 +  return false;
505 +  
506 + }
507 +
508 + //return the position of joint atom apears in  rigidbody's definition
509 + //for the time being, we will use the most inefficient algorithm, the complexity is O(N2)
510 + //actually we could improve the complexity to O(NlgN) by sorting the atom index in rigid body first
511 + vector<pair<int, int> > MoleculeStamp::getJointAtoms(int rb1, int rb2){
512 +  RigidBodyStamp* rbStamp1;
513 +  RigidBodyStamp* rbStamp2;
514 +  int natomInRb1;
515 +  int natomInRb2;
516 +  int atomIndex1;
517 +  int atomIndex2;
518 +  vector<pair<int, int> > jointAtomIndexPair;
519 +  
520 +  rbStamp1 = this->getRigidBody(rb1);
521 +  natomInRb1 =rbStamp1->getNMembers();
522 +
523 +  rbStamp2 = this->getRigidBody(rb2);
524 +  natomInRb2 =rbStamp2->getNMembers();
525 +
526 +  for(int i = 0; i < natomInRb1; i++){
527 +    atomIndex1 = rbStamp1->getMember(i);
528 +      
529 +    for(int j= 0; j < natomInRb1; j++){
530 +      atomIndex2 = rbStamp2->getMember(j);
531 +
532 +      if(atomIndex1 == atomIndex2){
533 +        jointAtomIndexPair.push_back(make_pair(i, j));
534 +        break;
535 +      }
536 +      
537 +    }//end for(j =0)
538 +
539 +  }//end for (i = 0)
540 +
541 +  return jointAtomIndexPair;
542 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines