--- trunk/OOPSE-4/src/primitives/CutoffGroup.hpp 2005/03/10 23:56:42 2114 +++ trunk/OOPSE-4/src/primitives/CutoffGroup.hpp 2005/04/15 22:04:00 2204 @@ -1,4 +1,4 @@ - /* +/* * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. * * The University of Notre Dame grants you ("Licensee") a @@ -47,91 +47,91 @@ class CutoffGroup { #include "math/Vector3.hpp" namespace oopse { -class CutoffGroup { - public: + class CutoffGroup { + public: - CutoffGroup() { - haveTotalMass = false; - totalMass = 0.0; - } + CutoffGroup() { + haveTotalMass = false; + totalMass = 0.0; + } - void addAtom(Atom *atom) { - cutoffAtomList.push_back(atom); - } + void addAtom(Atom *atom) { + cutoffAtomList.push_back(atom); + } - Atom *beginAtom(std::vector::iterator & i) { - i = cutoffAtomList.begin(); - return i != cutoffAtomList.end() ? *i : NULL; - } + Atom *beginAtom(std::vector::iterator & i) { + i = cutoffAtomList.begin(); + return i != cutoffAtomList.end() ? *i : NULL; + } - Atom *nextAtom(std::vector::iterator & i) { - i++; - return i != cutoffAtomList.end() ? *i : NULL; - } + Atom *nextAtom(std::vector::iterator & i) { + i++; + return i != cutoffAtomList.end() ? *i : NULL; + } - std::vector getAtoms() { return cutoffAtomList; } - double getMass() { - std::vector::iterator i; - Atom * atom; - double mass; + std::vector getAtoms() { return cutoffAtomList; } + double getMass() { + std::vector::iterator i; + Atom * atom; + double mass; - if (!haveTotalMass) { - totalMass = 0; + if (!haveTotalMass) { + totalMass = 0; - for(atom = beginAtom(i); atom != NULL; atom = nextAtom(i)) { - mass = atom->getMass(); - totalMass += mass; - } + for(atom = beginAtom(i); atom != NULL; atom = nextAtom(i)) { + mass = atom->getMass(); + totalMass += mass; + } - haveTotalMass = true; - } + haveTotalMass = true; + } - return totalMass; - } + return totalMass; + } - void getCOM(Vector3d & com) { - std::vector::iterator i; - Atom * atom; - Vector3d pos; - double mass; + void getCOM(Vector3d & com) { + std::vector::iterator i; + Atom * atom; + Vector3d pos; + double mass; - com[0] = 0; - com[1] = 0; - com[2] = 0; - totalMass = getMass(); + com[0] = 0; + com[1] = 0; + com[2] = 0; + totalMass = getMass(); - if (cutoffAtomList.size() == 1) { - com = beginAtom(i)->getPos(); - } else { - for(atom = beginAtom(i); atom != NULL; atom = nextAtom(i)) { - mass = atom->getMass(); - pos = atom->getPos(); - com += pos * mass; - } + if (cutoffAtomList.size() == 1) { + com = beginAtom(i)->getPos(); + } else { + for(atom = beginAtom(i); atom != NULL; atom = nextAtom(i)) { + mass = atom->getMass(); + pos = atom->getPos(); + com += pos * mass; + } - com /= totalMass; - } - } + com /= totalMass; + } + } - int getNumAtom() { - return cutoffAtomList.size(); - } + int getNumAtom() { + return cutoffAtomList.size(); + } - int getGlobalIndex() { - return globalIndex; - } + int getGlobalIndex() { + return globalIndex; + } - void setGlobalIndex(int id) { - this->globalIndex = id; - } + void setGlobalIndex(int id) { + this->globalIndex = id; + } - private: + private: - std::vectorcutoffAtomList; - bool haveTotalMass; - double totalMass; - int globalIndex; -}; + std::vectorcutoffAtomList; + bool haveTotalMass; + double totalMass; + int globalIndex; + }; } //end namespace oopse