ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/primitives/StuntDouble.hpp
Revision: 1803
Committed: Tue Nov 30 17:54:22 2004 UTC (19 years, 8 months ago) by tim
File size: 29676 byte(s)
Log Message:
more get fixed

File Contents

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

Properties

Name Value
svn:executable *