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

Comparing trunk/OOPSE-3.0/test/brains/StuntDouble.hpp (file contents):
Revision 1639 by tim, Fri Oct 22 23:09:57 2004 UTC vs.
Revision 1684 by tim, Fri Oct 29 16:20:50 2004 UTC

# Line 22 | Line 22
22   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23   *
24   */
25 +
26 + /**
27 + * @file StuntDouble.hpp
28 + * @author    tlin
29 + * @date  10/22/2004
30 + * @version 1.0
31 + */
32 +  
33   #ifndef _STUNTDOUBLE_HPP_
34   #define _STUNTDOUBLE_HPP_
35  
# Line 29 | Line 37
37  
38   #include <core/BaseVisitor.hpp>
39   #include <math/Quaternion.hpp>
40 < #include <math/Mat3x3d.hpp>
41 < #include <math/Vector3d.hpp>
42 < #include <util/PropertyMap.hpp>
40 > #include <math/SquareMatrix3.hpp>
41 > #include <math/Vector3.hpp>
42 > #include <utils/PropertyMap.hpp>
43  
44   namespace oopse{
45  
46 +
47 +  
48    /**
49 <   * The base class for atom types. Typically, atom types are used to descibe the behavior of an atom
50 <   * of a element in differnet enviroment. In OOPSE, atom types are also used to represent the coarse-
51 <   * grainded atom
52 <   * @author    tlin
53 <   * @date  09/08/2004
54 <   * @version 1.0
49 >   * @class StuntDouble StuntDouble.hpp "Primitives/StuntDouble.hpp"
50 >   * @brief
51 >   * StuntDouble is a very strange idea.  A StuntDouble stands in for
52 >   * some object that can be manipulated by the Integrators or
53 >   * Minimizers.  Some of the manipulable objects are Atoms, some are
54 >   * DirectionalAtoms, and some are RigidBodies.  StuntDouble
55 >   * provides an interface for the Integrators and Minimizers to use,
56 >   * and does some preliminary sanity checking so that the program
57 >   * doesn't try to do something stupid like torque an Atom
58 >   * @note the dynamoc data of stuntdouble will be stored outside of the class
59     */
46
47  /*
48   * Design Decision:
49   * the member data of stuntdouble will be stored outside of the class
50   */
60     class StuntDouble{
61 <    public:    
61 >   public:    
62  
63 +        enum ObjectType{
64 +            otAtom,
65 +            otDAtom,
66 +            otRigidBody
67 +        };
68 +
69 +        virtual ~StuntDouble();
70 +        
71          /**
72           * Returns the global index of this stuntdouble.
73           * @return  the global index of this stuntdouble
# Line 83 | Line 100 | namespace oopse{
100              localIndex_ = index;
101          }
102  
103 +        /**
104 +         * Tests if this stuntdouble is an atom
105 +         * @return true is this stuntdouble is an atom(or a directional atom), return false otherwise
106 +         */
107 +        bool isAtom(){
108 +            return objType_ == otAtom || objType_ == otDAtom;
109 +        }
110 +
111 +        /**
112 +         * Tests if this stuntdouble is an directional atom
113 +         * @return true if this stuntdouble is an directional atom, return false otherwise
114 +         */
115 +        bool isDirectionalAtom(){
116 +            return objType_ == otDAtom;
117 +        }
118 +
119 +        /**
120 +         * Tests if this stuntdouble is a rigid body.
121 +         * @return true if this stuntdouble is a rigid body, otherwise return false
122 +         */
123 +        bool isRigidBody(){
124 +            return objType_ == otRigidBody;
125 +        }
126 +
127 +        /**
128 +         * Tests if this stuntdouble is a directional one.
129 +         * @return true is this stuntdouble is a directional atom or a rigid body, return false otherwise
130 +         */
131 +        bool isDirectional(){
132 +            return isDirectionalAtom() || isRigidBody();
133 +        }
134 +
135         /**
136 <         * Returns  the previous position of this stuntdouble
136 >         * Returns the previous position of this stuntdouble
137           * @return the position of this stuntdouble
138           */    
139          void Vector3d getPrevPos() {
140 <            return (snapshotMan_->getPrevSnapshot())->storage->position[localId_];
140 >            return (snapshotMan_->getPrevSnapshot())->storage_->position[localIndex_];
141          }
142        
143          /**
144 <         * Returns  the current position of this stuntdouble
144 >         * Returns the current position of this stuntdouble
145           * @return the position of this stuntdouble
146           */    
147          void Vector3d getPos() {
148 <            return (snapshotMan_->getCurrentSnapshot())->storage->position[localId_];
148 >            return (snapshotMan_->getCurrentSnapshot())->storage_->position[localIndex_];
149          }
150  
151         /**
152 <         * Returns  the position of this stuntdouble in specified snapshot
104 <         *
152 >         * Returns the position of this stuntdouble in specified snapshot
153           * @return the position of this stuntdouble
154           * @param snapshotNo
155           */    
156          Vector3d getPos(int snapshotNo) {
157 <            return (snapshotMan_->getSnapshot(snapShotNo))->storage->position[localId_];
157 >            return (snapshotMan_->getSnapshot(snapShotNo))->storage_->position[localIndex_];
158          }
159  
160         /**
161           * Sets  the previous position of this stuntdouble
114         *
162           * @param pos  new position
163           * @see #getPos
164           */        
165         void setPrevPos(const Vector3d& pos) {
166 <            (snapshotMan_->getPrevSnapshot())->storage->position[localId_] = pos;
166 >            (snapshotMan_->getPrevSnapshot())->storage_->position[localIndex_] = pos;
167         }
168        
169         /**
# Line 124 | Line 171 | namespace oopse{
171           * @param pos  new position
172           */        
173          void setPos(const Vector3d& pos) {
174 <            (snapshotMan_->getCurrentSnapshot())->storage->position[localId_] = pos;
174 >            (snapshotMan_->getCurrentSnapshot())->storage_->position[localIndex_] = pos;
175          }
176  
177         /**
178           * Sets  the position of this stuntdouble in specified snapshot
132         *
179           * @param pos position to be set
180           * @param snapshotNo
181           * @see #getPos
182           */        
183          void setPos(const Vector3d& pos, int snapshotNo) {
184 <            (snapshotMan_->getSnapshot(snapshotNo))->storage->position[localId_] = pos;
184 >            (snapshotMan_->getSnapshot(snapshotNo))->storage_->position[localIndex_] = pos;
185          }
186        
187         /**
188 <         * Returns  the previous velocity of this stuntdouble
188 >         * Returns the previous velocity of this stuntdouble
189           * @return the velocity of this stuntdouble
190           */    
191          Vector3d getPrevVel() {
192 <            return (snapshotMan_->getPrevSnapshot())->storage->velocity[localId_];
192 >            return (snapshotMan_->getPrevSnapshot())->storage_->velocity[localIndex_];
193          }
194        
195          /**
196 <         * Returns  the current velocity of this stuntdouble
196 >         * Returns the current velocity of this stuntdouble
197           * @return the velocity of this stuntdouble
198           */    
199          Vector3d getVel() {
200 <            return (snapshotMan_->getCurrentSnapshot())->storage->velocity[localId_];
200 >            return (snapshotMan_->getCurrentSnapshot())->storage_->velocity[localIndex_];
201          }
202  
203         /**
204 <         * Returns  the velocity of this stuntdouble in specified snapshot
159 <         *
204 >         * Returns the velocity of this stuntdouble in specified snapshot
205           * @return the velocity of this stuntdouble
206           * @param snapshotNo
207           */    
208           Vector3d getVel(int snapshotNo) {
209 <            return (snapshotMan_->getSnapshot(snapShotNo))->storage->velocity[localId_];
209 >            return (snapshotMan_->getSnapshot(snapShotNo))->storage_->velocity[localIndex_];
210          }
211  
212         /**
213           * Sets  the previous velocity of this stuntdouble
169         *
214           * @param vel  new velocity
215           * @see #getVel
216           */        
217         void setPrevVel(const Vector3d& vel) {
218 <            (snapshotMan_->getPrevSnapshot())->storage->velocity[localId_] = vel;
218 >            (snapshotMan_->getPrevSnapshot())->storage_->velocity[localIndex_] = vel;
219         }
220        
221         /**
# Line 179 | Line 223 | namespace oopse{
223           * @param vel  new velocity
224           */        
225          void setVel(const Vector3d& vel) {
226 <            (snapshotMan_->getCurrentSnapshot())->storage->velocity[localId_] = vel;
226 >            (snapshotMan_->getCurrentSnapshot())->storage_->velocity[localIndex_] = vel;
227          }
228  
229         /**
230           * Sets  the velocity of this stuntdouble in specified snapshot
187         *
231           * @param vel velocity to be set
232           * @param snapshotNo
233           * @see #getVel
234           */        
235          void setVel(const Vector3d& vel, int snapshotNo) {
236 <            (snapshotMan_->getSnapshot(snapshotNo))->storage->velocity[localId_] = vel;
236 >            (snapshotMan_->getSnapshot(snapshotNo))->storage_->velocity[localIndex_] = vel;
237          }
238  
239         /**
240 <         * Returns  the previous rotation matrix of this stuntdouble
240 >         * Returns the previous rotation matrix of this stuntdouble
241           * @return the rotation matrix of this stuntdouble
242           */    
243          RotMat3x3d getPrevA() {
244 <            return (snapshotMan_->getPrevSnapshot())->storage->aMat[localId_];
244 >            return (snapshotMan_->getPrevSnapshot())->storage_->aMat[localIndex_];
245          }
246        
247          /**
248 <         * Returns  the current rotation matrix of this stuntdouble
248 >         * Returns the current rotation matrix of this stuntdouble
249           * @return the rotation matrix of this stuntdouble
250           */    
251          RotMat3x3d getA() {
252 <            return (snapshotMan_->getCurrentSnapshot())->storage->aMat[localId_];
252 >            return (snapshotMan_->getCurrentSnapshot())->storage_->aMat[localIndex_];
253          }
254  
255         /**
256 <         * Returns  the rotation matrix of this stuntdouble in specified snapshot
256 >         * Returns the rotation matrix of this stuntdouble in specified snapshot
257           *
258           * @return the rotation matrix of this stuntdouble
259           * @param snapshotNo
260           */    
261           RotMat3x3d getA(int snapshotNo) {
262 <            return (snapshotMan_->getSnapshot(snapShotNo))->storage->aMat[localId_];
262 >            return (snapshotMan_->getSnapshot(snapShotNo))->storage_->aMat[localIndex_];
263          }
264  
265         /**
266           * Sets  the previous rotation matrix of this stuntdouble
224         *
267           * @param a  new rotation matrix
268           * @see #getA
269           */        
270 <       void setPrevA(const RotMat3x3d& a) {
271 <            (snapshotMan_->getPrevSnapshot())->storage->aMat[localId_] = a;
270 >       virtual void setPrevA(const RotMat3x3d& a) {
271 >            (snapshotMan_->getPrevSnapshot())->storage_->aMat[localIndex_] = a;
272         }
273        
274         /**
275           * Sets  the current rotation matrix of this stuntdouble
276           * @param a  new rotation matrix
277           */        
278 <        void setA(const RotMat3x3d& a) {
279 <            (snapshotMan_->getCurrentSnapshot())->storage->aMat[localId_] = a;
278 >        virtual void setA(const RotMat3x3d& a) {
279 >            (snapshotMan_->getCurrentSnapshot())->storage_->aMat[localIndex_] = a;
280          }
281  
282         /**
283           * Sets  the rotation matrix of this stuntdouble in specified snapshot
242         *
284           * @param a rotation matrix to be set
285           * @param snapshotNo
286           * @see #getA
287           */        
288 <        void setA(const RotMat3x3d& a, int snapshotNo) {
289 <            (snapshotMan_->getSnapshot(snapshotNo))->storage->a[localId_] = a;
288 >        virtual void setA(const RotMat3x3d& a, int snapshotNo) {
289 >            (snapshotMan_->getSnapshot(snapshotNo))->storage_->aMat[localIndex_] = a;
290          }      
291  
292         /**
293 <         * Returns  the previous angular momentum of this stuntdouble
293 >         * Returns the previous angular momentum of this stuntdouble (body-fixed).
294           * @return the angular momentum of this stuntdouble
295           */    
296          Vector3d getPrevJ() {
297 <            return (snapshotMan_->getPrevSnapshot())->storage->angularMomentum[localId_];
297 >            return (snapshotMan_->getPrevSnapshot())->storage_->angularMomentum[localIndex_];
298          }
299        
300          /**
301 <         * Returns  the current angular momentum of this stuntdouble
301 >         * Returns the current angular momentum of this stuntdouble (body -fixed).
302           * @return the angular momentum of this stuntdouble
303           */    
304          Vector3d getJ() {
305 <            return (snapshotMan_->getCurrentSnapshot())->storage->angularMomentum[localId_];
305 >            return (snapshotMan_->getCurrentSnapshot())->storage_->angularMomentum[localIndex_];
306          }
307  
308         /**
309 <         * Returns  the angular momentum of this stuntdouble in specified snapshot
269 <         *
309 >         * Returns the angular momentum of this stuntdouble in specified snapshot (body-fixed).
310           * @return the angular momentum of this stuntdouble
311           * @param snapshotNo
312           */    
313           Vector3d getJ(int snapshotNo) {
314 <            return (snapshotMan_->getSnapshot(snapShotNo))->storage->angularMomentum[localId_];
314 >            return (snapshotMan_->getSnapshot(snapShotNo))->storage_->angularMomentum[localIndex_];
315          }
316  
317         /**
318 <         * Sets  the previous angular momentum of this stuntdouble
279 <         *
318 >         * Sets  the previous angular momentum of this stuntdouble (body-fixed).
319           * @param angMom  new angular momentum
320           * @see #getJ
321           */        
322         void setPrevJ(const Vector3d& angMom) {
323 <            (snapshotMan_->getPrevSnapshot())->storage->angularMomentum[localId_] = angMom;
323 >            (snapshotMan_->getPrevSnapshot())->storage_->angularMomentum[localIndex_] = angMom;
324         }
325        
326         /**
327 <         * Sets  the current angular momentum of this stuntdouble
327 >         * Sets  the current angular momentum of this stuntdouble (body-fixed).
328           * @param angMom  new angular momentum
329           */        
330          void setJ(const Vector3d& angMom) {
331 <            (snapshotMan_->getCurrentSnapshot())->storage->angularMomentum[localId_] = angMom;
331 >            (snapshotMan_->getCurrentSnapshot())->storage_->angularMomentum[localIndex_] = angMom;
332          }
333  
334         /**
335 <         * Sets the angular momentum of this stuntdouble in specified snapshot
297 <         *
335 >         * Sets the angular momentum of this stuntdouble in specified snapshot(body-fixed).
336           * @param angMom angular momentum to be set
337           * @param snapshotNo
338           * @see #getJ
339           */        
340          void setJ(const Vector3d& angMom, int snapshotNo) {
341 <            (snapshotMan_->getSnapshot(snapshotNo))->storage->angularMomentum[localId_] = angMom;
341 >            (snapshotMan_->getSnapshot(snapshotNo))->storage_->angularMomentum[localIndex_] = angMom;
342          }
343          
344         /**
345 <         * Returns  the previous quaternion of this stuntdouble
345 >         * Returns the previous quaternion of this stuntdouble
346           * @return the quaternion of this stuntdouble
347           */    
348          Quat4d getPrevQ() {
349 <            return (snapshotMan_->getPrevSnapshot())->storage->aMat[localId_].toQuaternion();
349 >            return (snapshotMan_->getPrevSnapshot())->storage_->aMat[localIndex_].toQuaternion();
350          }
351        
352          /**
353 <         * Returns  the current quaternion of this stuntdouble
353 >         * Returns the current quaternion of this stuntdouble
354           * @return the quaternion of this stuntdouble
355           */    
356          Quat4d getQ() {
357 <            return (snapshotMan_->getCurrentSnapshot())->storage->aMat[localId_].toQuaternion();
357 >            return (snapshotMan_->getCurrentSnapshot())->storage_->aMat[localIndex_].toQuaternion();
358          }
359  
360         /**
361 <         * Returns  the quaternion of this stuntdouble in specified snapshot
324 <         *
361 >         * Returns the quaternion of this stuntdouble in specified snapshot
362           * @return the quaternion of this stuntdouble
363           * @param snapshotNo
364           */    
365           Quat4d getQ(int snapshotNo) {
366 <            return (snapshotMan_->getSnapshot(snapShotNo))->storage->aMat[localId_].toQuaternion();
366 >            return (snapshotMan_->getSnapshot(snapShotNo))->storage_->aMat[localIndex_].toQuaternion();
367          }
368  
369         /**
370           * Sets  the previous quaternion of this stuntdouble
334         *
371           * @param q  new quaternion
372 <         * @see #getQ
372 >         * @note actual storage data is rotation matrix
373           */        
374         void setPrevQ(const Quat4d& q) {
375 <            (snapshotMan_->getPrevSnapshot())->storage->aMat[localId_] = q;
375 >            (snapshotMan_->getPrevSnapshot())->storage_->aMat[localIndex_] = q;
376         }
377        
378         /**
379           * Sets  the current quaternion of this stuntdouble
380           * @param q  new quaternion
381 +         * @note actual storage data is rotation matrix
382           */        
383          void setQ(const Quat4d& q) {
384 <            (snapshotMan_->getCurrentSnapshot())->storage->aMat[localId_] = q;
384 >            (snapshotMan_->getCurrentSnapshot())->storage_->aMat[localIndex_] = q;
385          }
386  
387         /**
# Line 352 | Line 389 | namespace oopse{
389           *
390           * @param q quaternion to be set
391           * @param snapshotNo
392 <         * @see #getQ
392 >         * @note actual storage data is rotation matrix
393           */        
394          void setQ(const Quat4d& q, int snapshotNo) {
395 <            (snapshotMan_->getSnapshot(snapshotNo))->storage->aMat[localId_] = q;
395 >            (snapshotMan_->getSnapshot(snapshotNo))->storage_->aMat[localIndex_] = q;
396          }
397 +
398 +       /**
399 +         * Returns the previous euler angles of this stuntdouble
400 +         * @return the euler angles of this stuntdouble
401 +         */    
402 +        Vector3d getPrevEuler() {
403 +            return (snapshotMan_->getPrevSnapshot())->storage_->aMat[localIndex_].toEulerAngles();
404 +        }
405        
406 +        /**
407 +         * Returns the current euler angles of this stuntdouble
408 +         * @return the euler angles of this stuntdouble
409 +         */    
410 +        Vector3d getEuler() {
411 +            return (snapshotMan_->getCurrentSnapshot())->storage_->aMat[localIndex_].toEulerAngles();
412 +        }
413 +
414         /**
415 <         * Returns the force of this stuntdouble
415 >         * Returns the euler angles of this stuntdouble in specified snapshot.
416 >         * @return the euler angles of this stuntdouble
417 >         * @param snapshotNo
418 >         */    
419 >         Vector3d getEuler(int snapshotNo) {
420 >            return (snapshotMan_->getSnapshot(snapShotNo))->storage_->aMat[localIndex_].toEulerAngles();
421 >        }
422 >
423 >       /**
424 >         * Sets  the previous euler angles of this stuntdouble.
425 >         * @param euler  new euler angles
426 >         * @see #getEuler
427 >         * @note actual storage data is rotation matrix        
428 >         */        
429 >       void setPrevEuler(const Vector3d& euler) {
430 >            (snapshotMan_->getPrevSnapshot())->storage_->aMat[localIndex_] = euler;
431 >       }
432 >      
433 >       /**
434 >         * Sets  the current euler angles of this stuntdouble
435 >         * @param euler  new euler angles
436 >         */        
437 >        void setEuler(const Vector3d& euler) {
438 >            (snapshotMan_->getCurrentSnapshot())->storage_->aMat[localIndex_] = euler;
439 >        }
440 >
441 >       /**
442 >         * Sets  the euler angles  of this stuntdouble in specified snapshot
443           *
444 <         * @return the quaternion of this stuntdouble
444 >         * @param euler euler angles to be set
445 >         * @param snapshotNo
446 >         * @note actual storage data is rotation matrix                  
447 >         */        
448 >        void setEuler(const Vector3d& euler, int snapshotNo) {
449 >            (snapshotMan_->getSnapshot(snapshotNo))->storage_->aMat[localIndex_] = euler;
450 >        }
451 >      
452 >       /**
453 >         * Returns the previous unit vectors of this stuntdouble
454 >         * @return the unit vectors of this stuntdouble
455 >         */    
456 >        Vector3d getPrevUnitVector() {
457 >            return (snapshotMan_->getPrevSnapshot())->storage_->unitVector[localIndex_];
458 >        }
459 >      
460 >        /**
461 >         * Returns the current unit vectors of this stuntdouble
462 >         * @return the unit vectors of this stuntdouble
463 >         */    
464 >        Vector3d getUnitVector() {
465 >            return (snapshotMan_->getCurrentSnapshot())->storage_->unitVector[localIndex_];
466 >        }
467 >
468 >       /**
469 >         * Returns the unit vectors of this stuntdouble in specified snapshot
470           *
471 <         * @see #setFrc
472 <         * @see #addFrc
473 <         */
474 <        virtual Vector3d getFrc() = 0;
471 >         * @return the unit vectors of this stuntdouble
472 >         * @param snapshotNo
473 >         */    
474 >         Vector3d getUnitVector(int snapshotNo) {
475 >            return (snapshotMan_->getSnapshot(snapShotNo))->storage_->unitVector[localIndex_];
476 >        }
477  
478         /**
479 <         * Sets the force of this stuntdouble
479 >         * Returns the previous force of this stuntdouble
480 >         * @return the force of this stuntdouble
481 >         */    
482 >        Vector3d getPrevFrc() {
483 >            return (snapshotMan_->getPrevSnapshot())->storage_->force[localIndex_];
484 >        }
485 >      
486 >        /**
487 >         * Returns the current force of this stuntdouble
488 >         * @return the force of this stuntdouble
489 >         */    
490 >        Vector3d getFrc() {
491 >            return (snapshotMan_->getCurrentSnapshot())->storage_->force[localIndex_];
492 >        }
493 >
494 >       /**
495 >         * Returns the force of this stuntdouble in specified snapshot
496           *
497 <         * @param frc new force
497 >         * @return the force of this stuntdouble
498 >         * @param snapshotNo
499 >         */    
500 >         Vector3d getFrc(int snapshotNo) {
501 >            return (snapshotMan_->getSnapshot(snapShotNo))->storage_->force[localIndex_];
502 >        }
503 >
504 >       /**
505 >         * Sets  the previous force of this stuntdouble
506           *
507 +         * @param frc  new force
508           * @see #getFrc
509 <         * @see #addFrc
510 <         */    
511 <        virtual void setFrc(Vector3d& frc) = 0;
509 >         */        
510 >       void setPrevFrc(const Vector3d& frc) {
511 >            (snapshotMan_->getPrevSnapshot())->storage_->force[localIndex_] = frc;
512 >       }
513 >      
514 >       /**
515 >         * Sets  the current force of this stuntdouble
516 >         * @param frc  new force
517 >         */        
518 >        void setFrc(const Vector3d& frc) {
519 >            (snapshotMan_->getCurrentSnapshot())->storage_->force[localIndex_] = frc;
520 >        }
521  
522         /**
523 <         * Adds the force into this stuntdouble
523 >         * Sets  the force of this stuntdouble in specified snapshot
524           *
525 <         * @param frc  force to be added
525 >         * @param frc force to be set
526 >         * @param snapshotNo
527 >         * @see #getFrc
528 >         */        
529 >        void setFrc(const Vector3d& frc, int snapshotNo) {
530 >            (snapshotMan_->getSnapshot(snapshotNo))->storage_->force[localIndex_] = frc;
531 >        }
532 >
533 >       /**
534 >         * Adds force into the previous force of this stuntdouble
535           *
536 +         * @param frc  new force
537           * @see #getFrc
538 <         * @see #setFrc
539 <         */          
540 <        virtual void addFrc(Vector3d& frc) = 0;
538 >         */        
539 >       void setPrevFrc(const Vector3d& frc) {
540 >            (snapshotMan_->getPrevSnapshot())->storage_->force[localIndex_] += frc;
541 >       }
542 >      
543 >       /**
544 >         * Adds force into the current force of this stuntdouble
545 >         * @param frc  new force
546 >         */        
547 >        void setFrc(const Vector3d& frc) {
548 >            (snapshotMan_->getCurrentSnapshot())->storage_->force[localIndex_] += frc;
549 >        }
550  
551         /**
552 <         * Returns the torque of this stuntdouble
552 >         * Adds force into the force of this stuntdouble in specified snapshot
553 >         *
554 >         * @param frc force to be set
555 >         * @param snapshotNo
556 >         * @see #getFrc
557 >         */        
558 >        void setFrc(const Vector3d& frc, int snapshotNo) {
559 >            (snapshotMan_->getSnapshot(snapshotNo))->storage_->force[localIndex_] += frc;
560 >        }
561 >
562 >       /**
563 >         * Returns the previous torque of this stuntdouble
564 >         * @return the torque of this stuntdouble
565 >         */    
566 >        Vector3d getPrevTrq() {
567 >            return (snapshotMan_->getPrevSnapshot())->storage_->torque[localIndex_];
568 >        }
569 >      
570 >        /**
571 >         * Returns the current torque of this stuntdouble
572 >         * @return the torque of this stuntdouble
573 >         */    
574 >        Vector3d getTrq() {
575 >            return (snapshotMan_->getCurrentSnapshot())->storage_->torque[localIndex_];
576 >        }
577 >
578 >       /**
579 >         * Returns the torque of this stuntdouble in specified snapshot
580           *
581           * @return the torque of this stuntdouble
582 +         * @param snapshotNo
583 +         */    
584 +         Vector3d getTrq(int snapshotNo) {
585 +            return (snapshotMan_->getSnapshot(snapShotNo))->storage_->torque[localIndex_];
586 +        }
587 +
588 +       /**
589 +         * Sets  the previous torque of this stuntdouble
590           *
591 <         * @see #setTrq
592 <         * @see #addTrq
593 <         */
594 <        virtual Vector3d getTrq() = 0;
591 >         * @param trq  new torque
592 >         * @see #getTrq
593 >         */        
594 >       void setPrevTrq(const Vector3d& trq) {
595 >            (snapshotMan_->getPrevSnapshot())->storage_->torque[localIndex_] = trq;
596 >       }
597 >      
598 >       /**
599 >         * Sets  the current torque of this stuntdouble
600 >         * @param trq  new torque
601 >         */        
602 >        void setTrq(const Vector3d& trq) {
603 >            (snapshotMan_->getCurrentSnapshot())->storage_->torque[localIndex_] = trq;
604 >        }
605  
606         /**
607 <         * Sets the torque of this stuntdouble
607 >         * Sets  the torque of this stuntdouble in specified snapshot
608           *
609 <         * @param trq new torque
609 >         * @param trq torque to be set
610 >         * @param snapshotNo
611 >         * @see #getTrq
612 >         */        
613 >        void setTrq(const Vector3d& trq, int snapshotNo) {
614 >            (snapshotMan_->getSnapshot(snapshotNo))->storage_->torque[localIndex_] = trq;
615 >        }
616 >
617 >       /**
618 >         * Adds torque into the previous torque of this stuntdouble
619           *
620 +         * @param trq  new torque
621           * @see #getTrq
622 <         * @see #addTrq
623 <         */      
624 <        virtual void setTrq(Vector3d& trq) = 0;
622 >         */        
623 >       void addPrevTrq(const Vector3d& trq) {
624 >            (snapshotMan_->getPrevSnapshot())->storage_->torque[localIndex_] += trq;
625 >       }
626 >      
627 >       /**
628 >         * Adds torque into the current torque of this stuntdouble
629 >         * @param trq  new torque
630 >         */        
631 >        void addTrq(const Vector3d& trq) {
632 >            (snapshotMan_->getCurrentSnapshot())->storage_->torque[localIndex_] += trq;
633 >        }
634  
635         /**
636 <         * Adds the torque into this stuntdouble
636 >         * Adds torque into the torque of this stuntdouble in specified snapshot
637           *
638 <         * @param trq  torque to be added
639 <         *
638 >         * @param trq torque to be add
639 >         * @param snapshotNo
640           * @see #getTrq
641 <         * @see #setTrq
642 <         */
643 <        virtual void addTrq(Vector3d& trq) = 0;
641 >         */        
642 >        void addTrq(const Vector3d& trq, int snapshotNo) {
643 >            (snapshotMan_->getSnapshot(snapshotNo))->storage_->torque[localIndex_] += trq;
644 >        }      
645  
646 +
647         /**
648 +         * Returns the previous z-angle of this stuntdouble
649 +         * @return the z-angle of this stuntdouble
650 +         */    
651 +        Vector3d getPrevZangle() {
652 +            return (snapshotMan_->getPrevSnapshot())->storage_->zAngle[localIndex_];
653 +        }
654 +      
655 +        /**
656 +         * Returns the current z-angle of this stuntdouble
657 +         * @return the z-angle of this stuntdouble
658 +         */    
659 +        Vector3d getZangle() {
660 +            return (snapshotMan_->getCurrentSnapshot())->storage_->zAngle[localIndex_];
661 +        }
662 +
663 +       /**
664 +         * Returns the z-angle of this stuntdouble in specified snapshot
665 +         * @return the z-angle of this stuntdouble
666 +         * @param snapshotNo
667 +         */    
668 +         Vector3d getZangle(int snapshotNo) {
669 +            return (snapshotMan_->getSnapshot(snapShotNo))->storage_->zAngle[localIndex_];
670 +        }
671 +
672 +       /**
673 +         * Sets  the previous z-angle of this stuntdouble
674 +         * @param angle  new z-angle
675 +         * @see #getZangle
676 +         */        
677 +       void setPrevZangle(const Vector3d& angle) {
678 +            (snapshotMan_->getPrevSnapshot())->storage_->zAngle[localIndex_] = angle;
679 +       }
680 +      
681 +       /**
682 +         * Sets  the current z-angle of this stuntdouble
683 +         * @param angle  new z-angle
684 +         */        
685 +        void setZangle(const Vector3d& angle) {
686 +            (snapshotMan_->getCurrentSnapshot())->storage_->zAngle[localIndex_] = angle;
687 +        }
688 +
689 +       /**
690 +         * Sets  the z-angle of this stuntdouble in specified snapshot
691 +         * @param angle z-angle to be set
692 +         * @param snapshotNo
693 +         * @see #getZangle
694 +         */        
695 +        void setZangle(const Vector3d& angle, int snapshotNo) {
696 +            (snapshotMan_->getSnapshot(snapshotNo))->storage_->zAngle[localIndex_] = angle;
697 +        }
698 +
699 +       /**
700 +         * Adds z-angle into the previous z-angle of this stuntdouble
701 +         * @param angle  new z-angle
702 +         * @see #getZangle
703 +         */        
704 +       void addPrevZangle(const Vector3d& angle) {
705 +            (snapshotMan_->getPrevSnapshot())->storage_->zAngle[localIndex_] += angle;
706 +       }
707 +      
708 +       /**
709 +         * Adds z-angle into the current z-angle of this stuntdouble
710 +         * @param angle  new z-angle
711 +         */        
712 +        void addZangle(const Vector3d& angle) {
713 +            (snapshotMan_->getCurrentSnapshot())->storage_->zAngle[localIndex_] += angle;
714 +        }
715 +
716 +       /**
717 +         * Adds z-angle into the z-angle of this stuntdouble in specified snapshot
718 +         * @param angle z-angle to be add
719 +         * @param snapshotNo
720 +         * @see #getZangle
721 +         */        
722 +        void addZangle(const Vector3d& angle, int snapshotNo) {
723 +            (snapshotMan_->getSnapshot(snapshotNo))->storage_->zAngle[localIndex_] += angle;
724 +        }      
725 +
726 +       /**
727           * Returns the inertia tensor of this stuntdouble
423         *
728           * @return the inertia tensor of this stuntdouble
425         *
426         * @see #setI
729           */
730          virtual Mat3x3d getI() = 0;
731  
732         /**
431         * Sets the inertia tensor of this stuntdouble
432         *
433         * @param trq new inertia tensor
434         *
435         * @see #getI
436         */      
437        virtual void setI(Mat3x3d& I) = 0;
438
439       /**
733           * Returns the gradient of this stuntdouble
734 <         *
442 <         * @return the inertia tensor of this stuntdouble
443 <         *
444 <         * @see #setI
734 >         * @return the gradient of this stuntdouble
735           */
736          virtual std::vector<double> getGrad() = 0;
737  
738         /**
739 <         * Returns the euler angles of this stuntdouble
450 <         * <p>
451 <         *   <ol>
452 <         *   <il>
453 <         *   <il>
454 <         *   <il>
455 <         *   </ol>
456 <         * </p>
457 <         * @return the euler angles of this stuntdouble
739 >         * Tests the  if this stuntdouble is a  linear rigidbody
740           *
741 <         * @see #setEuler
742 <         */
743 <        virtual Vector3d getEuler() = 0;
741 >         * @return true if this stuntdouble is a  linear rigidbody, otherwise return false
742 >         * @note atom and directional atom will always return false
743 >         *
744 >         * @see #linearAxis
745 >         */        
746 >        bool isLinear() {
747 >            return linear_;
748 >        }
749  
750         /**
464         * Sets the euler angles of this stuntdouble
465         *
466         * @param e new euler angles
467         * <p>
468         *   <ol>
469         *   <il>e[0] = phi </il>
470         *   <il>e[1] = theta <il>
471         *   <il>e[2] = psi </il>
472         *   </ol>
473         * </p>
474         *
475         * @see #setEuler
476         */
477        virtual void setEuler(Vector3d& e) = 0;
478        
479        virtual bool isLinear() {return false;}
480
481       /**
751           * Returns the linear axis of the rigidbody, atom and directional atom will always return -1
752           *
753           * @return the linear axis of the rigidbody
754           *
755           * @see #isLinear
756           */
757 <        virtual int linearAxis() {return -1;}
757 >        int linearAxis() {
758 >            return linearAxis_;
759 >        }
760  
761 <       /**
762 <        * Returns the zangle
763 <        *
764 <        * @return the zangle
494 <        *
495 <        * @see #setZangle
496 <        * @see #addZangle
497 <        */
498 <        virtual double   getZangle() = 0;
761 >        /** Returns the mass of this stuntdouble */
762 >        double getMass() {
763 >            return mass_;
764 >        }
765  
766 <       /**
767 <        *
768 <        */
769 <        virtual void   setZangle(double zAngle) = 0;
766 >        /**
767 >         * Sets the mass of this stuntdoulbe
768 >         * @param mass the mass to be set
769 >         */        
770 >        void setMass(double mass) {
771 >            mass_ = mass;
772 >        }
773  
774 <       /**
775 <        *
776 <        */
777 <        virtual void   addZangle(double zAngle) = 0;
774 >        /** Returns the name of this stuntdouble */
775 >        std::string getType();
776 >        
777 >        /** Sets the name of this stuntdouble*/
778 >        void setType(const std::string& name);
779  
780 <       /**
781 <         *
780 >        /**
781 >         * Converts a lab fixed vector to a body fixed vector.
782 >         * @return body fixed vector
783 >         * @param v lab fixed vector
784 >         */
785 >        Vector3d lab2Body(const Vector3d& v);
786 >
787 >        /**
788 >         * Converts a body fixed vector to a lab fixed vector.
789 >         * @return corresponding lab fixed vector
790 >         * @param v body fixed vector
791 >         */
792 >        Vector3d body2Lab(const Vector3d& v);
793 >        /**
794           * <p>
795           * The purpose of the Visitor Pattern is to encapsulate an operation that you want to perform on
796           * the elements of a data structure. In this way, you can change the operation being performed
# Line 520 | Line 802 | namespace oopse{
802           */      
803          virtual void accept(BaseVisitor* v) = 0;
804  
523        StorageMethod getStorageMethd(){return stMethod;}
524        void setStorageMethod(StorageMethod method) {stMethod = method;}
525
805          //below functions are just forward functions
806          /**
807           * Adds property into property map
529         *
808           * @param genData GenericData to be added into PropertyMap
531         *
532         * @see #removeProperty
533         * @see #clearProperties
809           */
810 <        void addProperty(GenericData* genData) {  properties.addProperty(genData);  }
810 >        void addProperty(GenericData* genData);
811  
812          /**
813           * Removes property from PropertyMap by name
539         *
814           * @param propName the name of property to be removed
541         *
542         * @see #addProperty
543         * @see #clearProperties
815           */
816 <        void removeProperty(std::string& propName) {  properties.removeProperty();  }
816 >        void removeProperty(std::string& propName);
817  
818          /**
819           * clear all of the properties
549         *
550         * @see #addProperty
551         * @see #removeProperty
820           */
821 <        void clearProperties() {  properties.clearProperties(); }
821 >        void clearProperties();
822  
823          /**
824           * Returns all names of properties
557         *
825           * @return all names of properties
826           */
827 <        std::vector<std::string> getPropertyNames() {return properties.getPropertyNames();  }
827 >        std::vector<std::string> getPropertyNames();
828  
829          /**
830           * Returns all of the properties in PropertyMap
564         *
831           * @return all of the properties in PropertyMap
566         *
567         * @see #getPropertyByName
832           */      
833 <        std::vector<GenericData*> getProperties() { return properties.getProperties(); }
833 >        std::vector<GenericData*> getProperties();
834  
835          /**
836           * Returns property
573         *
837           * @param propName name of property
575         *
838           * @return a pointer point to property with propName. If no property named propName
839           * exists, return NULL
578         *
579         * @see #getProperties
840           */      
841 <        GenericData* getPropertyByName(std:string& propName) {  return properties.getPropertyByName(propName); }
841 >        GenericData* getPropertyByName(std:string& propName);
842  
843 <      private:
843 >    protected:
844          
845 <        int globalIndex_;
846 <        int localIndex_;
847 <        PropertyMap properties;
845 >        StuntDouble();
846 >        
847 >        StuntDouble(const StuntDouble& sd);
848 >        StuntDouble& operator=(const StuntDouble& sd);
849 >
850 >        ObjectType objType_;
851 >
852 >        bool linear_;
853 >        int linearAxis_;        
854 >
855          DataStoragePointer storage_;
856          SnapshotManager* snapshotMan_;
857 < };
857 >        
858 >    private:
859 >        
860 >        int globalIndex_;
861 >        int localIndex_;
862  
863 +        std::string name_;
864 +
865 +        double mass_;
866 +        
867 +        PropertyMap properties_;
868 +    };
869 +
870   }//end namespace oopse
871   #endif //ifndef _STUNTDOUBLE_HPP_

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines