ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/primitives/StuntDouble.hpp
(Generate patch)

Comparing trunk/src/primitives/StuntDouble.hpp (file contents):
Revision 3 by tim, Fri Sep 24 16:27:58 2004 UTC vs.
Revision 1112 by chuckv, Wed Jan 3 20:47:00 2007 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 >   *     "Don't move, or you're dead! Stand up! Captain, we've got them!"
69 >   *
70 >   *     "Spectacular stunt, my friends, but all for naught. Turn around
71 >   *      please. Ha. What a pity. What a pity. So, Princess, you thought
72 >   *      you could outwit the imperious forces of...."
73 >   *
74 >   *     "You idiots! These are not them. You've captured their stunt
75 >   *      doubles! Search the area. Find them! Find them!"
76 >   *
77 >   * StuntDouble is a very strange idea.  A StuntDouble stands in for
78 >   * some object that can be manipulated by the Integrators or
79 >   * Minimizers.  Some of the manipulable objects are Atoms, some are
80 >   * DirectionalAtoms, and some are RigidBodies.  StuntDouble
81 >   * provides an interface for the Integrators and Minimizers to use,
82 >   * and does some preliminary sanity checking so that the program
83 >   * doesn't try to do something stupid like torque an Atom (The
84 >   * quotes above are from Spaceballs...)
85 >   *
86 >   * @note the dynamic data of stuntdouble will be stored outside of the class
87 >   */
88 >  class StuntDouble{
89 >  public:    
90  
91 <  bool isDirectionalAtom(){
92 <    return objType == OT_DATOM;
93 <  }
91 >    enum ObjectType{
92 >      otAtom,
93 >      otDAtom,
94 >      otRigidBody
95 >    };
96  
97 <  bool isRigidBody(){
98 <    return objType == OT_RIGIDBODY;
99 <  }
97 >    virtual ~StuntDouble();
98 >        
99 >    /**
100 >     * Returns the global index of this stuntRealType.
101 >     * @return  the global index of this stuntdouble
102 >     */
103 >    int getGlobalIndex() {
104 >      return globalIndex_;
105 >    }
106  
107 <  bool isDirectional(){
108 <    return isDirectionalAtom() || isRigidBody();
109 <  }
107 >    /**
108 >     * Sets the global index of this stuntRealType.
109 >     * @param new global index to be set
110 >     */
111 >    void setGlobalIndex(int index) {
112 >      globalIndex_ = index;
113 >    }
114 >        
115 >    /**
116 >     * Returns the local index of this stuntdouble
117 >     * @return the local index of this stuntdouble
118 >     */
119 >    int getLocalIndex() {
120 >      return localIndex_;
121 >    }
122  
123 <  virtual double getMass(void);
124 <  
125 <  virtual void   getPos(double pos[3]);
126 <  virtual void   setPos(double pos[3]);
127 <  
128 <  virtual void   getVel(double vel[3]);
129 <  virtual void   setVel(double vel[3]);
43 <  
44 <  virtual void   getFrc(double frc[3]);
45 <  virtual void   addFrc(double frc[3]);
123 >    /**
124 >     * Sets the local index of this stuntdouble
125 >     * @param index new index to be set
126 >     */        
127 >    void setLocalIndex(int index) {
128 >      localIndex_ = index;
129 >    }
130  
131 <  virtual void   getA(double A[3][3]);
132 <  virtual void   setA(double A[3][3]);
131 >  int getGlobalIntegrableObjectIndex(){
132 >        return globalIntegrableObjectIndex_;
133 >  }
134 >  void setGlobalIntegrableObjectIndex(int index) {
135 >     globalIntegrableObjectIndex_ = index;
136 >  }
137  
138 <  virtual void   getJ(double j[3]);
139 <  virtual void   setJ(double j[3]);
138 >    /**
139 >     * Sets the Snapshot Manager of this stuntdouble
140 >     */
141 >    void setSnapshotManager(SnapshotManager* sman) {
142 >      snapshotMan_ = sman;
143 >    }
144  
145 <  virtual void getQ( double q[4] ); // get the quanternions
146 <  virtual void setQ( double q[4] );
145 >    /**
146 >     * Tests if this stuntdouble is an atom
147 >     * @return true is this stuntdouble is an atom(or a directional atom), return false otherwise
148 >     */
149 >    bool isAtom(){
150 >      return objType_ == otAtom || objType_ == otDAtom;
151 >    }
152  
153 <  virtual void setType(char* type) = 0;
154 <  virtual char* getType() = 0;
155 <  
153 >    /**
154 >     * Tests if this stuntdouble is an directional atom
155 >     * @return true if this stuntdouble is an directional atom, return false otherwise
156 >     */
157 >    bool isDirectionalAtom(){
158 >      return objType_ == otDAtom;
159 >    }
160  
161 <  virtual void   getTrq(double trq[3]);
162 <  virtual void   addTrq(double trq[3]);
161 >    /**
162 >     * Tests if this stuntdouble is a rigid body.
163 >     * @return true if this stuntdouble is a rigid body, otherwise return false
164 >     */
165 >    bool isRigidBody(){
166 >      return objType_ == otRigidBody;
167 >    }
168  
169 <  virtual void   getI(double I[3][3]);
170 <  virtual void   lab2Body(double vec[3]);
169 >    /**
170 >     * Tests if this stuntdouble is a directional one.
171 >     * @return true is this stuntdouble is a directional atom or a rigid body, return false otherwise
172 >     */
173 >    bool isDirectional(){
174 >      return isDirectionalAtom() || isRigidBody();
175 >    }
176  
177 <  virtual void   getGrad(double grad[6]);
178 <  virtual void   setEuler(double phi, double theta, double psi);
179 <  virtual void   getEulerAngles(double eulers[3]);
177 >    /**
178 >     * Freezes out all velocity, angular velocity, forces and torques
179 >     * on this StuntDouble.  Also computes the number of frozen degrees
180 >     * of freedom.
181 >     * @return the total number of frozen degrees of freedom
182 >     */  
183 >    int freeze() {
184 >      
185 >      int fdf = 3;
186  
187 <  virtual bool isLinear() {return false;}
188 <  virtual int linearAxis() {return -1;}
187 >      setVel(V3Zero);
188 >      setFrc(V3Zero);
189 >      if (isDirectional()){
190 >        setJ(V3Zero);
191 >        setTrq(V3Zero);
192 >        if (isLinear())
193 >          fdf +=2;
194 >        else
195 >          fdf +=3;        
196 >      }      
197 >      return fdf;
198 >    }
199  
200 <  virtual double   getZangle();
201 <  virtual void   setZangle(double zAngle);
202 <  virtual void   addZangle(double zAngle);
200 >    /**
201 >     * Returns the previous position of this stuntdouble
202 >     * @return the position of this stuntdouble
203 >     */    
204 >    Vector3d getPrevPos() {
205 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).position[localIndex_];
206 >    }
207 >      
208 >    /**
209 >     * Returns the current position of this stuntdouble
210 >     * @return the position of this stuntdouble
211 >     */    
212 >    Vector3d getPos() {
213 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).position[localIndex_];
214 >    }
215  
216 <  virtual void accept(BaseVisitor* v) = 0;
217 <
218 <  void addProperty(GenericData* data);
219 <  void removeProperty(const string& propName);
220 <  GenericData* getProperty(const string& propName);
221 <  
222 < protected:
223 <  StuntDouble(){}
216 >    /**
217 >     * Returns the position of this stuntdouble in specified snapshot
218 >     * @return the position of this stuntdouble
219 >     * @param snapshotNo
220 >     */    
221 >    Vector3d getPos(int snapshotNo) {
222 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).position[localIndex_];
223 >    }
224  
225 <  //prevent default copy constructor copy information from properties which will cause problem
226 <  StuntDouble(const StuntDouble& sd){
227 <    objType = sd.objType;
228 <  }
229 <  
230 <  int objType;
225 >    /**
226 >     * Sets  the previous position of this stuntdouble
227 >     * @param pos  new position
228 >     * @see #getPos
229 >     */        
230 >    void setPrevPos(const Vector3d& pos) {
231 >      ((snapshotMan_->getPrevSnapshot())->*storage_).position[localIndex_] = pos;
232 >    }
233 >      
234 >    /**
235 >     * Sets  the current position of this stuntdouble
236 >     * @param pos  new position
237 >     */        
238 >    void setPos(const Vector3d& pos) {
239 >      DataStorage&  data = snapshotMan_->getCurrentSnapshot()->*storage_;
240 >      data.position[localIndex_] = pos;
241 >      //((snapshotMan_->getCurrentSnapshot())->*storage_).position[localIndex_] = pos;
242 >    }
243  
244 <  map<string, GenericData*> properties;
245 < };
244 >    /**
245 >     * Sets  the position of this stuntdouble in specified snapshot
246 >     * @param pos position to be set
247 >     * @param snapshotNo
248 >     * @see #getPos
249 >     */        
250 >    void setPos(const Vector3d& pos, int snapshotNo) {
251  
252 < #endif
252 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).position[localIndex_] = pos;
253 >
254 >    }
255 >      
256 >    /**
257 >     * Returns the previous velocity of this stuntdouble
258 >     * @return the velocity of this stuntdouble
259 >     */    
260 >    Vector3d getPrevVel() {
261 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).velocity[localIndex_];
262 >    }
263 >      
264 >    /**
265 >     * Returns the current velocity of this stuntdouble
266 >     * @return the velocity of this stuntdouble
267 >     */    
268 >    Vector3d getVel() {
269 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).velocity[localIndex_];
270 >    }
271 >
272 >    /**
273 >     * Returns the velocity of this stuntdouble in specified snapshot
274 >     * @return the velocity of this stuntdouble
275 >     * @param snapshotNo
276 >     */    
277 >    Vector3d getVel(int snapshotNo) {
278 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).velocity[localIndex_];
279 >    }
280 >
281 >    /**
282 >     * Sets  the previous velocity of this stuntdouble
283 >     * @param vel  new velocity
284 >     * @see #getVel
285 >     */        
286 >    void setPrevVel(const Vector3d& vel) {
287 >      ((snapshotMan_->getPrevSnapshot())->*storage_).velocity[localIndex_] = vel;
288 >    }
289 >      
290 >    /**
291 >     * Sets  the current velocity of this stuntdouble
292 >     * @param vel  new velocity
293 >     */        
294 >    void setVel(const Vector3d& vel) {
295 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).velocity[localIndex_] = vel;
296 >    }
297 >
298 >    /**
299 >     * Sets  the velocity of this stuntdouble in specified snapshot
300 >     * @param vel velocity to be set
301 >     * @param snapshotNo
302 >     * @see #getVel
303 >     */        
304 >    void setVel(const Vector3d& vel, int snapshotNo) {
305 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).velocity[localIndex_] = vel;
306 >    }
307 >
308 >    /**
309 >     * Returns the previous rotation matrix of this stuntdouble
310 >     * @return the rotation matrix of this stuntdouble
311 >     */    
312 >    RotMat3x3d getPrevA() {
313 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_];
314 >    }
315 >      
316 >    /**
317 >     * Returns the current rotation matrix of this stuntdouble
318 >     * @return the rotation matrix of this stuntdouble
319 >     */    
320 >    RotMat3x3d getA() {
321 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_];
322 >    }
323 >
324 >    /**
325 >     * Returns the rotation matrix of this stuntdouble in specified snapshot
326 >     *
327 >     * @return the rotation matrix of this stuntdouble
328 >     * @param snapshotNo
329 >     */    
330 >    RotMat3x3d getA(int snapshotNo) {
331 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_];
332 >    }
333 >
334 >    /**
335 >     * Sets  the previous rotation matrix of this stuntdouble
336 >     * @param a  new rotation matrix
337 >     * @see #getA
338 >     */        
339 >    virtual void setPrevA(const RotMat3x3d& a) {
340 >      ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_] = a;
341 >    }
342 >      
343 >    /**
344 >     * Sets  the current rotation matrix of this stuntdouble
345 >     * @param a  new rotation matrix
346 >     */        
347 >    virtual void setA(const RotMat3x3d& a) {
348 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_] = a;
349 >    }
350 >
351 >    /**
352 >     * Sets  the rotation matrix of this stuntdouble in specified snapshot
353 >     * @param a rotation matrix to be set
354 >     * @param snapshotNo
355 >     * @see #getA
356 >     */        
357 >    virtual void setA(const RotMat3x3d& a, int snapshotNo) {
358 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_] = a;
359 >    }      
360 >
361 >    /**
362 >     * Returns the previous angular momentum of this stuntdouble (body-fixed).
363 >     * @return the angular momentum of this stuntdouble
364 >     */    
365 >    Vector3d getPrevJ() {
366 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).angularMomentum[localIndex_];
367 >    }
368 >      
369 >    /**
370 >     * Returns the current angular momentum of this stuntdouble (body -fixed).
371 >     * @return the angular momentum of this stuntdouble
372 >     */    
373 >    Vector3d getJ() {
374 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).angularMomentum[localIndex_];
375 >    }
376 >
377 >    /**
378 >     * Returns the angular momentum of this stuntdouble in specified snapshot (body-fixed).
379 >     * @return the angular momentum of this stuntdouble
380 >     * @param snapshotNo
381 >     */    
382 >    Vector3d getJ(int snapshotNo) {
383 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).angularMomentum[localIndex_];
384 >    }
385 >
386 >    /**
387 >     * Sets  the previous angular momentum of this stuntdouble (body-fixed).
388 >     * @param angMom  new angular momentum
389 >     * @see #getJ
390 >     */        
391 >    void setPrevJ(const Vector3d& angMom) {
392 >      ((snapshotMan_->getPrevSnapshot())->*storage_).angularMomentum[localIndex_] = angMom;
393 >    }
394 >      
395 >    /**
396 >     * Sets  the current angular momentum of this stuntdouble (body-fixed).
397 >     * @param angMom  new angular momentum
398 >     */        
399 >    void setJ(const Vector3d& angMom) {
400 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).angularMomentum[localIndex_] = angMom;
401 >    }
402 >
403 >    /**
404 >     * Sets the angular momentum of this stuntdouble in specified snapshot(body-fixed).
405 >     * @param angMom angular momentum to be set
406 >     * @param snapshotNo
407 >     * @see #getJ
408 >     */        
409 >    void setJ(const Vector3d& angMom, int snapshotNo) {
410 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).angularMomentum[localIndex_] = angMom;
411 >    }
412 >    
413 >    /**
414 >     * Returns system Center of Mass for stuntdouble frame from snapshot
415 >     *
416 >     */
417 >    Vector3d getCOM(){
418 >      return (snapshotMan_->getCurrentSnapshot())->getCOM();
419 >    }
420 >    
421 >    /**
422 >      * Returns system Center of Mass velocity for stuntdouble frame from snapshot
423 >     *
424 >     */
425 >    
426 >    Vector3d getCOMvel(){
427 >      return (snapshotMan_->getCurrentSnapshot())->getCOMvel();
428 >    }
429 >    
430 >    /**
431 >      * Returns system Center of Mass angular momentum for stuntdouble frame from snapshot
432 >     *
433 >     */
434 >    Vector3d getCOMw(){
435 >      return (snapshotMan_->getCurrentSnapshot())->getCOMw();
436 >    }
437 >    
438 > /**
439 >     * Returns system Center of Mass for stuntdouble frame from snapshot
440 >     *
441 >     */
442 >    Vector3d getCOM(int snapshotNo){
443 >      return (snapshotMan_->getSnapshot(snapshotNo))->getCOM();
444 >    }
445 >    
446 >    /**
447 >      * Returns system Center of Mass velocity for stuntdouble frame from snapshot
448 >     *
449 >     */
450 >    
451 >    Vector3d getCOMvel(int snapshotNo){
452 >      return (snapshotMan_->getSnapshot(snapshotNo))->getCOMvel();
453 >    }
454 >    
455 >    /**
456 >      * Returns system Center of Mass angular momentum for stuntdouble frame from snapshot
457 >     *
458 >     */
459 >    Vector3d getCOMw(int snapshotNo){
460 >      return (snapshotMan_->getSnapshot(snapshotNo))->getCOMw();
461 >    }
462 >
463 >    /**
464 >     * Returns the previous quaternion of this stuntdouble
465 >     * @return the quaternion of this stuntdouble
466 >     */    
467 >    Quat4d getPrevQ() {
468 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_].toQuaternion();
469 >    }
470 >      
471 >    /**
472 >     * Returns the current quaternion of this stuntdouble
473 >     * @return the quaternion of this stuntdouble
474 >     */    
475 >    Quat4d getQ() {
476 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_].toQuaternion();
477 >    }
478 >
479 >    /**
480 >     * Returns the quaternion of this stuntdouble in specified snapshot
481 >     * @return the quaternion of this stuntdouble
482 >     * @param snapshotNo
483 >     */    
484 >    Quat4d getQ(int snapshotNo) {
485 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_].toQuaternion();
486 >    }
487 >
488 >    /**
489 >     * Sets  the previous quaternion of this stuntdouble
490 >     * @param q  new quaternion
491 >     * @note actual storage data is rotation matrix
492 >     */        
493 >    void setPrevQ(const Quat4d& q) {
494 >      setPrevA(q);
495 >    }
496 >      
497 >    /**
498 >     * Sets  the current quaternion of this stuntdouble
499 >     * @param q  new quaternion
500 >     * @note actual storage data is rotation matrix
501 >     */        
502 >    void setQ(const Quat4d& q) {
503 >      setA(q);
504 >    }
505 >
506 >    /**
507 >     * Sets  the quaternion of this stuntdouble in specified snapshot
508 >     *
509 >     * @param q quaternion to be set
510 >     * @param snapshotNo
511 >     * @note actual storage data is rotation matrix
512 >     */        
513 >    void setQ(const Quat4d& q, int snapshotNo) {
514 >      setA(q, snapshotNo);
515 >    }
516 >
517 >    /**
518 >     * Returns the previous euler angles of this stuntdouble
519 >     * @return the euler angles of this stuntdouble
520 >     */    
521 >    Vector3d getPrevEuler() {
522 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_].toEulerAngles();
523 >    }
524 >      
525 >    /**
526 >     * Returns the current euler angles of this stuntdouble
527 >     * @return the euler angles of this stuntdouble
528 >     */    
529 >    Vector3d getEuler() {
530 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_].toEulerAngles();
531 >    }
532 >
533 >    /**
534 >     * Returns the euler angles of this stuntdouble in specified snapshot.
535 >     * @return the euler angles of this stuntdouble
536 >     * @param snapshotNo
537 >     */    
538 >    Vector3d getEuler(int snapshotNo) {
539 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_].toEulerAngles();
540 >    }
541 >
542 >    /**
543 >     * Sets  the previous euler angles of this stuntRealType.
544 >     * @param euler  new euler angles
545 >     * @see #getEuler
546 >     * @note actual storage data is rotation matrix        
547 >     */        
548 >    void setPrevEuler(const Vector3d& euler) {
549 >      ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_] = euler;
550 >    }
551 >      
552 >    /**
553 >     * Sets  the current euler angles of this stuntdouble
554 >     * @param euler  new euler angles
555 >     */        
556 >    void setEuler(const Vector3d& euler) {
557 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_] = euler;
558 >    }
559 >
560 >    /**
561 >     * Sets  the euler angles  of this stuntdouble in specified snapshot
562 >     *
563 >     * @param euler euler angles to be set
564 >     * @param snapshotNo
565 >     * @note actual storage data is rotation matrix                  
566 >     */        
567 >    void setEuler(const Vector3d& euler, int snapshotNo) {
568 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_] = euler;
569 >    }
570 >      
571 >    /**
572 >     * Returns the previous unit vectors of this stuntdouble
573 >     * @return the unit vectors of this stuntdouble
574 >     */    
575 >    RotMat3x3d getPrevElectroFrame() {
576 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).electroFrame[localIndex_];
577 >    }
578 >      
579 >    /**
580 >     * Returns the current unit vectors of this stuntdouble
581 >     * @return the unit vectors of this stuntdouble
582 >     */    
583 >    RotMat3x3d getElectroFrame() {
584 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).electroFrame[localIndex_];
585 >    }
586 >
587 >    /**
588 >     * Returns the unit vectors of this stuntdouble in specified snapshot
589 >     *
590 >     * @return the unit vectors of this stuntdouble
591 >     * @param snapshotNo
592 >     */    
593 >    RotMat3x3d getElectroFrame(int snapshotNo) {
594 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).electroFrame[localIndex_];
595 >    }
596 >
597 >    /**
598 >     * Returns the previous force of this stuntdouble
599 >     * @return the force of this stuntdouble
600 >     */    
601 >    Vector3d getPrevFrc() {
602 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).force[localIndex_];
603 >    }
604 >      
605 >    /**
606 >     * Returns the current force of this stuntdouble
607 >     * @return the force of this stuntdouble
608 >     */    
609 >    Vector3d getFrc() {
610 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).force[localIndex_];
611 >    }
612 >
613 >    /**
614 >     * Returns the force of this stuntdouble in specified snapshot
615 >     *
616 >     * @return the force of this stuntdouble
617 >     * @param snapshotNo
618 >     */    
619 >    Vector3d getFrc(int snapshotNo) {
620 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).force[localIndex_];
621 >    }
622 >
623 >    /**
624 >     * Sets  the previous force of this stuntdouble
625 >     *
626 >     * @param frc  new force
627 >     * @see #getFrc
628 >     */        
629 >    void setPrevFrc(const Vector3d& frc) {
630 >      ((snapshotMan_->getPrevSnapshot())->*storage_).force[localIndex_] = frc;
631 >    }
632 >      
633 >    /**
634 >     * Sets  the current force of this stuntdouble
635 >     * @param frc  new force
636 >     */        
637 >    void setFrc(const Vector3d& frc) {
638 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).force[localIndex_] = frc;
639 >    }
640 >
641 >    /**
642 >     * Sets  the force of this stuntdouble in specified snapshot
643 >     *
644 >     * @param frc force to be set
645 >     * @param snapshotNo
646 >     * @see #getFrc
647 >     */        
648 >    void setFrc(const Vector3d& frc, int snapshotNo) {
649 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).force[localIndex_] = frc;
650 >    }
651 >
652 >    /**
653 >     * Adds force into the previous force of this stuntdouble
654 >     *
655 >     * @param frc  new force
656 >     * @see #getFrc
657 >     */        
658 >    void addPrevFrc(const Vector3d& frc) {
659 >      ((snapshotMan_->getPrevSnapshot())->*storage_).force[localIndex_] += frc;
660 >    }
661 >      
662 >    /**
663 >     * Adds force into the current force of this stuntdouble
664 >     * @param frc  new force
665 >     */        
666 >    void addFrc(const Vector3d& frc) {
667 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).force[localIndex_] += frc;
668 >    }
669 >
670 >    /**
671 >     * Adds force into the force of this stuntdouble in specified snapshot
672 >     *
673 >     * @param frc force to be set
674 >     * @param snapshotNo
675 >     * @see #getFrc
676 >     */        
677 >    void addFrc(const Vector3d& frc, int snapshotNo) {
678 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).force[localIndex_] += frc;
679 >    }
680 >
681 >    /**
682 >     * Returns the previous torque of this stuntdouble
683 >     * @return the torque of this stuntdouble
684 >     */    
685 >    Vector3d getPrevTrq() {
686 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).torque[localIndex_];
687 >    }
688 >      
689 >    /**
690 >     * Returns the current torque of this stuntdouble
691 >     * @return the torque of this stuntdouble
692 >     */    
693 >    Vector3d getTrq() {
694 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).torque[localIndex_];
695 >    }
696 >
697 >    /**
698 >     * Returns the torque of this stuntdouble in specified snapshot
699 >     *
700 >     * @return the torque of this stuntdouble
701 >     * @param snapshotNo
702 >     */    
703 >    Vector3d getTrq(int snapshotNo) {
704 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).torque[localIndex_];
705 >    }
706 >
707 >    /**
708 >     * Sets  the previous torque of this stuntdouble
709 >     *
710 >     * @param trq  new torque
711 >     * @see #getTrq
712 >     */        
713 >    void setPrevTrq(const Vector3d& trq) {
714 >      ((snapshotMan_->getPrevSnapshot())->*storage_).torque[localIndex_] = trq;
715 >    }
716 >      
717 >    /**
718 >     * Sets  the current torque of this stuntdouble
719 >     * @param trq  new torque
720 >     */        
721 >    void setTrq(const Vector3d& trq) {
722 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).torque[localIndex_] = trq;
723 >    }
724 >
725 >    /**
726 >     * Sets  the torque of this stuntdouble in specified snapshot
727 >     *
728 >     * @param trq torque to be set
729 >     * @param snapshotNo
730 >     * @see #getTrq
731 >     */        
732 >    void setTrq(const Vector3d& trq, int snapshotNo) {
733 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).torque[localIndex_] = trq;
734 >    }
735 >
736 >    /**
737 >     * Adds torque into the previous torque of this stuntdouble
738 >     *
739 >     * @param trq  new torque
740 >     * @see #getTrq
741 >     */        
742 >    void addPrevTrq(const Vector3d& trq) {
743 >      ((snapshotMan_->getPrevSnapshot())->*storage_).torque[localIndex_] += trq;
744 >    }
745 >      
746 >    /**
747 >     * Adds torque into the current torque of this stuntdouble
748 >     * @param trq  new torque
749 >     */        
750 >    void addTrq(const Vector3d& trq) {
751 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).torque[localIndex_] += trq;
752 >    }
753 >
754 >    /**
755 >     * Adds torque into the torque of this stuntdouble in specified snapshot
756 >     *
757 >     * @param trq torque to be add
758 >     * @param snapshotNo
759 >     * @see #getTrq
760 >     */        
761 >    void addTrq(const Vector3d& trq, int snapshotNo) {
762 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).torque[localIndex_] += trq;
763 >    }      
764 >
765 >
766 >    /**
767 >     * Returns the previous z-angle of this stuntdouble
768 >     * @return the z-angle of this stuntdouble
769 >     */    
770 >    RealType getPrevZangle() {
771 >      return ((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_];
772 >    }
773 >      
774 >    /**
775 >     * Returns the current z-angle of this stuntdouble
776 >     * @return the z-angle of this stuntdouble
777 >     */    
778 >    RealType getZangle() {
779 >      return ((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_];
780 >    }
781 >
782 >    /**
783 >     * Returns the z-angle of this stuntdouble in specified snapshot
784 >     * @return the z-angle of this stuntdouble
785 >     * @param snapshotNo
786 >     */    
787 >    RealType getZangle(int snapshotNo) {
788 >      return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_];
789 >    }
790 >
791 >    /**
792 >     * Sets  the previous z-angle of this stuntdouble
793 >     * @param angle  new z-angle
794 >     * @see #getZangle
795 >     */        
796 >    void setPrevZangle(RealType angle) {
797 >      ((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_] = angle;
798 >    }
799 >      
800 >    /**
801 >     * Sets  the current z-angle of this stuntdouble
802 >     * @param angle  new z-angle
803 >     */        
804 >    void setZangle(RealType angle) {
805 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_] = angle;
806 >    }
807 >
808 >    /**
809 >     * Sets  the z-angle of this stuntdouble in specified snapshot
810 >     * @param angle z-angle to be set
811 >     * @param snapshotNo
812 >     * @see #getZangle
813 >     */        
814 >    void setZangle(RealType angle, int snapshotNo) {
815 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_] = angle;
816 >    }
817 >
818 >    /**
819 >     * Adds z-angle into the previous z-angle of this stuntdouble
820 >     * @param angle  new z-angle
821 >     * @see #getZangle
822 >     */        
823 >    void addPrevZangle(RealType angle) {
824 >      ((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_] += angle;
825 >    }
826 >      
827 >    /**
828 >     * Adds z-angle into the current z-angle of this stuntdouble
829 >     * @param angle  new z-angle
830 >     */        
831 >    void addZangle(RealType angle) {
832 >      ((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_] += angle;
833 >    }
834 >
835 >    /**
836 >     * Adds z-angle into the z-angle of this stuntdouble in specified snapshot
837 >     * @param angle z-angle to be add
838 >     * @param snapshotNo
839 >     * @see #getZangle
840 >     */        
841 >    void addZangle(RealType angle, int snapshotNo) {
842 >      ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_] += angle;
843 >    }      
844 >
845 >    /** Set the force of this stuntdouble to zero */
846 >    void zeroForcesAndTorques();
847 >    /**
848 >     * Returns the inertia tensor of this stuntdouble
849 >     * @return the inertia tensor of this stuntdouble
850 >     */
851 >    virtual Mat3x3d getI() = 0;
852 >
853 >    /**
854 >     * Returns the gradient of this stuntdouble
855 >     * @return the gradient of this stuntdouble
856 >     */
857 >    virtual std::vector<RealType> getGrad() = 0;
858 >
859 >    /**
860 >     * Tests the  if this stuntdouble is a  linear rigidbody
861 >     *
862 >     * @return true if this stuntdouble is a  linear rigidbody, otherwise return false
863 >     * @note atom and directional atom will always return false
864 >     *
865 >     * @see #linearAxis
866 >     */        
867 >    bool isLinear() {
868 >      return linear_;
869 >    }
870 >
871 >    /**
872 >     * Returns the linear axis of the rigidbody, atom and directional atom will always return -1
873 >     *
874 >     * @return the linear axis of the rigidbody
875 >     *
876 >     * @see #isLinear
877 >     */
878 >    int linearAxis() {
879 >      return linearAxis_;
880 >    }
881 >
882 >    /** Returns the mass of this stuntdouble */
883 >    RealType getMass() {
884 >      return mass_;
885 >    }
886 >
887 >    /**
888 >     * Sets the mass of this stuntdoulbe
889 >     * @param mass the mass to be set
890 >     */        
891 >    void setMass(RealType mass) {
892 >      mass_ = mass;
893 >    }
894 >
895 >    /** Returns the name of this stuntdouble */
896 >    virtual std::string getType() = 0;
897 >        
898 >    /** Sets the name of this stuntRealType*/
899 >    virtual void setType(const std::string& name) {}
900 >
901 >    /**
902 >     * Converts a lab fixed vector to a body fixed vector.
903 >     * @return body fixed vector
904 >     * @param v lab fixed vector
905 >     */
906 >    Vector3d lab2Body(const Vector3d& v) {
907 >      return getA() * v;
908 >    }
909 >
910 >    Vector3d lab2Body(const Vector3d& v, int frame) {
911 >      return getA(frame) * v;
912 >    }
913 >
914 >    /**
915 >     * Converts a body fixed vector to a lab fixed vector.
916 >     * @return corresponding lab fixed vector
917 >     * @param v body fixed vector
918 >     */
919 >    Vector3d body2Lab(const Vector3d& v){
920 >      return getA().transpose() * v;
921 >    }
922 >
923 >    Vector3d body2Lab(const Vector3d& v, int frame){
924 >      return getA(frame).transpose() * v;
925 >    }
926 >    /**
927 >     * <p>
928 >     * The purpose of the Visitor Pattern is to encapsulate an operation that you want to perform on
929 >     * the elements of a data structure. In this way, you can change the operation being performed
930 >     * on a structure without the need of changing the classes of the elements that you are operating
931 >     * on. Using a Visitor pattern allows you to decouple the classes for the data structure and the
932 >     * algorithms used upon them
933 >     * </p>
934 >     * @param v visitor
935 >     */      
936 >    virtual void accept(BaseVisitor* v) = 0;
937 >
938 >    //below functions are just forward functions
939 >    /**
940 >     * Adds property into property map
941 >     * @param genData GenericData to be added into PropertyMap
942 >     */
943 >    void addProperty(GenericData* genData);
944 >
945 >    /**
946 >     * Removes property from PropertyMap by name
947 >     * @param propName the name of property to be removed
948 >     */
949 >    void removeProperty(const std::string& propName);
950 >
951 >    /**
952 >     * clear all of the properties
953 >     */
954 >    void clearProperties();
955 >
956 >    /**
957 >     * Returns all names of properties
958 >     * @return all names of properties
959 >     */
960 >    std::vector<std::string> getPropertyNames();
961 >
962 >    /**
963 >     * Returns all of the properties in PropertyMap
964 >     * @return all of the properties in PropertyMap
965 >     */      
966 >    std::vector<GenericData*> getProperties();
967 >
968 >    /**
969 >     * Returns property
970 >     * @param propName name of property
971 >     * @return a pointer point to property with propName. If no property named propName
972 >     * exists, return NULL
973 >     */      
974 >    GenericData* getPropertyByName(const std::string& propName);
975 >
976 >  protected:
977 >        
978 >    StuntDouble(ObjectType objType, DataStoragePointer storage);
979 >        
980 >    StuntDouble(const StuntDouble& sd);
981 >    StuntDouble& operator=(const StuntDouble& sd);
982 >
983 >    ObjectType objType_;
984 >    DataStoragePointer storage_;
985 >    SnapshotManager* snapshotMan_;
986 >        
987 >    bool linear_;
988 >    int linearAxis_;        
989 >
990 >        
991 >    int globalIndex_;
992 >    int globalIntegrableObjectIndex_;
993 >    int localIndex_;
994 >
995 >
996 >    RealType mass_;
997 >        
998 >  private:
999 >        
1000 >    PropertyMap properties_;
1001 >  };
1002 >
1003 > }//end namespace oopse
1004 > #endif //PRIMITIVES_STUNTDOUBLE_HPP

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines