Changeset 594 in Sophya


Ignore:
Timestamp:
Nov 17, 1999, 7:49:32 PM (26 years ago)
Author:
ercodmgr
Message:

finalisation interfacage TMatrix, PixelMap - Reza 17/11/99

Location:
trunk/SophyaPI/PIext
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/nobjmgr.cc

    r584 r594  
    955955obja = GetObjAdapter(nom);
    956956if (obja == NULL)  return;
    957 
    958 string ctyp = typeid(*obja->GetDataObj()).name();
     957AnyDataObj* ob = obja->GetDataObj();
     958if (ob == NULL) {
     959  cerr << "NamedObjMgr::PrintObj() / Error - NULL object ! in " << nom << endl;
     960  return;
     961  }
     962string ctyp = typeid(*ob).name();
    959963cout << "NamedObjMgr::PrintObj(" << nom << ") Type: " << ctyp << endl;
    960964obja->Print(cout);
     
    969973obja = GetObjAdapter(nom);
    970974if (obja == NULL) {
    971   cout << "NamedObjMgr::DisplayObj() Error , Pas d'objet de nom " << nom << endl;
     975  cout << "NamedObjMgr::DisplayObj() Error , No object with name " << nom << endl;
    972976  return;
    973977}
     978if (obja->GetDataObj() == NULL) {
     979  cerr << "NamedObjMgr::DisplayObj() / Error - NULL object ! in " << nom << endl;
     980  return;
     981  }
    974982if (!myImgApp)  return;
    975983 
     
    981989if (!dr && !arr) {
    982990  string ctyp = typeid(*(obja->GetDataObj())).name();
    983   cout << "NamedObjMgr::DisplayObj() Error , Pas de display pour " << ctyp << endl;
     991  cout << "NamedObjMgr::DisplayObj() Error , No display for " << ctyp << endl;
    984992  return;
    985993  }
     
    10171025  return;
    10181026}
     1027if (obja->GetDataObj() == NULL) {
     1028  cerr << "NamedObjMgr::DisplayImage() / Error - NULL object ! in " << nom << endl;
     1029  return;
     1030  }
    10191031if (!myImgApp)  return;
    10201032 
     
    10521064  return;
    10531065}
     1066if (obja->GetDataObj() == NULL) {
     1067  cerr << "NamedObjMgr::DisplaySurf3D() / Error - NULL object ! in " << nom << endl;
     1068  return;
     1069  }
    10541070if (!myImgApp)  return;
    10551071 
  • trunk/SophyaPI/PIext/nomskymapadapter.cc

    r585 r594  
    11#include "machdefs.h"
    22#include <stdlib.h>
     3#include <math.h>
    34#include <typeinfo>
    45#include <iostream.h>
     
    1011#include "spheregorski.h"
    1112#include "localmap.h"
    12 
     13#include "pitvmaad.h"
     14#include "complexios.h"
     15
     16//  Classe array adapter pour localMap
     17template <class T>
     18class LocalMapArrAdapter : public P2DArrayAdapter {
     19public:
     20                LocalMapArrAdapter(LocalMap<T>* lm, bool d=false) :
     21                    P2DArrayAdapter(lm->XSize(), lm->YSize())
     22                    { ad = d; map = lm; }
     23
     24  virtual       ~LocalMapArrAdapter() { if (ad) delete map; }
     25  virtual double  Value(int ix, int iy) { return((*map)(ix, iy)); }
     26
     27protected :
     28  bool ad;
     29  LocalMap<T>* map;
     30};
     31
     32/* --Methode-- */
     33double LocalMapArrAdapter< complex<float> >::Value(int ix, int iy)
     34{
     35double re,im;
     36re = (*map)(iy, ix).real();
     37im = (*map)(iy, ix).imag();
     38return(sqrt(re*re+im*im));
     39}
     40/* --Methode-- */
     41double LocalMapArrAdapter< complex<double> >::Value(int ix, int iy)
     42{
     43double re,im;
     44re = (*map)(iy, ix).real();
     45im = (*map)(iy, ix).imag();
     46return(sqrt(re*re+im*im));
     47}
    1348
    1449//----------------------------------------------------------------
     
    2055template <class T>
    2156NOMAdapter_PixelMap<T>::NOMAdapter_PixelMap(PixelMap<T> * o)
    22   : NObjMgrAdapter((AnyDataObj *)o)
     57  : NObjMgrAdapter(o)
    2358{
    2459mMap = o;
     
    84119{
    85120string s = typeid(*mMap).name();
     121T moy, sig;
     122MeanSig(moy, sig);
    86123cout << "SkyMap Type: " << s << " NbPixels= " << mMap->NbPixels() << endl;
     124cout << "  Mean= " << moy << "  Sig2= " << sig << endl;
    87125}
    88126
     
    92130P2DArrayAdapter* NOMAdapter_PixelMap<T>::Get2DArray(string &)
    93131{
    94 return(NULL);
     132LocalMap<T>* lm = dynamic_cast< LocalMap<T> * >(mMap);
     133if (lm != NULL) return(new LocalMapArrAdapter<T>(lm, false));
     134int nr = 250;
     135int nc = 500;
     136SphericalMap<T>* sm = dynamic_cast< SphericalMap<T> *>(mMap);
     137if (sm != NULL) { nr = sqrt(0.75*mMap->NbPixels());  nc = 2*nr; }
     138TMatrix<T> * mtx = new TMatrix<T>(nr, nc);
     139Project_Mol(*mtx);
     140return (new POTMatrixAdapter<T>(mtx, true) );
    95141}
    96142
     
    103149}
    104150
    105 
     151/* --Methode-- */
     152template <class T>
     153void NOMAdapter_PixelMap<T>::MeanSig(T& gmoy, T& gsig)
     154{
     155  gmoy=0.;
     156  gsig = 0.;
     157  T valok;
     158  for(int k=0; k<mMap->NbPixels(); k++) {
     159    valok = (*mMap)(k);
     160    gmoy += valok;  gsig += valok*valok;
     161  }
     162  gmoy /= (T)mMap->NbPixels();
     163  gsig = gsig/(T)mMap->NbPixels() - gmoy*gmoy;
     164
     165}
     166
     167/* --Methode-- */
     168template <class T>
     169void NOMAdapter_PixelMap<T>::Project_Mol(TMatrix<T> & mtx, T defval)
     170{
     171  r_8 xa, yd, teta,phi, facteur;
     172  int_4 l,c,k;
     173  int_4 nl = mtx.NRows();
     174  int_4 nc = mtx.NCols();
     175  mtx.Reset(defval);   // On met tout a defval
     176//  cout << " NRows= " << nl << "  NCols= " << nc  << endl;
     177  for(l=0; l<nl; l++) {
     178    yd = (r_8)(l+0.5)/(r_8)nl-0.5;
     179    facteur=2.*M_PI/sin(acos((double)yd*2));
     180    teta = (yd+0.5)*Pi;
     181    //    teta = (0.5-yd)*M_PI;
     182    for(c=0; c<nc; c++)  {
     183      xa = (r_8)(c+0.5)/(r_8)nc-0.5;
     184      phi = xa*facteur+M_PI;
     185      if ( (phi <= 2*M_PI) && (phi >= 0.) ) {
     186        k = mMap->PixIndexSph(teta, phi);
     187        mtx(l,c) = (*mMap)(k);
     188      }
     189    }
     190  }
     191}
    106192
    107193// -------------------------------------------------------------
  • trunk/SophyaPI/PIext/nomskymapadapter.h

    r585 r594  
    99
    1010#include "nomgadapter.h"
     11#include "tmatrix.h"
    1112#include "pixelmap.h"
    1213
     
    3435  virtual NTupleInterface*      GetNTupleInterface(bool& adel);
    3536
     37  virtual void                  MeanSig(T& gmoy, T& gsig);
     38  virtual void                  Project_Mol(TMatrix<T> & mtx, T defval=0.);
     39
    3640protected:
    3741  PixelMap<T>* mMap;
  • trunk/SophyaPI/PIext/pitvmaad.h

    r585 r594  
    88
    99#include "machdefs.h"
    10 #include <math.h>
    1110#include "parradapter.h"
    1211
     
    1918class POTVectorAdapter : public P1DArrayAdapter {
    2019public :
    21                   POTVectorAdapter(TVector<T>* v, bool ad=false)
    22                         : P1DArrayAdapter(v->NElts())
    23                                 { aDel = ad; mVec = v; }
    24   virtual         ~POTVectorAdapter()
    25                                 { if (aDel) delete mVec; }
    26   virtual double  Value(int i)
    27                                 { return((*mVec)(i)); }
     20                  POTVectorAdapter(TVector<T>* v, bool ad=false);
     21  virtual         ~POTVectorAdapter();
     22  virtual double  Value(int i);
    2823
    2924protected:
     
    3429typedef POTVectorAdapter<r_8> POVectorAdapter;
    3530
    36 double POTVectorAdapter< complex<float> >::Value(int i)
    37 {
    38 double re,im;
    39 re = (*mVec)(i).real();
    40 im = (*mVec)(i).imag();
    41 return(sqrt(re*re+im*im));
    42 }
    43 
    44 double POTVectorAdapter< complex<double> >::Value(int i)
    45 {
    46 double re,im;
    47 re = (*mVec)(i).real();
    48 im = (*mVec)(i).imag();
    49 return(sqrt(re*re+im*im));
    50 }
    5131
    5232// Adaptateur de matrice SOPHYA a P2DArrayAdapter
     
    5535class POTMatrixAdapter :  public P2DArrayAdapter {
    5636public :
    57                   POTMatrixAdapter(TMatrix<T>* mtx, bool ad=false)
    58                         : P2DArrayAdapter(mtx->NCols(), mtx->NRows())
    59                         { aDel = ad; mMtx = mtx; }
    60   virtual         ~POTMatrixAdapter()
    61                         { if (aDel)  delete mMtx; }
    62   virtual double  Value(int ix, int iy)
    63                         { return((double)(*mMtx)(iy, ix)); }
     37                  POTMatrixAdapter(TMatrix<T>* mtx, bool ad=false);
     38  virtual         ~POTMatrixAdapter();
     39  virtual double  Value(int ix, int iy);
    6440
    6541protected:
     
    7046typedef POTMatrixAdapter<r_8> POMatrixAdapter;
    7147
    72 double POTMatrixAdapter< complex<float> >::Value(int ix, int iy)
    73 {
    74 double re,im;
    75 re = (*mMtx)(iy, ix).real();
    76 im = (*mMtx)(iy, ix).imag();
    77 return(sqrt(re*re+im*im));
    78 }
    79 
    80 double POTMatrixAdapter< complex<double> >::Value(int ix, int iy)
    81 {
    82 double re,im;
    83 re = (*mMtx)(iy, ix).real();
    84 im = (*mMtx)(iy, ix).imag();
    85 return(sqrt(re*re+im*im));
    86 }
    8748#endif
Note: See TracChangeset for help on using the changeset viewer.