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

Last change on this file since 3506 was 2973, checked in by ansari, 19 years ago

1/ Nettoyage+commentaires/doxygen ds Vector3d, UnitVector, LongLat,
SphereCoordSys ...
2/ Ajout de la classe angle pour faciliter les conversions rad<>deg<>arcmin
dans le fichier vector3d.h .cc
3/ nettoyage/uniformisation methodes print pour pixelmap, ajout de la
methode PixelMap<T>::Show()
4/ Ajout methodes SphericalMap<T>::HasSymThetaSlice() et
GetSymThetaSliceIndex(int_4 idx) et leurs implementations pour
SphereHEALPix et SphereThetaPhi en vue de l'optimisation du calcul
transforme Ylm
5/ Ajout methode ResolToSizeIndex ds SphereThetaPhi , SphereHEALPix et
SphereECP

Reza , 20 Juin 2006

File size: 4.1 KB
RevLine 
[2973]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
[764]6// 04/01/00 : implantation de la persistance par classe deleguee - Guy Le Meur
7
[2615]8#include "sopnamsp.h"
[764]9#include "spherepos.h"
[1967]10#include "datatype.h"
11#include <typeinfo>
[764]12
[2973]13static char *head_spherepos_cc_ = "$Header: /Users/garnier/temp/CVSSophya/SophyaLib/SkyMap/spherepos.cc,v 1.4 2006-06-20 16:01:48 ansari Exp $";
[764]14
15
16//................. SphereCoordSys class .................
17
[2973]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
[764]26SphereCoordSys::SphereCoordSys(){
[2973]27 id_ = SphereCoordSys::NEUTRAL;
[764]28 description_ = "NEUTRAL SphereCoordSystem";
29}
30SphereCoordSys::SphereCoordSys(const SphereCoordSys& a )
31{
32 id_ = a.id_;
33 description_ = a.description_;
34}
35
[2973]36SphereCoordSys::SphereCoordSys(int id,
37 const string& description){
[764]38 id_ = id;
39 description_ = description;
40}
41
42SphereCoordSys::~SphereCoordSys()
43{
44}
45SphereCoordSys& 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
58FIO_SphereCoordSys::FIO_SphereCoordSys()
59 {
60 dobj=new SphereCoordSys;
61 ownobj=true;
62 }
63FIO_SphereCoordSys::FIO_SphereCoordSys(string const & filename)
64 {
65 dobj=new SphereCoordSys;
66 ownobj=true;
67 Read(filename);
68 }
69FIO_SphereCoordSys::FIO_SphereCoordSys(const SphereCoordSys & obj)
70 {
71 dobj = new SphereCoordSys(obj);
72 ownobj=true;
73 }
74FIO_SphereCoordSys::FIO_SphereCoordSys(SphereCoordSys * obj)
75 {
76 dobj = obj;
77 ownobj=false;
78 }
79FIO_SphereCoordSys::~FIO_SphereCoordSys()
80 {
81 if (ownobj && dobj) delete dobj;
82 }
83AnyDataObj* FIO_SphereCoordSys::DataObj()
84 {
85 return(dobj);
86 }
87
88void FIO_SphereCoordSys::SetDataObj(AnyDataObj & o)
89{
90 SphereCoordSys * po = dynamic_cast<SphereCoordSys *>(&o);
[1967]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
[764]98 if (ownobj && dobj) delete dobj;
99 dobj = po; ownobj = false;
100}
101
102
103void FIO_SphereCoordSys::ReadSelf(PInPersist& is)
104 {
105uint_8 itab[3];
106 string description;
107is.Get(itab, 3);
108is.GetStr(description);
109if (dobj == NULL) dobj = new SphereCoordSys(itab[1], description);
110 else *dobj= SphereCoordSys(itab[1], description);
111 }
112void FIO_SphereCoordSys::WriteSelf(POutPersist& os) const
113{
114if (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
117uint_8 itab[3];
118itab[0] = 1;
119itab[1] = dobj->Id();
120itab[2] = 0;
121os.Put(itab, 3);
122os.PutStr(dobj->description());
123}
124
125
126
127//................. SpherePosition class .................
[2973]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*/
[764]135
136SpherePosition::SpherePosition()
137 : UnitVector()
138{
139 cs_ = new SphereCoordSys;
140}
141
142SpherePosition::SpherePosition(double theta, double phi, SphereCoordSys* cs)
143 : UnitVector(theta, phi)
144{
145if (cs == NULL) cs_ = new SphereCoordSys;
146else cs_ = cs;
147}
148
149SpherePosition::SpherePosition(double x, double y, double z, SphereCoordSys* cs)
150 : UnitVector(x, y, z)
151{
152if (cs == NULL) cs_ = new SphereCoordSys;
153else cs_ = cs;
154}
155
156SpherePosition::~SpherePosition()
157{
158if (cs_) delete cs_;
159}
160
161UnitVector SpherePosition::Transform(const SphereCoordSys& /*cs*/) const
162{
163return(*this);
164}
165
166double SpherePosition::Separation(const SpherePosition& gamma) const
167{
168return(this->SepAngle(gamma));
169}
Note: See TracBrowser for help on using the repository browser.