ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/primitives/StuntDouble.hpp
(Generate patch)

Comparing trunk/OOPSE-2.0/src/primitives/StuntDouble.hpp (file contents):
Revision 1492 by tim, Fri Sep 24 16:27:58 2004 UTC vs.
Revision 2204 by gezelter, Fri Apr 15 22:04:00 2005 UTC

# Line 1 | Line 1
1 < #ifndef __STUNTDOUBLE_HPP__
2 < #define __STUNTDOUBLE_HPP__
1 > /*
2 > * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3 > *
4 > * The University of Notre Dame grants you ("Licensee") a
5 > * non-exclusive, royalty free, license to use, modify and
6 > * redistribute this software in source and binary code form, provided
7 > * that the following conditions are met:
8 > *
9 > * 1. Acknowledgement of the program authors must be made in any
10 > *    publication of scientific results based in part on use of the
11 > *    program.  An acceptable form of acknowledgement is citation of
12 > *    the article in which the program was described (Matthew
13 > *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 > *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 > *    Parallel Simulation Engine for Molecular Dynamics,"
16 > *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 > *
18 > * 2. Redistributions of source code must retain the above copyright
19 > *    notice, this list of conditions and the following disclaimer.
20 > *
21 > * 3. Redistributions in binary form must reproduce the above copyright
22 > *    notice, this list of conditions and the following disclaimer in the
23 > *    documentation and/or other materials provided with the
24 > *    distribution.
25 > *
26 > * This software is provided "AS IS," without a warranty of any
27 > * kind. All express or implied conditions, representations and
28 > * warranties, including any implied warranty of merchantability,
29 > * fitness for a particular purpose or non-infringement, are hereby
30 > * excluded.  The University of Notre Dame and its licensors shall not
31 > * be liable for any damages suffered by licensee as a result of
32 > * using, modifying or distributing the software or its
33 > * derivatives. In no event will the University of Notre Dame or its
34 > * licensors be liable for any lost revenue, profit or data, or for
35 > * direct, indirect, special, consequential, incidental or punitive
36 > * damages, however caused and regardless of the theory of liability,
37 > * arising out of the use of or inability to use software, even if the
38 > * University of Notre Dame has been advised of the possibility of
39 > * such damages.
40 > */
41 >
42 > /**
43 > * @file StuntDouble.hpp
44 > * @author    tlin
45 > * @date  10/22/2004
46 > * @version 1.0
47 > */
48 >  
49 > #ifndef PRIMITIVES_STUNTDOUBLE_HPP
50 > #define PRIMITIVES_STUNTDOUBLE_HPP
51  
52 < #include <map>
5 < #include "utils/GenericData.hpp"
52 > #include <vector>
53  
54 < #define OT_ATOM 0
55 < #define OT_DATOM 1
56 < #define OT_RIGIDBODY 2
54 > #include "visitors/BaseVisitor.hpp"
55 > #include "math/Quaternion.hpp"
56 > #include "math/SquareMatrix3.hpp"
57 > #include "math/Vector3.hpp"
58 > #include "utils/PropertyMap.hpp"
59 > #include "brains/Snapshot.hpp"
60 > #include "brains/SnapshotManager.hpp"
61 > namespace oopse{
62  
11 using namespace std;
12 class BaseVisitor;
63  
64 < class StuntDouble {
65 < public:
66 <  virtual ~StuntDouble();
67 <  
68 <  int getObjType();
69 <  
70 <  bool isAtom(){
71 <    return objType == OT_ATOM || objType == OT_DATOM;
72 <  }
64 >  
65 >  /**
66 >   * @class StuntDouble StuntDouble.hpp "Primitives/StuntDouble.hpp"
67 >   * @brief
68 >   * StuntDouble is a very strange idea.  A StuntDouble stands in for
69 >   * some object that can be manipulated by the Integrators or
70 >   * Minimizers.  Some of the manipulable objects are Atoms, some are
71 >   * DirectionalAtoms, and some are RigidBodies.  StuntDouble
72 >   * provides an interface for the Integrators and Minimizers to use,
73 >   * and does some preliminary sanity checking so that the program
74 >   * doesn't try to do something stupid like torque an Atom
75 >   * @note the dynamic data of stuntdouble will be stored outside of the class
76 >   */
77 >  class StuntDouble{
78 >  public:    
79  
80 <  bool isDirectionalAtom(){
81 <    return objType == OT_DATOM;
82 <  }
80 >    enum ObjectType{
81 >      otAtom,
82 >      otDAtom,
83 >      otRigidBody
84 >    };
85  
86 <  bool isRigidBody(){
87 <    return objType == OT_RIGIDBODY;
88 <  }
86 >    virtual ~StuntDouble();
87 >        
88 >    /**
89 >     * Returns the global index of this stuntdouble.
90 >     * @return  the global index of this stuntdouble
91 >     */
92 >    int getGlobalIndex() {
93 >      return globalIndex_;
94 >    }
95  
96 <  bool isDirectional(){
97 <    return isDirectionalAtom() || isRigidBody();
98 <  }
96 >    /**
97 >     * Sets the global index of this stuntdouble.
98 >     * @param new global index to be set
99 >     */
100 >    void setGlobalIndex(int index) {
101 >      globalIndex_ = index;
102 >    }
103 >        
104 >    /**
105 >     * Returns the local index of this stuntdouble
106 >     * @return the local index of this stuntdouble
107 >     */
108 >    int getLocalIndex() {
109 >      return localIndex_;
110 >    }
111  
112 <  virtual double getMass(void);
113 <  
114 <  virtual void   getPos(double pos[3]);
115 <  virtual void   setPos(double pos[3]);
116 <  
117 <  virtual void   getVel(double vel[3]);
118 <  virtual void   setVel(double vel[3]);
43 <  
44 <  virtual void   getFrc(double frc[3]);
45 <  virtual void   addFrc(double frc[3]);
112 >    /**
113 >     * Sets the local index of this stuntdouble
114 >     * @param index new index to be set
115 >     */        
116 >    void setLocalIndex(int index) {
117 >      localIndex_ = index;
118 >    }
119  
120 <  virtual void   getA(double A[3][3]);
121 <  virtual void   setA(double A[3][3]);
120 >    /**
121 >     * Sets the Snapshot Manager of this stuntdouble
122 >     */
123 >    void setSnapshotManager(SnapshotManager* sman) {
124 >      snapshotMan_ = sman;
125 >    }
126  
127 <  virtual void   getJ(double j[3]);
128 <  virtual void   setJ(double j[3]);
127 >    /**
128 >     * Tests if this stuntdouble is an atom
129 >     * @return true is this stuntdouble is an atom(or a directional atom), return false otherwise
130 >     */
131 >    bool isAtom(){
132 >      return objType_ == otAtom || objType_ == otDAtom;
133 >    }
134  
135 <  virtual void getQ( double q[4] ); // get the quanternions
136 <  virtual void setQ( double q[4] );
135 >    /**
136 >     * Tests if this stuntdouble is an directional atom
137 >     * @return true if this stuntdouble is an directional atom, return false otherwise
138 >     */
139 >    bool isDirectionalAtom(){
140 >      return objType_ == otDAtom;
141 >    }
142  
143 <  virtual void setType(char* type) = 0;
144 <  virtual char* getType() = 0;
145 <  
143 >    /**
144 >     * Tests if this stuntdouble is a rigid body.
145 >     * @return true if this stuntdouble is a rigid body, otherwise return false
146 >     */
147 >    bool isRigidBody(){
148 >      return objType_ == otRigidBody;
149 >    }
150  
151 <  virtual void   getTrq(double trq[3]);
152 <  virtual void   addTrq(double trq[3]);
151 >    /**
152 >     * Tests if this stuntdouble is a directional one.
153 >     * @return true is this stuntdouble is a directional atom or a rigid body, return false otherwise
154 >     */
155 >    bool isDirectional(){
156 >      return isDirectionalAtom() || isRigidBody();
157 >    }
158  
159 <  virtual void   getI(double I[3][3]);
160 <  virtual void   lab2Body(double vec[3]);
159 >    /**
160 >     * Returns the previous position of this stuntdouble
161 >     * @return the position of this stuntdouble
162 >     */    
163 >    Vector3d getPrevPos() {
164 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).position[localIndex_];
165 >    }
166 >      
167 >    /**
168 >     * Returns the current position of this stuntdouble
169 >     * @return the position of this stuntdouble
170 >     */    
171 >    Vector3d getPos() {
172 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).position[localIndex_];
173 >    }
174  
175 <  virtual void   getGrad(double grad[6]);
176 <  virtual void   setEuler(double phi, double theta, double psi);
177 <  virtual void   getEulerAngles(double eulers[3]);
175 >    /**
176 >     * Returns the position of this stuntdouble in specified snapshot
177 >     * @return the position of this stuntdouble
178 >     * @param snapshotNo
179 >     */    
180 >    Vector3d getPos(int snapshotNo) {
181 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).position[localIndex_];
182 >    }
183  
184 <  virtual bool isLinear() {return false;}
185 <  virtual int linearAxis() {return -1;}
184 >    /**
185 >     * Sets  the previous position of this stuntdouble
186 >     * @param pos  new position
187 >     * @see #getPos
188 >     */        
189 >    void setPrevPos(const Vector3d& pos) {
190 >      ((snapshotMan_->getPrevSnapshot())->*storage_).position[localIndex_] = pos;
191 >    }
192 >      
193 >    /**
194 >     * Sets  the current position of this stuntdouble
195 >     * @param pos  new position
196 >     */        
197 >    void setPos(const Vector3d& pos) {
198 >      DataStorage&  data = snapshotMan_->getCurrentSnapshot()->*storage_;
199 >      data.position[localIndex_] = pos;
200 >      //((snapshotMan_->getCurrentSnapshot())->*storage_).position[localIndex_] = pos;
201 >    }
202  
203 <  virtual double   getZangle();
204 <  virtual void   setZangle(double zAngle);
205 <  virtual void   addZangle(double zAngle);
206 <
207 <  virtual void accept(BaseVisitor* v) = 0;
203 >    /**
204 >     * Sets  the position of this stuntdouble in specified snapshot
205 >     * @param pos position to be set
206 >     * @param snapshotNo
207 >     * @see #getPos
208 >     */        
209 >    void setPos(const Vector3d& pos, int snapshotNo) {
210  
211 <  void addProperty(GenericData* data);
80 <  void removeProperty(const string& propName);
81 <  GenericData* getProperty(const string& propName);
82 <  
83 < protected:
84 <  StuntDouble(){}
211 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).position[localIndex_] = pos;
212  
213 <  //prevent default copy constructor copy information from properties which will cause problem
214 <  StuntDouble(const StuntDouble& sd){
215 <    objType = sd.objType;
216 <  }
217 <  
218 <  int objType;
213 >    }
214 >      
215 >    /**
216 >     * Returns the previous velocity of this stuntdouble
217 >     * @return the velocity of this stuntdouble
218 >     */    
219 >    Vector3d getPrevVel() {
220 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).velocity[localIndex_];
221 >    }
222 >      
223 >    /**
224 >     * Returns the current velocity of this stuntdouble
225 >     * @return the velocity of this stuntdouble
226 >     */    
227 >    Vector3d getVel() {
228 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).velocity[localIndex_];
229 >    }
230  
231 <  map<string, GenericData*> properties;
232 < };
231 >    /**
232 >     * Returns the velocity of this stuntdouble in specified snapshot
233 >     * @return the velocity of this stuntdouble
234 >     * @param snapshotNo
235 >     */    
236 >    Vector3d getVel(int snapshotNo) {
237 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).velocity[localIndex_];
238 >    }
239  
240 < #endif
240 >    /**
241 >     * Sets  the previous velocity of this stuntdouble
242 >     * @param vel  new velocity
243 >     * @see #getVel
244 >     */        
245 >    void setPrevVel(const Vector3d& vel) {
246 >      ((snapshotMan_->getPrevSnapshot())->*storage_).velocity[localIndex_] = vel;
247 >    }
248 >      
249 >    /**
250 >     * Sets  the current velocity of this stuntdouble
251 >     * @param vel  new velocity
252 >     */        
253 >    void setVel(const Vector3d& vel) {
254 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).velocity[localIndex_] = vel;
255 >    }
256 >
257 >    /**
258 >     * Sets  the velocity of this stuntdouble in specified snapshot
259 >     * @param vel velocity to be set
260 >     * @param snapshotNo
261 >     * @see #getVel
262 >     */        
263 >    void setVel(const Vector3d& vel, int snapshotNo) {
264 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).velocity[localIndex_] = vel;
265 >    }
266 >
267 >    /**
268 >     * Returns the previous rotation matrix of this stuntdouble
269 >     * @return the rotation matrix of this stuntdouble
270 >     */    
271 >    RotMat3x3d getPrevA() {
272 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_];
273 >    }
274 >      
275 >    /**
276 >     * Returns the current rotation matrix of this stuntdouble
277 >     * @return the rotation matrix of this stuntdouble
278 >     */    
279 >    RotMat3x3d getA() {
280 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_];
281 >    }
282 >
283 >    /**
284 >     * Returns the rotation matrix of this stuntdouble in specified snapshot
285 >     *
286 >     * @return the rotation matrix of this stuntdouble
287 >     * @param snapshotNo
288 >     */    
289 >    RotMat3x3d getA(int snapshotNo) {
290 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_];
291 >    }
292 >
293 >    /**
294 >     * Sets  the previous rotation matrix of this stuntdouble
295 >     * @param a  new rotation matrix
296 >     * @see #getA
297 >     */        
298 >    virtual void setPrevA(const RotMat3x3d& a) {
299 >      ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_] = a;
300 >    }
301 >      
302 >    /**
303 >     * Sets  the current rotation matrix of this stuntdouble
304 >     * @param a  new rotation matrix
305 >     */        
306 >    virtual void setA(const RotMat3x3d& a) {
307 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_] = a;
308 >    }
309 >
310 >    /**
311 >     * Sets  the rotation matrix of this stuntdouble in specified snapshot
312 >     * @param a rotation matrix to be set
313 >     * @param snapshotNo
314 >     * @see #getA
315 >     */        
316 >    virtual void setA(const RotMat3x3d& a, int snapshotNo) {
317 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_] = a;
318 >    }      
319 >
320 >    /**
321 >     * Returns the previous angular momentum of this stuntdouble (body-fixed).
322 >     * @return the angular momentum of this stuntdouble
323 >     */    
324 >    Vector3d getPrevJ() {
325 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).angularMomentum[localIndex_];
326 >    }
327 >      
328 >    /**
329 >     * Returns the current angular momentum of this stuntdouble (body -fixed).
330 >     * @return the angular momentum of this stuntdouble
331 >     */    
332 >    Vector3d getJ() {
333 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).angularMomentum[localIndex_];
334 >    }
335 >
336 >    /**
337 >     * Returns the angular momentum of this stuntdouble in specified snapshot (body-fixed).
338 >     * @return the angular momentum of this stuntdouble
339 >     * @param snapshotNo
340 >     */    
341 >    Vector3d getJ(int snapshotNo) {
342 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).angularMomentum[localIndex_];
343 >    }
344 >
345 >    /**
346 >     * Sets  the previous angular momentum of this stuntdouble (body-fixed).
347 >     * @param angMom  new angular momentum
348 >     * @see #getJ
349 >     */        
350 >    void setPrevJ(const Vector3d& angMom) {
351 >      ((snapshotMan_->getPrevSnapshot())->*storage_).angularMomentum[localIndex_] = angMom;
352 >    }
353 >      
354 >    /**
355 >     * Sets  the current angular momentum of this stuntdouble (body-fixed).
356 >     * @param angMom  new angular momentum
357 >     */        
358 >    void setJ(const Vector3d& angMom) {
359 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).angularMomentum[localIndex_] = angMom;
360 >    }
361 >
362 >    /**
363 >     * Sets the angular momentum of this stuntdouble in specified snapshot(body-fixed).
364 >     * @param angMom angular momentum to be set
365 >     * @param snapshotNo
366 >     * @see #getJ
367 >     */        
368 >    void setJ(const Vector3d& angMom, int snapshotNo) {
369 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).angularMomentum[localIndex_] = angMom;
370 >    }
371 >        
372 >    /**
373 >     * Returns the previous quaternion of this stuntdouble
374 >     * @return the quaternion of this stuntdouble
375 >     */    
376 >    Quat4d getPrevQ() {
377 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_].toQuaternion();
378 >    }
379 >      
380 >    /**
381 >     * Returns the current quaternion of this stuntdouble
382 >     * @return the quaternion of this stuntdouble
383 >     */    
384 >    Quat4d getQ() {
385 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_].toQuaternion();
386 >    }
387 >
388 >    /**
389 >     * Returns the quaternion of this stuntdouble in specified snapshot
390 >     * @return the quaternion of this stuntdouble
391 >     * @param snapshotNo
392 >     */    
393 >    Quat4d getQ(int snapshotNo) {
394 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_].toQuaternion();
395 >    }
396 >
397 >    /**
398 >     * Sets  the previous quaternion of this stuntdouble
399 >     * @param q  new quaternion
400 >     * @note actual storage data is rotation matrix
401 >     */        
402 >    void setPrevQ(const Quat4d& q) {
403 >      setPrevA(q);
404 >    }
405 >      
406 >    /**
407 >     * Sets  the current quaternion of this stuntdouble
408 >     * @param q  new quaternion
409 >     * @note actual storage data is rotation matrix
410 >     */        
411 >    void setQ(const Quat4d& q) {
412 >      setA(q);
413 >    }
414 >
415 >    /**
416 >     * Sets  the quaternion of this stuntdouble in specified snapshot
417 >     *
418 >     * @param q quaternion to be set
419 >     * @param snapshotNo
420 >     * @note actual storage data is rotation matrix
421 >     */        
422 >    void setQ(const Quat4d& q, int snapshotNo) {
423 >      setA(q, snapshotNo);
424 >    }
425 >
426 >    /**
427 >     * Returns the previous euler angles of this stuntdouble
428 >     * @return the euler angles of this stuntdouble
429 >     */    
430 >    Vector3d getPrevEuler() {
431 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_].toEulerAngles();
432 >    }
433 >      
434 >    /**
435 >     * Returns the current euler angles of this stuntdouble
436 >     * @return the euler angles of this stuntdouble
437 >     */    
438 >    Vector3d getEuler() {
439 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_].toEulerAngles();
440 >    }
441 >
442 >    /**
443 >     * Returns the euler angles of this stuntdouble in specified snapshot.
444 >     * @return the euler angles of this stuntdouble
445 >     * @param snapshotNo
446 >     */    
447 >    Vector3d getEuler(int snapshotNo) {
448 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_].toEulerAngles();
449 >    }
450 >
451 >    /**
452 >     * Sets  the previous euler angles of this stuntdouble.
453 >     * @param euler  new euler angles
454 >     * @see #getEuler
455 >     * @note actual storage data is rotation matrix        
456 >     */        
457 >    void setPrevEuler(const Vector3d& euler) {
458 >      ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_] = euler;
459 >    }
460 >      
461 >    /**
462 >     * Sets  the current euler angles of this stuntdouble
463 >     * @param euler  new euler angles
464 >     */        
465 >    void setEuler(const Vector3d& euler) {
466 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_] = euler;
467 >    }
468 >
469 >    /**
470 >     * Sets  the euler angles  of this stuntdouble in specified snapshot
471 >     *
472 >     * @param euler euler angles to be set
473 >     * @param snapshotNo
474 >     * @note actual storage data is rotation matrix                  
475 >     */        
476 >    void setEuler(const Vector3d& euler, int snapshotNo) {
477 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_] = euler;
478 >    }
479 >      
480 >    /**
481 >     * Returns the previous unit vectors of this stuntdouble
482 >     * @return the unit vectors of this stuntdouble
483 >     */    
484 >    RotMat3x3d getPrevElectroFrame() {
485 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).electroFrame[localIndex_];
486 >    }
487 >      
488 >    /**
489 >     * Returns the current unit vectors of this stuntdouble
490 >     * @return the unit vectors of this stuntdouble
491 >     */    
492 >    RotMat3x3d getElectroFrame() {
493 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).electroFrame[localIndex_];
494 >    }
495 >
496 >    /**
497 >     * Returns the unit vectors of this stuntdouble in specified snapshot
498 >     *
499 >     * @return the unit vectors of this stuntdouble
500 >     * @param snapshotNo
501 >     */    
502 >    RotMat3x3d getElectroFrame(int snapshotNo) {
503 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).electroFrame[localIndex_];
504 >    }
505 >
506 >    /**
507 >     * Returns the previous force of this stuntdouble
508 >     * @return the force of this stuntdouble
509 >     */    
510 >    Vector3d getPrevFrc() {
511 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).force[localIndex_];
512 >    }
513 >      
514 >    /**
515 >     * Returns the current force of this stuntdouble
516 >     * @return the force of this stuntdouble
517 >     */    
518 >    Vector3d getFrc() {
519 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).force[localIndex_];
520 >    }
521 >
522 >    /**
523 >     * Returns the force of this stuntdouble in specified snapshot
524 >     *
525 >     * @return the force of this stuntdouble
526 >     * @param snapshotNo
527 >     */    
528 >    Vector3d getFrc(int snapshotNo) {
529 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).force[localIndex_];
530 >    }
531 >
532 >    /**
533 >     * Sets  the previous force of this stuntdouble
534 >     *
535 >     * @param frc  new force
536 >     * @see #getFrc
537 >     */        
538 >    void setPrevFrc(const Vector3d& frc) {
539 >      ((snapshotMan_->getPrevSnapshot())->*storage_).force[localIndex_] = frc;
540 >    }
541 >      
542 >    /**
543 >     * Sets  the current force of this stuntdouble
544 >     * @param frc  new force
545 >     */        
546 >    void setFrc(const Vector3d& frc) {
547 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).force[localIndex_] = frc;
548 >    }
549 >
550 >    /**
551 >     * Sets  the force of this stuntdouble in specified snapshot
552 >     *
553 >     * @param frc force to be set
554 >     * @param snapshotNo
555 >     * @see #getFrc
556 >     */        
557 >    void setFrc(const Vector3d& frc, int snapshotNo) {
558 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).force[localIndex_] = frc;
559 >    }
560 >
561 >    /**
562 >     * Adds force into the previous force of this stuntdouble
563 >     *
564 >     * @param frc  new force
565 >     * @see #getFrc
566 >     */        
567 >    void addPrevFrc(const Vector3d& frc) {
568 >      ((snapshotMan_->getPrevSnapshot())->*storage_).force[localIndex_] += frc;
569 >    }
570 >      
571 >    /**
572 >     * Adds force into the current force of this stuntdouble
573 >     * @param frc  new force
574 >     */        
575 >    void addFrc(const Vector3d& frc) {
576 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).force[localIndex_] += frc;
577 >    }
578 >
579 >    /**
580 >     * Adds force into the force of this stuntdouble in specified snapshot
581 >     *
582 >     * @param frc force to be set
583 >     * @param snapshotNo
584 >     * @see #getFrc
585 >     */        
586 >    void addFrc(const Vector3d& frc, int snapshotNo) {
587 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).force[localIndex_] += frc;
588 >    }
589 >
590 >    /**
591 >     * Returns the previous torque of this stuntdouble
592 >     * @return the torque of this stuntdouble
593 >     */    
594 >    Vector3d getPrevTrq() {
595 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).torque[localIndex_];
596 >    }
597 >      
598 >    /**
599 >     * Returns the current torque of this stuntdouble
600 >     * @return the torque of this stuntdouble
601 >     */    
602 >    Vector3d getTrq() {
603 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).torque[localIndex_];
604 >    }
605 >
606 >    /**
607 >     * Returns the torque of this stuntdouble in specified snapshot
608 >     *
609 >     * @return the torque of this stuntdouble
610 >     * @param snapshotNo
611 >     */    
612 >    Vector3d getTrq(int snapshotNo) {
613 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).torque[localIndex_];
614 >    }
615 >
616 >    /**
617 >     * Sets  the previous torque of this stuntdouble
618 >     *
619 >     * @param trq  new torque
620 >     * @see #getTrq
621 >     */        
622 >    void setPrevTrq(const Vector3d& trq) {
623 >      ((snapshotMan_->getPrevSnapshot())->*storage_).torque[localIndex_] = trq;
624 >    }
625 >      
626 >    /**
627 >     * Sets  the current torque of this stuntdouble
628 >     * @param trq  new torque
629 >     */        
630 >    void setTrq(const Vector3d& trq) {
631 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).torque[localIndex_] = trq;
632 >    }
633 >
634 >    /**
635 >     * Sets  the torque of this stuntdouble in specified snapshot
636 >     *
637 >     * @param trq torque to be set
638 >     * @param snapshotNo
639 >     * @see #getTrq
640 >     */        
641 >    void setTrq(const Vector3d& trq, int snapshotNo) {
642 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).torque[localIndex_] = trq;
643 >    }
644 >
645 >    /**
646 >     * Adds torque into the previous torque of this stuntdouble
647 >     *
648 >     * @param trq  new torque
649 >     * @see #getTrq
650 >     */        
651 >    void addPrevTrq(const Vector3d& trq) {
652 >      ((snapshotMan_->getPrevSnapshot())->*storage_).torque[localIndex_] += trq;
653 >    }
654 >      
655 >    /**
656 >     * Adds torque into the current torque of this stuntdouble
657 >     * @param trq  new torque
658 >     */        
659 >    void addTrq(const Vector3d& trq) {
660 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).torque[localIndex_] += trq;
661 >    }
662 >
663 >    /**
664 >     * Adds torque into the torque of this stuntdouble in specified snapshot
665 >     *
666 >     * @param trq torque to be add
667 >     * @param snapshotNo
668 >     * @see #getTrq
669 >     */        
670 >    void addTrq(const Vector3d& trq, int snapshotNo) {
671 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).torque[localIndex_] += trq;
672 >    }      
673 >
674 >
675 >    /**
676 >     * Returns the previous z-angle of this stuntdouble
677 >     * @return the z-angle of this stuntdouble
678 >     */    
679 >    double getPrevZangle() {
680 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_];
681 >    }
682 >      
683 >    /**
684 >     * Returns the current z-angle of this stuntdouble
685 >     * @return the z-angle of this stuntdouble
686 >     */    
687 >    double getZangle() {
688 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_];
689 >    }
690 >
691 >    /**
692 >     * Returns the z-angle of this stuntdouble in specified snapshot
693 >     * @return the z-angle of this stuntdouble
694 >     * @param snapshotNo
695 >     */    
696 >    double getZangle(int snapshotNo) {
697 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_];
698 >    }
699 >
700 >    /**
701 >     * Sets  the previous z-angle of this stuntdouble
702 >     * @param angle  new z-angle
703 >     * @see #getZangle
704 >     */        
705 >    void setPrevZangle(double angle) {
706 >      ((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_] = angle;
707 >    }
708 >      
709 >    /**
710 >     * Sets  the current z-angle of this stuntdouble
711 >     * @param angle  new z-angle
712 >     */        
713 >    void setZangle(double angle) {
714 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_] = angle;
715 >    }
716 >
717 >    /**
718 >     * Sets  the z-angle of this stuntdouble in specified snapshot
719 >     * @param angle z-angle to be set
720 >     * @param snapshotNo
721 >     * @see #getZangle
722 >     */        
723 >    void setZangle(double angle, int snapshotNo) {
724 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_] = angle;
725 >    }
726 >
727 >    /**
728 >     * Adds z-angle into the previous z-angle of this stuntdouble
729 >     * @param angle  new z-angle
730 >     * @see #getZangle
731 >     */        
732 >    void addPrevZangle(double angle) {
733 >      ((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_] += angle;
734 >    }
735 >      
736 >    /**
737 >     * Adds z-angle into the current z-angle of this stuntdouble
738 >     * @param angle  new z-angle
739 >     */        
740 >    void addZangle(double angle) {
741 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_] += angle;
742 >    }
743 >
744 >    /**
745 >     * Adds z-angle into the z-angle of this stuntdouble in specified snapshot
746 >     * @param angle z-angle to be add
747 >     * @param snapshotNo
748 >     * @see #getZangle
749 >     */        
750 >    void addZangle(double angle, int snapshotNo) {
751 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_] += angle;
752 >    }      
753 >
754 >    /** Set the force of this stuntdouble to zero */
755 >    void zeroForcesAndTorques();
756 >    /**
757 >     * Returns the inertia tensor of this stuntdouble
758 >     * @return the inertia tensor of this stuntdouble
759 >     */
760 >    virtual Mat3x3d getI() = 0;
761 >
762 >    /**
763 >     * Returns the gradient of this stuntdouble
764 >     * @return the gradient of this stuntdouble
765 >     */
766 >    virtual std::vector<double> getGrad() = 0;
767 >
768 >    /**
769 >     * Tests the  if this stuntdouble is a  linear rigidbody
770 >     *
771 >     * @return true if this stuntdouble is a  linear rigidbody, otherwise return false
772 >     * @note atom and directional atom will always return false
773 >     *
774 >     * @see #linearAxis
775 >     */        
776 >    bool isLinear() {
777 >      return linear_;
778 >    }
779 >
780 >    /**
781 >     * Returns the linear axis of the rigidbody, atom and directional atom will always return -1
782 >     *
783 >     * @return the linear axis of the rigidbody
784 >     *
785 >     * @see #isLinear
786 >     */
787 >    int linearAxis() {
788 >      return linearAxis_;
789 >    }
790 >
791 >    /** Returns the mass of this stuntdouble */
792 >    double getMass() {
793 >      return mass_;
794 >    }
795 >
796 >    /**
797 >     * Sets the mass of this stuntdoulbe
798 >     * @param mass the mass to be set
799 >     */        
800 >    void setMass(double mass) {
801 >      mass_ = mass;
802 >    }
803 >
804 >    /** Returns the name of this stuntdouble */
805 >    virtual std::string getType() = 0;
806 >        
807 >    /** Sets the name of this stuntdouble*/
808 >    virtual void setType(const std::string& name) {}
809 >
810 >    /**
811 >     * Converts a lab fixed vector to a body fixed vector.
812 >     * @return body fixed vector
813 >     * @param v lab fixed vector
814 >     */
815 >    Vector3d lab2Body(const Vector3d& v) {
816 >      return getA() * v;
817 >    }
818 >
819 >    Vector3d lab2Body(const Vector3d& v, int frame) {
820 >      return getA(frame) * v;
821 >    }
822 >
823 >    /**
824 >     * Converts a body fixed vector to a lab fixed vector.
825 >     * @return corresponding lab fixed vector
826 >     * @param v body fixed vector
827 >     */
828 >    Vector3d body2Lab(const Vector3d& v){
829 >      return getA().transpose() * v;
830 >    }
831 >
832 >    Vector3d body2Lab(const Vector3d& v, int frame){
833 >      return getA(frame).transpose() * v;
834 >    }
835 >    /**
836 >     * <p>
837 >     * The purpose of the Visitor Pattern is to encapsulate an operation that you want to perform on
838 >     * the elements of a data structure. In this way, you can change the operation being performed
839 >     * on a structure without the need of changing the classes of the elements that you are operating
840 >     * on. Using a Visitor pattern allows you to decouple the classes for the data structure and the
841 >     * algorithms used upon them
842 >     * </p>
843 >     * @param v visitor
844 >     */      
845 >    virtual void accept(BaseVisitor* v) = 0;
846 >
847 >    //below functions are just forward functions
848 >    /**
849 >     * Adds property into property map
850 >     * @param genData GenericData to be added into PropertyMap
851 >     */
852 >    void addProperty(GenericData* genData);
853 >
854 >    /**
855 >     * Removes property from PropertyMap by name
856 >     * @param propName the name of property to be removed
857 >     */
858 >    void removeProperty(const std::string& propName);
859 >
860 >    /**
861 >     * clear all of the properties
862 >     */
863 >    void clearProperties();
864 >
865 >    /**
866 >     * Returns all names of properties
867 >     * @return all names of properties
868 >     */
869 >    std::vector<std::string> getPropertyNames();
870 >
871 >    /**
872 >     * Returns all of the properties in PropertyMap
873 >     * @return all of the properties in PropertyMap
874 >     */      
875 >    std::vector<GenericData*> getProperties();
876 >
877 >    /**
878 >     * Returns property
879 >     * @param propName name of property
880 >     * @return a pointer point to property with propName. If no property named propName
881 >     * exists, return NULL
882 >     */      
883 >    GenericData* getPropertyByName(const std::string& propName);
884 >
885 >  protected:
886 >        
887 >    StuntDouble(ObjectType objType, DataStoragePointer storage);
888 >        
889 >    StuntDouble(const StuntDouble& sd);
890 >    StuntDouble& operator=(const StuntDouble& sd);
891 >
892 >    ObjectType objType_;
893 >    DataStoragePointer storage_;
894 >    SnapshotManager* snapshotMan_;
895 >        
896 >    bool linear_;
897 >    int linearAxis_;        
898 >
899 >        
900 >    int globalIndex_;
901 >    int localIndex_;
902 >
903 >
904 >    double mass_;
905 >        
906 >  private:
907 >        
908 >    PropertyMap properties_;
909 >  };
910 >
911 > }//end namespace oopse
912 > #endif //PRIMITIVES_STUNTDOUBLE_HPP

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines