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 1256 by gezelter, Thu Jun 10 14:59:14 2004 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines