1 | // Classes SphereCoordSys , SpherePosition
|
---|
2 | // G. Le Meur 2000
|
---|
3 | // R. Ansari 2006 (documentation/commentaire)
|
---|
4 | // LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA
|
---|
5 |
|
---|
6 | // 04/01/00 : implantation de la persistance par classe deleguee - Guy Le Meur
|
---|
7 |
|
---|
8 | #include "sopnamsp.h"
|
---|
9 | #include "spherepos.h"
|
---|
10 | #include "datatype.h"
|
---|
11 | #include <typeinfo>
|
---|
12 |
|
---|
13 | static char *head_spherepos_cc_ = "$Header: /Users/garnier/temp/CVSSophya/SophyaLib/SkyMap/spherepos.cc,v 1.4 2006-06-20 16:01:48 ansari Exp $";
|
---|
14 |
|
---|
15 |
|
---|
16 | //................. SphereCoordSys class .................
|
---|
17 |
|
---|
18 | /*!
|
---|
19 | \class SOPHYA::SphereCoordSys
|
---|
20 | \ingroup SkyMap
|
---|
21 | \brief Class which describes the coordinate system used in spherical maps
|
---|
22 | Current implementation (~ 2006 ) does NOT perform any coordinate transformation
|
---|
23 | \sa SOPHYA::PixelMap
|
---|
24 | */
|
---|
25 |
|
---|
26 | SphereCoordSys::SphereCoordSys(){
|
---|
27 | id_ = SphereCoordSys::NEUTRAL;
|
---|
28 | description_ = "NEUTRAL SphereCoordSystem";
|
---|
29 | }
|
---|
30 | SphereCoordSys::SphereCoordSys(const SphereCoordSys& a )
|
---|
31 | {
|
---|
32 | id_ = a.id_;
|
---|
33 | description_ = a.description_;
|
---|
34 | }
|
---|
35 |
|
---|
36 | SphereCoordSys::SphereCoordSys(int id,
|
---|
37 | const string& description){
|
---|
38 | id_ = id;
|
---|
39 | description_ = description;
|
---|
40 | }
|
---|
41 |
|
---|
42 | SphereCoordSys::~SphereCoordSys()
|
---|
43 | {
|
---|
44 | }
|
---|
45 | SphereCoordSys& SphereCoordSys::operator = (const SphereCoordSys& a)
|
---|
46 | {
|
---|
47 | id_ = a.id_;
|
---|
48 | description_ = a.description_;
|
---|
49 | return *this;
|
---|
50 | }
|
---|
51 |
|
---|
52 |
|
---|
53 | ////////////////////////////////////////////////////////////////
|
---|
54 | // -------------------------------------------------------------------------
|
---|
55 | // Les objets delegues pour la gestion de persistance
|
---|
56 | // -------------------------------------------------------------------------
|
---|
57 |
|
---|
58 | FIO_SphereCoordSys::FIO_SphereCoordSys()
|
---|
59 | {
|
---|
60 | dobj=new SphereCoordSys;
|
---|
61 | ownobj=true;
|
---|
62 | }
|
---|
63 | FIO_SphereCoordSys::FIO_SphereCoordSys(string const & filename)
|
---|
64 | {
|
---|
65 | dobj=new SphereCoordSys;
|
---|
66 | ownobj=true;
|
---|
67 | Read(filename);
|
---|
68 | }
|
---|
69 | FIO_SphereCoordSys::FIO_SphereCoordSys(const SphereCoordSys & obj)
|
---|
70 | {
|
---|
71 | dobj = new SphereCoordSys(obj);
|
---|
72 | ownobj=true;
|
---|
73 | }
|
---|
74 | FIO_SphereCoordSys::FIO_SphereCoordSys(SphereCoordSys * obj)
|
---|
75 | {
|
---|
76 | dobj = obj;
|
---|
77 | ownobj=false;
|
---|
78 | }
|
---|
79 | FIO_SphereCoordSys::~FIO_SphereCoordSys()
|
---|
80 | {
|
---|
81 | if (ownobj && dobj) delete dobj;
|
---|
82 | }
|
---|
83 | AnyDataObj* FIO_SphereCoordSys::DataObj()
|
---|
84 | {
|
---|
85 | return(dobj);
|
---|
86 | }
|
---|
87 |
|
---|
88 | void FIO_SphereCoordSys::SetDataObj(AnyDataObj & o)
|
---|
89 | {
|
---|
90 | SphereCoordSys * po = dynamic_cast<SphereCoordSys *>(&o);
|
---|
91 | if (po == NULL) {
|
---|
92 | char buff[160];
|
---|
93 | sprintf(buff,"FIO_SphereCoordSys::SetDataObj(%s) - Object type error ! ",
|
---|
94 | typeid(o).name());
|
---|
95 | throw TypeMismatchExc(PExcLongMessage(buff));
|
---|
96 | }
|
---|
97 |
|
---|
98 | if (ownobj && dobj) delete dobj;
|
---|
99 | dobj = po; ownobj = false;
|
---|
100 | }
|
---|
101 |
|
---|
102 |
|
---|
103 | void FIO_SphereCoordSys::ReadSelf(PInPersist& is)
|
---|
104 | {
|
---|
105 | uint_8 itab[3];
|
---|
106 | string description;
|
---|
107 | is.Get(itab, 3);
|
---|
108 | is.GetStr(description);
|
---|
109 | if (dobj == NULL) dobj = new SphereCoordSys(itab[1], description);
|
---|
110 | else *dobj= SphereCoordSys(itab[1], description);
|
---|
111 | }
|
---|
112 | void FIO_SphereCoordSys::WriteSelf(POutPersist& os) const
|
---|
113 | {
|
---|
114 | if (dobj == NULL) return; // Attention - $CHECK$ Guy 04/01/00
|
---|
115 | // On ecrit 3 uint_8
|
---|
116 | // 0 : Numero de version, 1 : Id, 2 reserve a l
|
---|
117 | uint_8 itab[3];
|
---|
118 | itab[0] = 1;
|
---|
119 | itab[1] = dobj->Id();
|
---|
120 | itab[2] = 0;
|
---|
121 | os.Put(itab, 3);
|
---|
122 | os.PutStr(dobj->description());
|
---|
123 | }
|
---|
124 |
|
---|
125 |
|
---|
126 |
|
---|
127 | //................. SpherePosition class .................
|
---|
128 | /*!
|
---|
129 | \class SOPHYA::SpherePosition
|
---|
130 | \ingroup SkyMap
|
---|
131 | \brief Class to define a (angular) position on a sphere, combined a coordinate system
|
---|
132 | Current implementation (~ 2006 ) does NOT perform any coordinate transformation
|
---|
133 | \sa SOPHYA::PixelMap
|
---|
134 | */
|
---|
135 |
|
---|
136 | SpherePosition::SpherePosition()
|
---|
137 | : UnitVector()
|
---|
138 | {
|
---|
139 | cs_ = new SphereCoordSys;
|
---|
140 | }
|
---|
141 |
|
---|
142 | SpherePosition::SpherePosition(double theta, double phi, SphereCoordSys* cs)
|
---|
143 | : UnitVector(theta, phi)
|
---|
144 | {
|
---|
145 | if (cs == NULL) cs_ = new SphereCoordSys;
|
---|
146 | else cs_ = cs;
|
---|
147 | }
|
---|
148 |
|
---|
149 | SpherePosition::SpherePosition(double x, double y, double z, SphereCoordSys* cs)
|
---|
150 | : UnitVector(x, y, z)
|
---|
151 | {
|
---|
152 | if (cs == NULL) cs_ = new SphereCoordSys;
|
---|
153 | else cs_ = cs;
|
---|
154 | }
|
---|
155 |
|
---|
156 | SpherePosition::~SpherePosition()
|
---|
157 | {
|
---|
158 | if (cs_) delete cs_;
|
---|
159 | }
|
---|
160 |
|
---|
161 | UnitVector SpherePosition::Transform(const SphereCoordSys& /*cs*/) const
|
---|
162 | {
|
---|
163 | return(*this);
|
---|
164 | }
|
---|
165 |
|
---|
166 | double SpherePosition::Separation(const SpherePosition& gamma) const
|
---|
167 | {
|
---|
168 | return(this->SepAngle(gamma));
|
---|
169 | }
|
---|