| 1 | tim | 1615 | /* | 
| 2 |  |  | * Copyright (C) 2000-2004  Object Oriented Parallel Simulation Engine (OOPSE) project | 
| 3 |  |  | * | 
| 4 |  |  | * Contact: oopse@oopse.org | 
| 5 |  |  | * | 
| 6 |  |  | * This program is free software; you can redistribute it and/or | 
| 7 |  |  | * modify it under the terms of the GNU Lesser General Public License | 
| 8 |  |  | * as published by the Free Software Foundation; either version 2.1 | 
| 9 |  |  | * of the License, or (at your option) any later version. | 
| 10 |  |  | * All we ask is that proper credit is given for our work, which includes | 
| 11 |  |  | * - but is not limited to - adding the above copyright notice to the beginning | 
| 12 |  |  | * of your source code files, and to any copyright notice that you may distribute | 
| 13 |  |  | * with programs based on this work. | 
| 14 |  |  | * | 
| 15 |  |  | * This program is distributed in the hope that it will be useful, | 
| 16 |  |  | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 17 |  |  | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| 18 |  |  | * GNU Lesser General Public License for more details. | 
| 19 |  |  | * | 
| 20 |  |  | * You should have received a copy of the GNU Lesser General Public License | 
| 21 |  |  | * along with this program; if not, write to the Free Software | 
| 22 |  |  | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. | 
| 23 |  |  | * | 
| 24 |  |  | */ | 
| 25 |  |  |  | 
| 26 |  |  | /** | 
| 27 |  |  | * @file Snapshot.hpp | 
| 28 |  |  | * @author tlin | 
| 29 |  |  | * @date 10/20/2004 | 
| 30 |  |  | * @time 23:56am | 
| 31 |  |  | * @version 1.0 | 
| 32 |  |  | */ | 
| 33 | tim | 1639 |  | 
| 34 | tim | 1615 | #ifndef BRAINS_SNAPSHOT_HPP | 
| 35 |  |  | #define BRAINS_SNAPSHOT_HPP | 
| 36 | tim | 1630 |  | 
| 37 |  |  | #include <vector> | 
| 38 |  |  |  | 
| 39 | tim | 1648 | #include "brains/DataStorage.hpp" | 
| 40 | tim | 1630 |  | 
| 41 |  |  | using namespace std; | 
| 42 |  |  |  | 
| 43 | tim | 1615 | namespace oopse{ | 
| 44 |  |  |  | 
| 45 | tim | 1642 | class StuntDouble; | 
| 46 |  |  |  | 
| 47 | tim | 1615 | /** | 
| 48 |  |  | * @class Snapshot Snapshot.hpp "brains/Snapshot.hpp" | 
| 49 |  |  | * @brief Snapshot class is a repository class for storing dynamic data during | 
| 50 |  |  | *  Simulation | 
| 51 | tim | 1639 | * Every snapshot class will contain one DataStorage  for atoms and one DataStorage | 
| 52 |  |  | *  for rigid bodies. | 
| 53 | tim | 1615 | * @see SimData | 
| 54 |  |  | */ | 
| 55 |  |  | class Snapshot { | 
| 56 |  |  | public: | 
| 57 | tim | 1639 |  | 
| 58 | tim | 1642 | Snapshot(int nAtoms, int nRigidbodies) { | 
| 59 |  |  | atomData.resize(nAtoms); | 
| 60 |  |  | rigidbodyData.resize(nRigidbodies); | 
| 61 | tim | 1630 | } | 
| 62 |  |  |  | 
| 63 |  |  | Snapshot(const Snapshot& s); | 
| 64 |  |  |  | 
| 65 |  |  | Snapshot& operator =(const Snapshot& s); | 
| 66 | tim | 1615 |  | 
| 67 | tim | 1630 | /** Returns the id of this Snapshot */ | 
| 68 |  |  | int getID() { | 
| 69 |  |  | return id_; | 
| 70 |  |  | } | 
| 71 |  |  |  | 
| 72 |  |  | /** Sets the id of this Snapshot */ | 
| 73 |  |  | void setID(int id) { | 
| 74 |  |  | id_ = id; | 
| 75 |  |  | } | 
| 76 |  |  |  | 
| 77 |  |  | //template<typename T> | 
| 78 |  |  | //static typename T::ElemPointerType getArrayPointer(vector<T>& v) { | 
| 79 |  |  | //    return v[0]->getArrayPointer(); | 
| 80 |  |  | //} | 
| 81 |  |  |  | 
| 82 | tim | 1642 | int getSize() { | 
| 83 | tim | 1648 | return atomData.getSize() + rigidbodyData.getSize(); | 
| 84 | tim | 1642 | } | 
| 85 | tim | 1645 |  | 
| 86 |  |  | /** Returns the number of atoms */ | 
| 87 |  |  | int getNumberOfAtoms() { | 
| 88 | tim | 1648 | return atomData.getSize(); | 
| 89 | tim | 1642 | } | 
| 90 | tim | 1645 |  | 
| 91 |  |  | /** Returns the number of rigid bodies */ | 
| 92 |  |  | int getNumberOfRigidBodies() { | 
| 93 | tim | 1648 | return rigidbodyData.getSize(); | 
| 94 | tim | 1642 | } | 
| 95 | tim | 1645 |  | 
| 96 |  |  | /** Returns the H-Matrix */ | 
| 97 |  |  | Mat3x3d getHmat() { | 
| 98 |  |  | return hmat_; | 
| 99 |  |  | } | 
| 100 |  |  |  | 
| 101 |  |  | /** Sets the H-Matrix */ | 
| 102 |  |  | void setHamt(const Mat3x3d& m) { | 
| 103 |  |  | hmat_ = m; | 
| 104 |  |  | invHmat_ = hmat_.inverse(); | 
| 105 |  |  | } | 
| 106 |  |  |  | 
| 107 |  |  | /** Returns the inverse H-Matrix */ | 
| 108 |  |  | Mat3x3d getInvHmat() { | 
| 109 |  |  | return invHmat_ | 
| 110 |  |  | } | 
| 111 |  |  |  | 
| 112 |  |  | double getTimeStamp() { | 
| 113 |  |  | return timeStamp_; | 
| 114 |  |  | } | 
| 115 |  |  |  | 
| 116 |  |  | void setTimeStamp(double timeStamp) { | 
| 117 |  |  | timeStamp_ =timeStamp; | 
| 118 |  |  | } | 
| 119 |  |  |  | 
| 120 |  |  |  | 
| 121 | tim | 1639 | DataStorage atomData; | 
| 122 |  |  | DataStorage rigidbodyData; | 
| 123 | tim | 1645 |  | 
| 124 | tim | 1642 | friend class StuntDouble; | 
| 125 | tim | 1645 |  | 
| 126 | tim | 1615 | private: | 
| 127 | tim | 1645 | double timeStamp_; | 
| 128 |  |  | Mat3x3d hmat_; | 
| 129 |  |  | Mat3x3d invHmat_; | 
| 130 | tim | 1630 | int id_; /**< identification number of the snapshot */ | 
| 131 | tim | 1615 | }; | 
| 132 |  |  |  | 
| 133 | tim | 1642 | typedef DataStorage (Snapshot::*DataStoragePointer); | 
| 134 | tim | 1615 | } | 
| 135 |  |  | #endif //BRAINS_SNAPSHOT_HPP |