Changeset 980 in Sophya


Ignore:
Timestamp:
Apr 28, 2000, 4:12:44 PM (25 years ago)
Author:
ansari
Message:

modifs constructeurs copie et operateur =

Location:
trunk/SophyaLib/SkyMap
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/SkyMap/spherehealpix.cc

    r979 r980  
    261261template<class T>
    262262SphereHEALPix<T>& SphereHEALPix<T>::Set(const SphereHEALPix<T>& a)
    263    {
     263{
    264264  if (this != &a)
    265265    {
    266 
    267   if (a.NbPixels() < 1)
    268     throw RangeCheckError("SphereHEALPix<T>::Set(a ) - Array a not allocated ! ");
    269   if (NbPixels() < 1) CloneOrShare(a);
    270   else CopyElt(a);
    271 
    272 
    273       //     CloneOrShare(a);
    274      if (mInfo_) delete mInfo_;
    275      mInfo_ = NULL;
    276      if (a.mInfo_) mInfo_ = new DVList(*(a.mInfo_));
     266     
     267      if (a.NbPixels() < 1)
     268        throw RangeCheckError("SphereHEALPix<T>::Set(a ) - Array a not allocated ! ");
     269      if (NbPixels() < 1) CloneOrShare(a);
     270      else CopyElt(a);
     271     
     272     
     273      if (mInfo_) delete mInfo_;
     274      mInfo_ = NULL;
     275      if (a.mInfo_) mInfo_ = new DVList(*(a.mInfo_));
    277276    }
    278277  return(*this);
    279    }
     278}
    280279
    281280template<class T>
     
    285284    throw RangeCheckError("SphereHEALPix<T>::CopyElt(const SphereHEALPix<T>& )  - Not Allocated Array ! ");
    286285  if (NbPixels() != a.NbPixels())
    287     throw(SzMismatchError("TArray<T>::MultElt(const TArray<T>&) SizeMismatch")) ;
     286    throw(SzMismatchError("SphereHEALPix<T>::CopyElt(const SphereHEALPix<T>&) SizeMismatch")) ;
    288287  nSide_= a.nSide_;
    289288  nPix_ = a.nPix_;
  • trunk/SophyaLib/SkyMap/spherehealpix.h

    r908 r980  
    215215
    216216inline  SphereHEALPix<T>& operator = (const SphereHEALPix<T>& a)
    217                                                        {return Set(a);}
     217                                                        {return Set(a);}
    218218       
    219219private :
     
    239239 void CloneOrShare(const SphereHEALPix<T>& a);
    240240 SphereHEALPix<T>& Set(const SphereHEALPix<T>& a);
     241 SphereHEALPix<T>& CopyElt(const SphereHEALPix<T>& a);
    241242
    242243// ------------- variables internes -----------------------
  • trunk/SophyaLib/SkyMap/spherethetaphi.cc

    r908 r980  
    3939template <class T>
    4040SphereThetaPhi<T>::SphereThetaPhi()
     41  : NPhi_(), TNphi_(), Theta_(), pixels_()
    4142
    4243//--
    4344{
    4445  InitNul();
    45   pixels_.Reset();
    4646}
    4747
     
    6767    pixels_(s.pixels_ , share)
    6868{
    69   if(s.mInfo_) mInfo_= new DVList(*s.mInfo_);
    7069
    7170  NTheta_= s.NTheta_;
    7271  NPix_  = s.NPix_;
    7372  Omega_ = s.Omega_;
     73  if(s.mInfo_) mInfo_= new DVList(*s.mInfo_);
    7474}
    7575
     
    7878  : NPhi_(s.NPhi_), TNphi_(s.TNphi_), Theta_(s.Theta_), pixels_(s.pixels_)
    7979{
    80   if(s.mInfo_) mInfo_= new DVList(*s.mInfo_);
    8180
    8281  NTheta_= s.NTheta_;
    8382  NPix_  = s.NPix_;
    8483  Omega_ = s.Omega_;
     84  if(s.mInfo_) mInfo_= new DVList(*s.mInfo_);
    8585}
    8686
     
    122122{
    123123
    124     NPhi_.CloneOrShare(a.NPhi_);
    125     TNphi_.CloneOrShare(a.TNphi_);
    126     Theta_.CloneOrShare(a.Theta_);
    127     pixels_.CloneOrShare(a.pixels_);
    128 }
    129 
     124  NTheta_= a.NTheta_;
     125  NPix_  = a.NPix_;
     126  Omega_ = a.Omega_;
     127  NPhi_.CloneOrShare(a.NPhi_);
     128  TNphi_.CloneOrShare(a.TNphi_);
     129  Theta_.CloneOrShare(a.Theta_);
     130  pixels_.CloneOrShare(a.pixels_);
     131}
     132
     133////////////////////////// methodes de copie/share
    130134template<class T>
    131135SphereThetaPhi<T>& SphereThetaPhi<T>::Set(const SphereThetaPhi<T>& a)
    132    {
     136{
    133137  if (this != &a)
    134138    {
    135 
    136 
    137       NTheta_= a.NTheta_;
    138       NPix_  = a.NPix_;
    139       Omega_ = a.Omega_;
    140       CloneOrShare(a);
     139     
     140     
     141      if (a.NbPixels() < 1)
     142        throw RangeCheckError("SphereThetaPhi<T>::Set(a ) - Array a not allocated ! ");
     143      if (NbPixels() < 1) CloneOrShare(a);
     144      else CopyElt(a);
    141145      if (mInfo_) delete mInfo_;
    142146      mInfo_ = NULL;
     
    144148    }
    145149  return(*this);
    146    }
    147 
    148 
     150}
     151
     152template<class T>
     153SphereThetaPhi<T>& SphereThetaPhi<T>::CopyElt(const SphereThetaPhi<T>& a)
     154{
     155  if (NbPixels() < 1)
     156    throw RangeCheckError("SphereThetaPhi<T>::CopyElt(const SphereThetaPhi<T>& )  - Not Allocated Array ! ");
     157  if (NbPixels() != a.NbPixels())
     158    throw(SzMismatchError("SphereThetaPhi<T>::CopyElt(const SphereThetaPhi<T>&) SizeMismatch")) ;
     159
     160  NTheta_= a.NTheta_;
     161  NPix_  = a.NPix_;
     162  Omega_ = a.Omega_;
     163  int k;
     164  for (k=0; k< NPix_; k++) pixels_(k) = a.pixels_(k);
     165  for (k=0; k< a.NPhi_.Size(); k++) NPhi_(k) = a.NPhi_(k);
     166  for (k=0; k< a.TNphi_.Size(); k++) TNphi_(k) = a.TNphi_(k);
     167  for (k=0; k< a.Theta_.Size(); k++) Theta_(k) = a.Theta_(k);
     168  return(*this);
     169
     170}
    149171
    150172/* --Methode-- */
     
    524546  // Le nombre de pixels en phi de chacune des bandes en theta
    525547  //  NPhi_ = new int_4[m];
    526   NPhi_.ReSize(m);
     548  // une taille de m suffit, mais je mets m+1 pour que les 3 tableaux aient
     549  // la meme taille pour une manipulation plus faciles par la librairie
     550  // cfitsio -- GLM (13-04-00)
     551  NPhi_.ReSize(m+1);
    527552 
    528553  // Le nombre/Deuxpi total des pixels contenus dans les bandes de z superieur a une
  • trunk/SophyaLib/SkyMap/spherethetaphi.h

    r908 r980  
    1515template <class T>
    1616class FIO_SphereThetaPhi; 
     17
     18template<class T>
     19class FITS_SphereThetaPhi;
    1720
    1821
     
    3336
    3437  friend class FIO_SphereThetaPhi<T>;
     38  friend class FITS_SphereThetaPhi<T>;
    3539
    3640public :
     
    198202
    199203SphereThetaPhi<T>& Set(const SphereThetaPhi<T>& a);
     204 SphereThetaPhi<T>& CopyElt(const SphereThetaPhi<T>& a);
    200205
    201206// ------------- variables internes ---------------------
Note: See TracChangeset for help on using the changeset viewer.