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

Last change on this file since 4034 was 3572, checked in by cmv, 17 years ago

char* -> const char* pour regler les problemes de deprecated string const... + comparaison unsigned signed + suppression EVOL_PLANCK rz+cmv 07/02/2009

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