source: Sophya/trunk/SophyaLib/SkyMap/spherepos.cc@ 764

Last change on this file since 764 was 764, checked in by ansari, 26 years ago

Reorganisation - Creation du module SkyMap (Loacl/Spherical maps ...) - Reza 2/3/2000

File size: 3.2 KB
Line 
1// 04/01/00 : implantation de la persistance par classe deleguee - Guy Le Meur
2
3#include "spherepos.h"
4
5static 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
10SphereCoordSys::SphereCoordSys(){
11 id_ = SphereCoordSys_NEUTRAL;
12 description_ = "NEUTRAL SphereCoordSystem";
13}
14SphereCoordSys::SphereCoordSys(const SphereCoordSys& a )
15{
16 id_ = a.id_;
17 description_ = a.description_;
18}
19
20SphereCoordSys::SphereCoordSys(int id, const string& description){
21 id_ = id;
22 description_ = description;
23}
24
25SphereCoordSys::~SphereCoordSys()
26{
27}
28SphereCoordSys& 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
41FIO_SphereCoordSys::FIO_SphereCoordSys()
42 {
43 dobj=new SphereCoordSys;
44 ownobj=true;
45 }
46FIO_SphereCoordSys::FIO_SphereCoordSys(string const & filename)
47 {
48 dobj=new SphereCoordSys;
49 ownobj=true;
50 Read(filename);
51 }
52FIO_SphereCoordSys::FIO_SphereCoordSys(const SphereCoordSys & obj)
53 {
54 dobj = new SphereCoordSys(obj);
55 ownobj=true;
56 }
57FIO_SphereCoordSys::FIO_SphereCoordSys(SphereCoordSys * obj)
58 {
59 dobj = obj;
60 ownobj=false;
61 }
62FIO_SphereCoordSys::~FIO_SphereCoordSys()
63 {
64 if (ownobj && dobj) delete dobj;
65 }
66AnyDataObj* FIO_SphereCoordSys::DataObj()
67 {
68 return(dobj);
69 }
70
71void 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
80void FIO_SphereCoordSys::ReadSelf(PInPersist& is)
81 {
82uint_8 itab[3];
83 string description;
84is.Get(itab, 3);
85is.GetStr(description);
86if (dobj == NULL) dobj = new SphereCoordSys(itab[1], description);
87 else *dobj= SphereCoordSys(itab[1], description);
88 }
89void FIO_SphereCoordSys::WriteSelf(POutPersist& os) const
90{
91if (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
94uint_8 itab[3];
95itab[0] = 1;
96itab[1] = dobj->Id();
97itab[2] = 0;
98os.Put(itab, 3);
99os.PutStr(dobj->description());
100}
101
102
103
104//................. SpherePosition class .................
105
106SpherePosition::SpherePosition()
107 : UnitVector()
108{
109 cs_ = new SphereCoordSys;
110}
111
112SpherePosition::SpherePosition(double theta, double phi, SphereCoordSys* cs)
113 : UnitVector(theta, phi)
114{
115if (cs == NULL) cs_ = new SphereCoordSys;
116else cs_ = cs;
117}
118
119SpherePosition::SpherePosition(double x, double y, double z, SphereCoordSys* cs)
120 : UnitVector(x, y, z)
121{
122if (cs == NULL) cs_ = new SphereCoordSys;
123else cs_ = cs;
124}
125
126SpherePosition::~SpherePosition()
127{
128if (cs_) delete cs_;
129}
130
131UnitVector SpherePosition::Transform(const SphereCoordSys& /*cs*/) const
132{
133return(*this);
134}
135
136double SpherePosition::Separation(const SpherePosition& gamma) const
137{
138return(this->SepAngle(gamma));
139}
Note: See TracBrowser for help on using the repository browser.