[842] | 1 | // G. Le Meur 04/2000
|
---|
| 2 |
|
---|
| 3 | #include "fiospherehealpix.h"
|
---|
| 4 | #include "pexceptions.h"
|
---|
| 5 | #include "fiondblock.h"
|
---|
| 6 |
|
---|
| 7 | //*******************************************************************
|
---|
[853] | 8 | // Class FIO_SphereHEALPix<T>
|
---|
[842] | 9 | // Les objets delegues pour la gestion de persistance
|
---|
| 10 | //*******************************************************************
|
---|
| 11 |
|
---|
| 12 | template <class T>
|
---|
[853] | 13 | FIO_SphereHEALPix<T>::FIO_SphereHEALPix()
|
---|
[842] | 14 | {
|
---|
[853] | 15 | dobj_= new SphereHEALPix<T>;
|
---|
[842] | 16 | ownobj= true;
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | template <class T>
|
---|
[853] | 20 | FIO_SphereHEALPix<T>::FIO_SphereHEALPix(string const& filename)
|
---|
[842] | 21 | {
|
---|
[853] | 22 | dobj_= new SphereHEALPix<T>;
|
---|
[842] | 23 | ownobj= true;
|
---|
| 24 | Read(filename);
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | template <class T>
|
---|
[853] | 28 | FIO_SphereHEALPix<T>::FIO_SphereHEALPix(const SphereHEALPix<T>& obj)
|
---|
[842] | 29 | {
|
---|
[853] | 30 | dobj_= new SphereHEALPix<T>(obj, true);
|
---|
[842] | 31 | ownobj= true;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | template <class T>
|
---|
[853] | 35 | FIO_SphereHEALPix<T>::FIO_SphereHEALPix(SphereHEALPix<T>* obj)
|
---|
[842] | 36 | {
|
---|
| 37 | dobj_= obj;
|
---|
| 38 | ownobj= false;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | template <class T>
|
---|
[853] | 42 | FIO_SphereHEALPix<T>::~FIO_SphereHEALPix()
|
---|
[842] | 43 | {
|
---|
| 44 | if (ownobj && dobj_) delete dobj_;
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | template <class T>
|
---|
[853] | 48 | AnyDataObj* FIO_SphereHEALPix<T>::DataObj()
|
---|
[842] | 49 | {
|
---|
| 50 | return(dobj_);
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | template <class T>
|
---|
[853] | 54 | void FIO_SphereHEALPix<T>::SetDataObj(AnyDataObj & o)
|
---|
[842] | 55 | {
|
---|
[853] | 56 | SphereHEALPix<T> * po = dynamic_cast< SphereHEALPix<T> * >(&o);
|
---|
[842] | 57 | if (po == NULL) return;
|
---|
| 58 | if (ownobj && dobj_) delete dobj_;
|
---|
| 59 | dobj_ = po; ownobj = false;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | template <class T>
|
---|
[853] | 63 | void FIO_SphereHEALPix<T>::ReadSelf(PInPersist& is)
|
---|
[842] | 64 | {
|
---|
| 65 |
|
---|
| 66 | if(dobj_ == NULL)
|
---|
| 67 | {
|
---|
[853] | 68 | dobj_= new SphereHEALPix<T>;
|
---|
[842] | 69 | ownobj= true;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | // On lit les 3 premiers uint_8
|
---|
| 73 | uint_8 itab[3];
|
---|
| 74 | is.Get(itab, 3);
|
---|
| 75 | // Let's Read the SphereCoordSys object -- ATTENTIOn - $CHECK$
|
---|
| 76 | FIO_SphereCoordSys fio_scs( dobj_->GetCoordSys());
|
---|
| 77 | fio_scs.Read(is);
|
---|
| 78 | // Pour savoir s'il y avait un DVList Infodobj->Info(); associe
|
---|
| 79 | char strg[256];
|
---|
| 80 | is.GetLine(strg, 255);
|
---|
| 81 | bool hadinfo= false;
|
---|
| 82 | if(strncmp(strg+strlen(strg)-7, "HasInfo", 7) == 0) hadinfo= true;
|
---|
| 83 | if(hadinfo)
|
---|
| 84 | { // Lecture eventuelle du DVList Info
|
---|
| 85 | is >> dobj_->Info();
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | int_4 nSide;
|
---|
| 89 | is.GetI4(nSide);
|
---|
| 90 | int_4 nPix;
|
---|
| 91 | is.GetI4(nPix);
|
---|
| 92 | double Omega;
|
---|
| 93 | is.GetR8(Omega);
|
---|
| 94 | dobj_->setParameters(nSide,nPix, Omega);
|
---|
| 95 |
|
---|
| 96 | // On lit les DataBlocks;
|
---|
| 97 | FIO_NDataBlock<T> fio_nd(&dobj_->pixels_);
|
---|
| 98 | fio_nd.Read(is);
|
---|
[1382] | 99 | FIO_NDataBlock<int_4> fio_ndi1(&dobj_->sliceBeginIndex_);
|
---|
[842] | 100 | fio_ndi1.Read(is);
|
---|
[1382] | 101 | FIO_NDataBlock<int_4> fio_ndi2(&dobj_->sliceLenght_);
|
---|
[842] | 102 | fio_ndi2.Read(is);
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | template <class T>
|
---|
[853] | 106 | void FIO_SphereHEALPix<T>::WriteSelf(POutPersist& os) const
|
---|
[842] | 107 | {
|
---|
| 108 | if(dobj_ == NULL)
|
---|
| 109 | {
|
---|
| 110 | cout << " WriteSelf:: dobj_= null " << endl;
|
---|
| 111 | return;
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | // On ecrit 3 uint_8
|
---|
| 115 | // 0 : Numero de version, 1 : Size index, 2 reserve a l
|
---|
| 116 | uint_8 itab[3];
|
---|
| 117 | itab[0] = 1;
|
---|
| 118 | itab[1] = dobj_->SizeIndex();
|
---|
| 119 | itab[2] = 0;
|
---|
| 120 | os.Put(itab, 3);
|
---|
| 121 | // Let's write the SphereCoordSys object
|
---|
| 122 | FIO_SphereCoordSys fio_scs( dobj_->GetCoordSys());
|
---|
| 123 | fio_scs.Write(os);
|
---|
| 124 |
|
---|
| 125 | char strg[256];
|
---|
| 126 | int_4 nSide= dobj_->SizeIndex();
|
---|
| 127 | int_4 nPix = dobj_->NbPixels();
|
---|
| 128 |
|
---|
| 129 | if(dobj_->ptrInfo())
|
---|
| 130 | {
|
---|
[853] | 131 | sprintf(strg,"SphereHEALPix: NSide=%6d NPix=%9d HasInfo",nSide,nPix);
|
---|
[842] | 132 | os.PutLine(strg);
|
---|
| 133 | os << dobj_->Info();
|
---|
| 134 | }
|
---|
| 135 | else
|
---|
| 136 | {
|
---|
[853] | 137 | sprintf(strg,"SphereHEALPix: NSide=%6d NPix=%9d ",nSide,nPix);
|
---|
[842] | 138 | os.PutLine(strg);
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | os.PutI4(nSide);
|
---|
| 142 | os.PutI4(nPix);
|
---|
| 143 | os.PutR8(dobj_->PixSolAngle());
|
---|
| 144 | // On ecrit les dataBlocks
|
---|
| 145 | FIO_NDataBlock<T> fio_nd(&dobj_->pixels_);
|
---|
| 146 | fio_nd.Write(os);
|
---|
[1382] | 147 | FIO_NDataBlock<int_4> fio_ndi1(&dobj_->sliceBeginIndex_);
|
---|
[842] | 148 | fio_ndi1.Write(os);
|
---|
[1382] | 149 | FIO_NDataBlock<int_4> fio_ndi2(&dobj_->sliceLenght_);
|
---|
[842] | 150 | fio_ndi2.Write(os);
|
---|
| 151 | }
|
---|
| 152 |
|
---|
| 153 | //*******************************************************************
|
---|
| 154 |
|
---|
| 155 | #ifdef __CXX_PRAGMA_TEMPLATES__
|
---|
[853] | 156 | #pragma define_template FIO_SphereHEALPix<r_8>
|
---|
| 157 | #pragma define_template FIO_SphereHEALPix<r_4>
|
---|
| 158 | #pragma define_template FIO_SphereHEALPix< complex<r_4> >
|
---|
| 159 | #pragma define_template FIO_SphereHEALPix< complex<r_8> >
|
---|
[842] | 160 | #endif
|
---|
| 161 | #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
|
---|
[853] | 162 | template class FIO_SphereHEALPix<r_8>;
|
---|
| 163 | template class FIO_SphereHEALPix<r_4>;
|
---|
| 164 | template class FIO_SphereHEALPix< complex<r_4> >;
|
---|
| 165 | template class FIO_SphereHEALPix< complex<r_8> >;
|
---|
[842] | 166 | #endif
|
---|