ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/primitives/StuntDouble.hpp
Revision: 2204
Committed: Fri Apr 15 22:04:00 2005 UTC (19 years, 2 months ago) by gezelter
File size: 28096 byte(s)
Log Message:
xemacs has been drafted to perform our indentation services

File Contents

# User Rev Content
1 gezelter 2204 /*
2 gezelter 1930 * 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 gezelter 2204 #ifndef PRIMITIVES_STUNTDOUBLE_HPP
50     #define PRIMITIVES_STUNTDOUBLE_HPP
51 gezelter 1490
52 gezelter 1930 #include <vector>
53 gezelter 1490
54 gezelter 1930 #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 gezelter 1490
63 tim 1625
64 gezelter 1930
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 gezelter 2204 class StuntDouble{
78     public:
79 gezelter 1490
80 gezelter 2204 enum ObjectType{
81     otAtom,
82     otDAtom,
83     otRigidBody
84     };
85 gezelter 1490
86 gezelter 2204 virtual ~StuntDouble();
87 gezelter 1930
88 gezelter 2204 /**
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 gezelter 1490
96 gezelter 2204 /**
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 gezelter 1930
104 gezelter 2204 /**
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 gezelter 1490
112 gezelter 2204 /**
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 gezelter 1490
120 gezelter 2204 /**
121     * Sets the Snapshot Manager of this stuntdouble
122     */
123     void setSnapshotManager(SnapshotManager* sman) {
124     snapshotMan_ = sman;
125     }
126 gezelter 1490
127 gezelter 2204 /**
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 gezelter 1490
135 gezelter 2204 /**
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 gezelter 1490
143 gezelter 2204 /**
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 gezelter 1490
151 gezelter 2204 /**
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 gezelter 1490
159 gezelter 2204 /**
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 gezelter 1930
167 gezelter 2204 /**
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 gezelter 1490
175 gezelter 2204 /**
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 gezelter 1490
184 gezelter 2204 /**
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 gezelter 1930
193 gezelter 2204 /**
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 gezelter 1490
203 gezelter 2204 /**
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 gezelter 1490
211 gezelter 2204 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).position[localIndex_] = pos;
212 gezelter 1490
213 gezelter 2204 }
214 gezelter 1930
215 gezelter 2204 /**
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 gezelter 1930
223 gezelter 2204 /**
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 gezelter 1490
231 gezelter 2204 /**
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 gezelter 1490
240 gezelter 2204 /**
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 gezelter 1930
249 gezelter 2204 /**
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 gezelter 1930
257 gezelter 2204 /**
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 gezelter 1930
267 gezelter 2204 /**
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 gezelter 1930
275 gezelter 2204 /**
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 gezelter 1930
283 gezelter 2204 /**
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 gezelter 1930
293 gezelter 2204 /**
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 gezelter 1930
302 gezelter 2204 /**
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 gezelter 1930
310 gezelter 2204 /**
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 gezelter 1930
320 gezelter 2204 /**
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 gezelter 1930
328 gezelter 2204 /**
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 gezelter 1930
336 gezelter 2204 /**
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 gezelter 1930
345 gezelter 2204 /**
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 gezelter 1930
354 gezelter 2204 /**
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 gezelter 1930
362 gezelter 2204 /**
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 gezelter 1930
372 gezelter 2204 /**
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 gezelter 1930
380 gezelter 2204 /**
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 gezelter 1930
388 gezelter 2204 /**
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 gezelter 1930
397 gezelter 2204 /**
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 gezelter 1930
406 gezelter 2204 /**
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 gezelter 1930
415 gezelter 2204 /**
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 gezelter 1930
426 gezelter 2204 /**
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 gezelter 1930
434 gezelter 2204 /**
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 gezelter 1930
442 gezelter 2204 /**
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 gezelter 1930
451 gezelter 2204 /**
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 gezelter 1930
461 gezelter 2204 /**
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 gezelter 1930
469 gezelter 2204 /**
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 gezelter 1930
480 gezelter 2204 /**
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 gezelter 1930
488 gezelter 2204 /**
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 gezelter 1930
496 gezelter 2204 /**
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 gezelter 1930
506 gezelter 2204 /**
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 gezelter 1930
514 gezelter 2204 /**
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 gezelter 1930
522 gezelter 2204 /**
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 gezelter 1930
532 gezelter 2204 /**
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 gezelter 1930
542 gezelter 2204 /**
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 gezelter 1930
550 gezelter 2204 /**
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 gezelter 1930
561 gezelter 2204 /**
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 gezelter 1930
571 gezelter 2204 /**
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 gezelter 1930
579 gezelter 2204 /**
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 gezelter 1930
590 gezelter 2204 /**
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 gezelter 1930
598 gezelter 2204 /**
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 gezelter 1930
606 gezelter 2204 /**
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 gezelter 1930
616 gezelter 2204 /**
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 gezelter 1930
626 gezelter 2204 /**
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 gezelter 1930
634 gezelter 2204 /**
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 gezelter 1930
645 gezelter 2204 /**
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 gezelter 1930
655 gezelter 2204 /**
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 gezelter 1930
663 gezelter 2204 /**
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 gezelter 1930
674    
675 gezelter 2204 /**
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 gezelter 1930
683 gezelter 2204 /**
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 gezelter 1930
691 gezelter 2204 /**
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 gezelter 1930
700 gezelter 2204 /**
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 gezelter 1930
709 gezelter 2204 /**
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 gezelter 1930
717 gezelter 2204 /**
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 gezelter 1930
727 gezelter 2204 /**
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 gezelter 1930
736 gezelter 2204 /**
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 gezelter 1930
744 gezelter 2204 /**
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 gezelter 1930
754 gezelter 2204 /** 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 gezelter 1930
762 gezelter 2204 /**
763     * Returns the gradient of this stuntdouble
764     * @return the gradient of this stuntdouble
765     */
766     virtual std::vector<double> getGrad() = 0;
767 gezelter 1930
768 gezelter 2204 /**
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 gezelter 1930
780 gezelter 2204 /**
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 gezelter 1930
791 gezelter 2204 /** Returns the mass of this stuntdouble */
792     double getMass() {
793     return mass_;
794     }
795 gezelter 1930
796 gezelter 2204 /**
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 gezelter 1930
804 gezelter 2204 /** Returns the name of this stuntdouble */
805     virtual std::string getType() = 0;
806 gezelter 1930
807 gezelter 2204 /** Sets the name of this stuntdouble*/
808     virtual void setType(const std::string& name) {}
809 gezelter 1930
810 gezelter 2204 /**
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 gezelter 1930
819 gezelter 2204 Vector3d lab2Body(const Vector3d& v, int frame) {
820     return getA(frame) * v;
821     }
822 tim 2018
823 gezelter 2204 /**
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 tim 2018
832 gezelter 2204 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 gezelter 1930
847 gezelter 2204 //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 gezelter 1930
854 gezelter 2204 /**
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 gezelter 1930
860 gezelter 2204 /**
861     * clear all of the properties
862     */
863     void clearProperties();
864 gezelter 1930
865 gezelter 2204 /**
866     * Returns all names of properties
867     * @return all names of properties
868     */
869     std::vector<std::string> getPropertyNames();
870 gezelter 1930
871 gezelter 2204 /**
872     * Returns all of the properties in PropertyMap
873     * @return all of the properties in PropertyMap
874     */
875     std::vector<GenericData*> getProperties();
876 gezelter 1930
877 gezelter 2204 /**
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 gezelter 1930
885 gezelter 2204 protected:
886 gezelter 1930
887 gezelter 2204 StuntDouble(ObjectType objType, DataStoragePointer storage);
888 gezelter 1930
889 gezelter 2204 StuntDouble(const StuntDouble& sd);
890     StuntDouble& operator=(const StuntDouble& sd);
891 gezelter 1930
892 gezelter 2204 ObjectType objType_;
893     DataStoragePointer storage_;
894     SnapshotManager* snapshotMan_;
895 gezelter 1930
896 gezelter 2204 bool linear_;
897     int linearAxis_;
898 gezelter 1930
899    
900 gezelter 2204 int globalIndex_;
901     int localIndex_;
902 gezelter 1930
903    
904 gezelter 2204 double mass_;
905 gezelter 1930
906 gezelter 2204 private:
907 gezelter 1930
908 gezelter 2204 PropertyMap properties_;
909     };
910 gezelter 1490
911 gezelter 1930 }//end namespace oopse
912     #endif //PRIMITIVES_STUNTDOUBLE_HPP

Properties

Name Value
svn:executable *