[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 |
|
---|
| 13 |
|
---|
| 14 |
|
---|
| 15 | //................. SphereCoordSys class .................
|
---|
| 16 |
|
---|
[2973] | 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 |
|
---|
[764] | 25 | SphereCoordSys::SphereCoordSys(){
|
---|
[2973] | 26 | id_ = SphereCoordSys::NEUTRAL;
|
---|
[764] | 27 | description_ = "NEUTRAL SphereCoordSystem";
|
---|
| 28 | }
|
---|
| 29 | SphereCoordSys::SphereCoordSys(const SphereCoordSys& a )
|
---|
| 30 | {
|
---|
| 31 | id_ = a.id_;
|
---|
| 32 | description_ = a.description_;
|
---|
| 33 | }
|
---|
| 34 |
|
---|
[2973] | 35 | SphereCoordSys::SphereCoordSys(int id,
|
---|
| 36 | const string& description){
|
---|
[764] | 37 | id_ = id;
|
---|
| 38 | description_ = description;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | SphereCoordSys::~SphereCoordSys()
|
---|
| 42 | {
|
---|
| 43 | }
|
---|
| 44 | SphereCoordSys& 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 |
|
---|
| 57 | FIO_SphereCoordSys::FIO_SphereCoordSys()
|
---|
| 58 | {
|
---|
| 59 | dobj=new SphereCoordSys;
|
---|
| 60 | ownobj=true;
|
---|
| 61 | }
|
---|
| 62 | FIO_SphereCoordSys::FIO_SphereCoordSys(string const & filename)
|
---|
| 63 | {
|
---|
| 64 | dobj=new SphereCoordSys;
|
---|
| 65 | ownobj=true;
|
---|
| 66 | Read(filename);
|
---|
| 67 | }
|
---|
| 68 | FIO_SphereCoordSys::FIO_SphereCoordSys(const SphereCoordSys & obj)
|
---|
| 69 | {
|
---|
| 70 | dobj = new SphereCoordSys(obj);
|
---|
| 71 | ownobj=true;
|
---|
| 72 | }
|
---|
| 73 | FIO_SphereCoordSys::FIO_SphereCoordSys(SphereCoordSys * obj)
|
---|
| 74 | {
|
---|
| 75 | dobj = obj;
|
---|
| 76 | ownobj=false;
|
---|
| 77 | }
|
---|
| 78 | FIO_SphereCoordSys::~FIO_SphereCoordSys()
|
---|
| 79 | {
|
---|
| 80 | if (ownobj && dobj) delete dobj;
|
---|
| 81 | }
|
---|
| 82 | AnyDataObj* FIO_SphereCoordSys::DataObj()
|
---|
| 83 | {
|
---|
| 84 | return(dobj);
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | void FIO_SphereCoordSys::SetDataObj(AnyDataObj & o)
|
---|
| 88 | {
|
---|
| 89 | SphereCoordSys * po = dynamic_cast<SphereCoordSys *>(&o);
|
---|
[1967] | 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 |
|
---|
[764] | 97 | if (ownobj && dobj) delete dobj;
|
---|
| 98 | dobj = po; ownobj = false;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 |
|
---|
| 102 | void FIO_SphereCoordSys::ReadSelf(PInPersist& is)
|
---|
| 103 | {
|
---|
| 104 | uint_8 itab[3];
|
---|
| 105 | string description;
|
---|
| 106 | is.Get(itab, 3);
|
---|
| 107 | is.GetStr(description);
|
---|
| 108 | if (dobj == NULL) dobj = new SphereCoordSys(itab[1], description);
|
---|
| 109 | else *dobj= SphereCoordSys(itab[1], description);
|
---|
| 110 | }
|
---|
| 111 | void FIO_SphereCoordSys::WriteSelf(POutPersist& os) const
|
---|
| 112 | {
|
---|
| 113 | if (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
|
---|
| 116 | uint_8 itab[3];
|
---|
| 117 | itab[0] = 1;
|
---|
| 118 | itab[1] = dobj->Id();
|
---|
| 119 | itab[2] = 0;
|
---|
| 120 | os.Put(itab, 3);
|
---|
| 121 | os.PutStr(dobj->description());
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 |
|
---|
| 125 |
|
---|
| 126 | //................. SpherePosition class .................
|
---|
[2973] | 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 | */
|
---|
[764] | 134 |
|
---|
| 135 | SpherePosition::SpherePosition()
|
---|
| 136 | : UnitVector()
|
---|
| 137 | {
|
---|
| 138 | cs_ = new SphereCoordSys;
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | SpherePosition::SpherePosition(double theta, double phi, SphereCoordSys* cs)
|
---|
| 142 | : UnitVector(theta, phi)
|
---|
| 143 | {
|
---|
| 144 | if (cs == NULL) cs_ = new SphereCoordSys;
|
---|
| 145 | else cs_ = cs;
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | SpherePosition::SpherePosition(double x, double y, double z, SphereCoordSys* cs)
|
---|
| 149 | : UnitVector(x, y, z)
|
---|
| 150 | {
|
---|
| 151 | if (cs == NULL) cs_ = new SphereCoordSys;
|
---|
| 152 | else cs_ = cs;
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | SpherePosition::~SpherePosition()
|
---|
| 156 | {
|
---|
| 157 | if (cs_) delete cs_;
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 | UnitVector SpherePosition::Transform(const SphereCoordSys& /*cs*/) const
|
---|
| 161 | {
|
---|
| 162 | return(*this);
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | double SpherePosition::Separation(const SpherePosition& gamma) const
|
---|
| 166 | {
|
---|
| 167 | return(this->SepAngle(gamma));
|
---|
| 168 | }
|
---|