[764] | 1 | // 04/01/00 : implantation de la persistance par classe deleguee - Guy Le Meur
|
---|
| 2 |
|
---|
| 3 | #include "spherepos.h"
|
---|
| 4 |
|
---|
| 5 | static char *head_spherepos_cc_ = "$Header: /Users/garnier/temp/CVSSophya/SophyaLib/SkyMap/spherepos.cc,v 1.1.1.1 2000-03-02 17:05:39 ansari Exp $";
|
---|
| 6 |
|
---|
| 7 |
|
---|
| 8 | //................. SphereCoordSys class .................
|
---|
| 9 |
|
---|
| 10 | SphereCoordSys::SphereCoordSys(){
|
---|
| 11 | id_ = SphereCoordSys_NEUTRAL;
|
---|
| 12 | description_ = "NEUTRAL SphereCoordSystem";
|
---|
| 13 | }
|
---|
| 14 | SphereCoordSys::SphereCoordSys(const SphereCoordSys& a )
|
---|
| 15 | {
|
---|
| 16 | id_ = a.id_;
|
---|
| 17 | description_ = a.description_;
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | SphereCoordSys::SphereCoordSys(int id, const string& description){
|
---|
| 21 | id_ = id;
|
---|
| 22 | description_ = description;
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | SphereCoordSys::~SphereCoordSys()
|
---|
| 26 | {
|
---|
| 27 | }
|
---|
| 28 | SphereCoordSys& SphereCoordSys::operator = (const SphereCoordSys& a)
|
---|
| 29 | {
|
---|
| 30 | id_ = a.id_;
|
---|
| 31 | description_ = a.description_;
|
---|
| 32 | return *this;
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 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 | void FIO_SphereCoordSys::SetDataObj(AnyDataObj & o)
|
---|
| 72 | {
|
---|
| 73 | SphereCoordSys * po = dynamic_cast<SphereCoordSys *>(&o);
|
---|
| 74 | if (po == NULL) return;
|
---|
| 75 | if (ownobj && dobj) delete dobj;
|
---|
| 76 | dobj = po; ownobj = false;
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 | void FIO_SphereCoordSys::ReadSelf(PInPersist& is)
|
---|
| 81 | {
|
---|
| 82 | uint_8 itab[3];
|
---|
| 83 | string description;
|
---|
| 84 | is.Get(itab, 3);
|
---|
| 85 | is.GetStr(description);
|
---|
| 86 | if (dobj == NULL) dobj = new SphereCoordSys(itab[1], description);
|
---|
| 87 | else *dobj= SphereCoordSys(itab[1], description);
|
---|
| 88 | }
|
---|
| 89 | void FIO_SphereCoordSys::WriteSelf(POutPersist& os) const
|
---|
| 90 | {
|
---|
| 91 | if (dobj == NULL) return; // Attention - $CHECK$ Guy 04/01/00
|
---|
| 92 | // On ecrit 3 uint_8
|
---|
| 93 | // 0 : Numero de version, 1 : Id, 2 reserve a l
|
---|
| 94 | uint_8 itab[3];
|
---|
| 95 | itab[0] = 1;
|
---|
| 96 | itab[1] = dobj->Id();
|
---|
| 97 | itab[2] = 0;
|
---|
| 98 | os.Put(itab, 3);
|
---|
| 99 | os.PutStr(dobj->description());
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 |
|
---|
| 103 |
|
---|
| 104 | //................. SpherePosition class .................
|
---|
| 105 |
|
---|
| 106 | SpherePosition::SpherePosition()
|
---|
| 107 | : UnitVector()
|
---|
| 108 | {
|
---|
| 109 | cs_ = new SphereCoordSys;
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | SpherePosition::SpherePosition(double theta, double phi, SphereCoordSys* cs)
|
---|
| 113 | : UnitVector(theta, phi)
|
---|
| 114 | {
|
---|
| 115 | if (cs == NULL) cs_ = new SphereCoordSys;
|
---|
| 116 | else cs_ = cs;
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | SpherePosition::SpherePosition(double x, double y, double z, SphereCoordSys* cs)
|
---|
| 120 | : UnitVector(x, y, z)
|
---|
| 121 | {
|
---|
| 122 | if (cs == NULL) cs_ = new SphereCoordSys;
|
---|
| 123 | else cs_ = cs;
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | SpherePosition::~SpherePosition()
|
---|
| 127 | {
|
---|
| 128 | if (cs_) delete cs_;
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | UnitVector SpherePosition::Transform(const SphereCoordSys& /*cs*/) const
|
---|
| 132 | {
|
---|
| 133 | return(*this);
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | double SpherePosition::Separation(const SpherePosition& gamma) const
|
---|
| 137 | {
|
---|
| 138 | return(this->SepAngle(gamma));
|
---|
| 139 | }
|
---|