--- trunk/OOPSE/libBASS/MoleculeStamp.cpp 2004/01/27 19:37:48 988 +++ 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 ); @@ -277,6 +323,24 @@ char* MoleculeStamp::addBond( BondStamp* the_bond, int 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; +} + char* MoleculeStamp::addBond( BondStamp* the_bond, int bondIndex ){ @@ -332,7 +396,7 @@ char* MoleculeStamp::checkMe( void ){ char* MoleculeStamp::checkMe( void ){ int i; - short int no_atom, no_rigidbody; + short int no_atom, no_rigidbody, no_cutoffgroup; if( !have_name ) return strdup( "MoleculeStamp error. Molecule's name" " was not given.\n" ); @@ -353,6 +417,18 @@ char* MoleculeStamp::checkMe( void ){ return strdup( errMsg ); } + no_cutoffgroup = 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; }