[701] | 1 | // 04/01/00 : implantation de la persistance par classe deleguee - Guy Le Meur
|
---|
| 2 |
|
---|
[518] | 3 | #include "spherepos.h"
|
---|
| 4 |
|
---|
[701] | 5 | static char *head_spherepos_cc_ = "$Header: /Users/garnier/temp/CVSSophya/SophyaLib/Samba/spherepos.cc,v 1.4 2000-01-04 14:27:15 ansari Exp $";
|
---|
[518] | 6 |
|
---|
| 7 |
|
---|
| 8 | //................. SphereCoordSys class .................
|
---|
| 9 |
|
---|
| 10 | SphereCoordSys::SphereCoordSys(){
|
---|
| 11 | id_ = SphereCoordSys_NEUTRAL;
|
---|
| 12 | description_ = "NEUTRAL SphereCoordSystem";
|
---|
| 13 | }
|
---|
[701] | 14 | SphereCoordSys::SphereCoordSys(const SphereCoordSys& a )
|
---|
| 15 | {
|
---|
| 16 | id_ = a.id_;
|
---|
| 17 | description_ = a.description_;
|
---|
| 18 | }
|
---|
[518] | 19 |
|
---|
| 20 | SphereCoordSys::SphereCoordSys(int id, const string& description){
|
---|
| 21 | id_ = id;
|
---|
| 22 | description_ = description;
|
---|
| 23 | }
|
---|
| 24 |
|
---|
[525] | 25 | SphereCoordSys::~SphereCoordSys()
|
---|
| 26 | {
|
---|
| 27 | }
|
---|
[701] | 28 | SphereCoordSys& SphereCoordSys::operator = (const SphereCoordSys& a)
|
---|
| 29 | {
|
---|
| 30 | id_ = a.id_;
|
---|
| 31 | description_ = a.description_;
|
---|
| 32 | return *this;
|
---|
| 33 | }
|
---|
[525] | 34 |
|
---|
[701] | 35 |
|
---|
| 36 | ////////////////////////////////////////////////////////////////
|
---|
| 37 | // -------------------------------------------------------------------------
|
---|
| 38 | // Les objets delegues pour la gestion de persistance
|
---|
| 39 | // -------------------------------------------------------------------------
|
---|
| 40 |
|
---|
| 41 | FIO_SphereCoordSys::FIO_SphereCoordSys()
|
---|
| 42 | {
|
---|
| 43 | dobj=new SphereCoordSys;
|
---|
| 44 | ownobj=true;
|
---|
| 45 | }
|
---|
| 46 | FIO_SphereCoordSys::FIO_SphereCoordSys(string const & filename)
|
---|
| 47 | {
|
---|
| 48 | dobj=new SphereCoordSys;
|
---|
| 49 | ownobj=true;
|
---|
| 50 | Read(filename);
|
---|
| 51 | }
|
---|
| 52 | FIO_SphereCoordSys::FIO_SphereCoordSys(const SphereCoordSys & obj)
|
---|
| 53 | {
|
---|
| 54 | dobj = new SphereCoordSys(obj);
|
---|
| 55 | ownobj=true;
|
---|
| 56 | }
|
---|
| 57 | FIO_SphereCoordSys::FIO_SphereCoordSys(SphereCoordSys * obj)
|
---|
| 58 | {
|
---|
| 59 | dobj = obj;
|
---|
| 60 | ownobj=false;
|
---|
| 61 | }
|
---|
| 62 | FIO_SphereCoordSys::~FIO_SphereCoordSys()
|
---|
| 63 | {
|
---|
| 64 | if (ownobj && dobj) delete dobj;
|
---|
| 65 | }
|
---|
| 66 | AnyDataObj* FIO_SphereCoordSys::DataObj()
|
---|
| 67 | {
|
---|
| 68 | return(dobj);
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 |
|
---|
| 72 | void FIO_SphereCoordSys::ReadSelf(PInPersist& is)
|
---|
| 73 | {
|
---|
[518] | 74 | uint_8 itab[3];
|
---|
[701] | 75 | string description;
|
---|
[518] | 76 | is.Get(itab, 3);
|
---|
[701] | 77 | is.GetStr(description);
|
---|
| 78 | if (dobj == NULL) dobj = new SphereCoordSys(itab[1], description);
|
---|
| 79 | else *dobj= SphereCoordSys(itab[1], description);
|
---|
| 80 | }
|
---|
| 81 | void FIO_SphereCoordSys::WriteSelf(POutPersist& os) const
|
---|
[518] | 82 | {
|
---|
[701] | 83 | if (dobj == NULL) return; // Attention - $CHECK$ Guy 04/01/00
|
---|
[518] | 84 | // On ecrit 3 uint_8
|
---|
| 85 | // 0 : Numero de version, 1 : Id, 2 reserve a l
|
---|
| 86 | uint_8 itab[3];
|
---|
| 87 | itab[0] = 1;
|
---|
[701] | 88 | itab[1] = dobj->Id();
|
---|
[518] | 89 | itab[2] = 0;
|
---|
| 90 | os.Put(itab, 3);
|
---|
[701] | 91 | os.PutStr(dobj->description());
|
---|
| 92 | }
|
---|
[518] | 93 |
|
---|
[701] | 94 |
|
---|
| 95 |
|
---|
[518] | 96 | //................. SpherePosition class .................
|
---|
| 97 |
|
---|
| 98 | SpherePosition::SpherePosition()
|
---|
| 99 | : UnitVector()
|
---|
| 100 | {
|
---|
| 101 | cs_ = new SphereCoordSys;
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | SpherePosition::SpherePosition(double theta, double phi, SphereCoordSys* cs)
|
---|
| 105 | : UnitVector(theta, phi)
|
---|
| 106 | {
|
---|
| 107 | if (cs == NULL) cs_ = new SphereCoordSys;
|
---|
| 108 | else cs_ = cs;
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | SpherePosition::SpherePosition(double x, double y, double z, SphereCoordSys* cs)
|
---|
| 112 | : UnitVector(x, y, z)
|
---|
| 113 | {
|
---|
| 114 | if (cs == NULL) cs_ = new SphereCoordSys;
|
---|
| 115 | else cs_ = cs;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
[525] | 118 | SpherePosition::~SpherePosition()
|
---|
| 119 | {
|
---|
| 120 | if (cs_) delete cs_;
|
---|
| 121 | }
|
---|
| 122 |
|
---|
[682] | 123 | UnitVector SpherePosition::Transform(const SphereCoordSys& /*cs*/) const
|
---|
[518] | 124 | {
|
---|
| 125 | return(*this);
|
---|
| 126 | }
|
---|
| 127 |
|
---|
| 128 | double SpherePosition::Separation(const SpherePosition& gamma) const
|
---|
| 129 | {
|
---|
| 130 | return(this->SepAngle(gamma));
|
---|
| 131 | }
|
---|