--- trunk/OOPSE/libBASS/MoleculeStamp.cpp 2004/01/26 18:52:42 981 +++ trunk/OOPSE/libBASS/MoleculeStamp.cpp 2004/06/01 21:44:54 1216 @@ -14,6 +14,8 @@ MoleculeStamp::MoleculeStamp(){ n_bends = 0; n_torsions = 0; n_rigidbodies = 0; + n_cutoffgroups = 0; + n_integrable = 0; unhandled = NULL; atoms = NULL; @@ -21,6 +23,7 @@ MoleculeStamp::MoleculeStamp(){ bends = NULL; torsions = NULL; rigidBodies = NULL; + cutoffGroups = NULL; have_name = 0; have_atoms = 0; @@ -28,6 +31,7 @@ MoleculeStamp::MoleculeStamp(){ have_bends = 0; have_torsions = 0; have_rigidbodies = 0; + have_cutoffgroups = 0; } @@ -39,23 +43,36 @@ MoleculeStamp::~MoleculeStamp(){ if( rigidBodies != NULL ) { for( i=0; iadd( lhs, rhs ); @@ -226,7 +258,7 @@ char* MoleculeStamp::assignInt( char* lhs, int rhs ){ if( have_rigidbodies ){ sprintf( errMsg, - "RigidBodyStamp error, n_rigidbodies already declared for" + "MoleculeStamp error, n_rigidbodies already declared for" " molecule: %s\n", name); return strdup( errMsg ); @@ -235,6 +267,20 @@ char* MoleculeStamp::assignInt( char* lhs, int rhs ){ rigidBodies = new RigidBodyStamp*[n_rigidbodies]; for( i=0; iadd( lhs, rhs ); @@ -246,7 +292,7 @@ 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 ); @@ -264,7 +310,7 @@ char* MoleculeStamp::addRigidBody( RigidBodyStamp* the if( have_rigidbodies && rigidBodyIndex < n_rigidbodies ) rigidBodies[rigidBodyIndex] = the_rigidbody; - else{ + else { if( have_rigidbodies ){ sprintf( errMsg, "MoleculeStamp error, %d out of nRigidBodies range", rigidBodyIndex ); @@ -272,6 +318,24 @@ char* MoleculeStamp::addRigidBody( RigidBodyStamp* the } else return strdup("MoleculeStamp error, nRigidBodies not given before" " first rigidBody declaration." ); + } + + return NULL; +} + +char* MoleculeStamp::addCutoffGroup( CutoffGroupStamp* the_cutoffgroup, + int cutoffGroupIndex ){ + + if( have_cutoffgroups && cutoffGroupIndex < n_cutoffgroups ) + cutoffGroups[cutoffGroupIndex] = the_cutoffgroup; + else { + if( have_cutoffgroups ){ + sprintf( errMsg, "MoleculeStamp error, %d out of nCutoffGroups range", + cutoffGroupIndex ); + return strdup( errMsg ); + } + else return strdup("MoleculeStamp error, nCutoffGroups not given before" + " first CutoffGroup declaration." ); } return NULL; @@ -332,18 +396,13 @@ char* MoleculeStamp::checkMe( void ){ char* MoleculeStamp::checkMe( void ){ int i; - short int no_atom, no_rigidbody; + short int no_atom, no_rigidbody, no_cutoffgroup; - // Fix for Rigid Bodies!!! Molecules may not have any atoms that - // they know about. They might have only rigid bodies (which then - // know about the atoms! - - if( !have_name ) return strdup( "MoleculeStamp error. Molecule's name" " was not given.\n" ); - - if( !have_rigidbodies && !have_atoms ){ - return strdup( "MoleculeStamp error. Molecule contains no atoms or RigidBodies." ); + + if( !have_atoms ){ + return strdup( "MoleculeStamp error. Molecule contains no atoms." ); } no_rigidbody = 0; @@ -358,6 +417,18 @@ char* MoleculeStamp::checkMe( void ){ return strdup( errMsg ); } + no_cutoffgroup = 0; + for( i=0; igetNAtoms(); + n_integrable = n_atoms; + for (i = 0; i < n_rigidbodies; i++) + n_integrable = n_integrable - rigidBodies[i]->getNMembers() + 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 total_atoms; -} - + return NULL; +}