--- trunk/OOPSE/libBASS/MoleculeStamp.cpp 2003/10/28 16:03:06 828 +++ trunk/OOPSE/libBASS/MoleculeStamp.cpp 2004/04/15 16:18:26 1113 @@ -13,18 +13,22 @@ MoleculeStamp::MoleculeStamp(){ n_bonds = 0; n_bends = 0; n_torsions = 0; + n_rigidbodies = 0; + n_integrable = 0; unhandled = NULL; atoms = NULL; bonds = NULL; bends = NULL; torsions = NULL; + rigidBodies = NULL; have_name = 0; have_atoms = 0; have_bonds = 0; have_bends = 0; have_torsions = 0; + have_rigidbodies = 0; } @@ -32,7 +36,11 @@ MoleculeStamp::~MoleculeStamp(){ int i; if( unhandled != NULL) delete unhandled; - + + if( rigidBodies != NULL ) { + for( i=0; iadd( lhs, rhs ); @@ -197,6 +221,21 @@ char* MoleculeStamp::assignInt( char* lhs, int rhs ){ torsions = new TorsionStamp*[n_torsions]; for( i=0; iadd( lhs, rhs ); @@ -208,16 +247,34 @@ char* MoleculeStamp::addAtom( AtomStamp* the_atom, int char* MoleculeStamp::addAtom( AtomStamp* the_atom, int atomIndex ){ if( have_atoms && atomIndex < n_atoms ) atoms[atomIndex] = the_atom; - else{ + else { if( have_atoms ){ sprintf( errMsg, "MoleculeStamp error, %d out of nAtoms range", atomIndex ); return strdup( errMsg ); } else return strdup("MoleculeStamp error, nAtoms not given before" - "first atom declaration." ); + " first atom declaration." ); } + return NULL; +} + +char* MoleculeStamp::addRigidBody( RigidBodyStamp* the_rigidbody, + int rigidBodyIndex ){ + + if( have_rigidbodies && rigidBodyIndex < n_rigidbodies ) + rigidBodies[rigidBodyIndex] = the_rigidbody; + else { + if( have_rigidbodies ){ + sprintf( errMsg, "MoleculeStamp error, %d out of nRigidBodies range", + rigidBodyIndex ); + return strdup( errMsg ); + } + else return strdup("MoleculeStamp error, nRigidBodies not given before" + " first rigidBody declaration." ); + } + return NULL; } @@ -276,14 +333,27 @@ char* MoleculeStamp::checkMe( void ){ char* MoleculeStamp::checkMe( void ){ int i; - short int no_atom; + short int no_atom, no_rigidbody; + + if( !have_name ) return strdup( "MoleculeStamp error. Molecule's name" + " was not given.\n" ); - if( !have_name || !have_atoms ){ - if( !have_name ) return strdup( "MoleculeStamp error. Molecule's name" - " was not given.\n" ); - else return strdup( "MoleculeStamp error. Molecule contains no atoms." ); + if( !have_atoms ){ + return strdup( "MoleculeStamp error. Molecule contains no atoms." ); } + no_rigidbody = 0; + for( i=0; igetNMembers() + 1; //rigidbody is an integrable object + + if (n_integrable <= 0 || n_integrable > n_atoms) { + sprintf( errMsg, + "MoleculeStamp error. n_integrable is either <= 0 or" + " greater than n_atoms in molecule \"%s\".\n", name ); + return strdup( errMsg ); + } + return NULL; -} +}