GRALE
backprojecttreebase.h
Go to the documentation of this file.
1 /*
2 
3  This file is a part of GRALE, a library to facilitate the simulation
4  and inversion of gravitational lenses.
5 
6  Copyright (C) 2008-2012 Jori Liesenborgs
7 
8  Contact: jori.liesenborgs@gmail.com
9 
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 
24 */
25 
30 #ifndef GRALE_BACKPROJECTTREEBASE_H
31 
32 #define GRALE_BACKPROJECTTREEBASE_H
33 
34 #include "graleconfig.h"
36 #include <vector>
37 #include <list>
38 
39 namespace grale
40 {
41 
42 class ImagesDataExtended;
43 class GridNodeBase;
44 
45 class GRALE_IMPORTEXPORT BackProjectTreeBase : public ProjectedImagesInterface
46 {
47 public:
48  ~BackProjectTreeBase();
49 
50  void calculateDeflection(const GridNodeBase *pRootNode, bool intensities);
51  void calculateBetas(float massFactor);
52  void calculateMagnifications(float massFactor);
53 
54  double getAngularScale() const { return m_angularScale; }
55  const Vector2D<float> *getBetas(int sourceNumber) const { return m_betaPointers[sourceNumber][0]; }
56  const Vector2D<float> *getBetas(int sourceNumber, int imageNumber) const { return m_betaPointers[sourceNumber][imageNumber]; }
57  const Vector2D<float> *getThetas(int sourceNumber) const { return m_thetaPointers[sourceNumber][0]; }
58  const Vector2D<float> *getThetas(int sourceNumber, int imageNumber) const { return m_thetaPointers[sourceNumber][imageNumber]; }
59  const float *getInverseMagnifications(int sourceNumber) const { return m_invMagPointers[sourceNumber][0]; }
60  const float *getInverseMagnifications(int sourceNumber, int imageNumber) const { return m_invMagPointers[sourceNumber][imageNumber]; }
61  const float *getDerivativesXX(int sourceNumber) const { return 0; }
62  const float *getDerivativesXX(int sourceNumber, int imageNumber) const { return 0; }
63  const float *getDerivativesYY(int sourceNumber) const { return 0; }
64  const float *getDerivativesYY(int sourceNumber, int imageNumber) const { return 0; }
65  const float *getDerivativesXY(int sourceNumber) const { return 0; }
66  const float *getDerivativesXY(int sourceNumber, int imageNumber) const { return 0; }
67  const float *getShearComponents1(int sourceNumber) const { return 0; }
68  const float *getShearComponents1(int sourceNumber, int imageNumber) const { return 0; }
69  const float *getShearComponents2(int sourceNumber) const { return 0; }
70  const float *getShearComponents2(int sourceNumber, int imageNumber) const { return 0; }
71  const float *getConvergence(int sourceNumber) const { return 0; }
72  const float *getConvergence(int sourceNumber, int imageNumber) const { return 0; }
73 
74  float getTimeDelay(int sourceNumber, int imageNumber, int pointNumber,
75  Vector2D<float> beta) const; // in days!
76 protected:
77  BackProjectTreeBase();
78 
79  void init(const std::list<ImagesDataExtended *> &images,
80  Vector2D<double> center, double areaSize, int firstLevelSubdiv, int maxDepth, bool useWeights);
81  virtual void getDeflectionInformation(double squareSize, Vector2D<double> theta,
82  Vector2D<double> &alpha,
83  double &alphaxx, double &alphayy, double &alphaxy) = 0;
84 private:
85  void processNode(int numSubdiv, int level, int offset, const GridNodeBase *pNode, bool intensities);
86  void fillInRows(int numSubdiv, int level, int offset, int maxDepth, Vector2D<double> center, double areaSize, const std::vector<Vector2D<double> > &unscaledThetas, const std::vector<double> &distanceFractions);
87 
88  std::vector<std::vector<std::vector<Vector2D<float> > > > m_deflectionRows;
89  std::vector<std::vector<std::vector<float> > > m_magnificationRows[3];
90 
91  std::vector<Vector2D<float> > m_betas, m_thetas, m_subThetas;
92  std::vector<std::vector<Vector2D<float> * > > m_betaPointers, m_thetaPointers;
93 
94  std::vector<float> m_invMag, m_subMag0, m_subMag1, m_subMag2;
95  std::vector<std::vector<float *> > m_invMagPointers;
96 
97  std::vector<float> m_tmpBuf, m_tmpBuf2;
98  std::vector<float> m_oneVector;
99  std::vector<Vector2D<float> > m_zeroVector;
100 
101  double m_angularScale;
102  int m_firstLevelSubdiv;
103  int m_totalPoints;
104  bool m_useWeights;
105 };
106 
107 } // end namespace
108 
109 #endif // GRALE_BACKPROJECTTREEBASE_H