26 #ifndef GRALE_LENSPLANE_H
28 #define GRALE_LENSPLANE_H
30 #include "graleconfig.h"
32 #include <enut/networklayeraddress.h>
33 #include <serut/serializationinterface.h>
43 class GravitationalLens;
46 class GRALE_IMPORTEXPORT LensPlane :
public errut::ErrorBase
49 LensPlane(
const GravitationalLens *pLens);
51 bool init(Vector2D<double> bottomleft,Vector2D<double> topright,
int xpoints,
int ypoints, OpenCLKernel *pCLKernel = 0);
52 bool init(Vector2D<double> bottomleft,Vector2D<double> topright,
int xpoints,
int ypoints,
53 const nut::NetworkLayerAddress &serverAddress, uint16_t serverport);
54 bool isInit()
const {
return m_init; }
55 const GravitationalLens *getLens()
const {
return m_pLens; }
57 GravitationalLens *createDeflectionGridLens()
const;
59 bool scaleDeflections(
double factor);
60 int getNumXPoints()
const {
return numx; }
61 int getNumYPoints()
const {
return numy; }
62 Vector2D<double> getBottomLeft()
const {
return bottomleft; }
63 Vector2D<double> getTopRight()
const {
return topright; }
64 double getXStep()
const {
return xstep; }
65 double getYStep()
const {
return ystep; }
67 Vector2D<double> getAlpha(
int xpos,
int ypos)
const {
return alphas[xpos+ypos*numx]; }
68 void getAlphaDerivatives(
int xpos,
int ypos,
double &axx,
double &ayy,
double &axy)
const { axx = alphaxx[xpos+ypos*numx]; ayy = alphayy[xpos+ypos*numx]; axy = alphaxy[xpos+ypos*numx]; }
70 Vector2D<double> getIndexCoordinate(
int xpos,
int ypos)
const;
71 bool getIndices(Vector2D<double> v,
int *xpos,
int *ypos)
const;
73 bool write(serut::SerializationInterface &si)
const;
74 static bool read(serut::SerializationInterface &si,LensPlane **ip,std::string &errstr);
75 static bool load(
const std::string &fname,LensPlane **ip,std::string &errstr);
76 bool save(
const std::string &fname)
const;
78 const std::vector<Vector2D<double> > &getAlphas()
const {
return alphas; }
79 const std::vector<double> &getAlphaXXs()
const {
return alphaxx; }
80 const std::vector<double> &getAlphaXYs()
const {
return alphaxy; }
81 const std::vector<double> &getAlphaYYs()
const {
return alphayy; }
83 virtual void setFeedbackStatus(
const std::string &msg) { }
84 virtual void setFeedbackPercentage(
int pct) { }
87 static double getTime();
89 bool initUsingGPU(OpenCLKernel *pCLKernel,
bool lilePerLine,
int numSubLenses,
bool &renderError);
90 bool renderRemote(
const nut::NetworkLayerAddress &serverAddress, uint16_t serverport);
92 GravitationalLens *m_pLens;
94 std::vector<Vector2D<double> > alphas;
95 std::vector<double> alphaxx, alphayy, alphaxy;
97 Vector2D<double> bottomleft;
98 Vector2D<double> topright;
104 inline Vector2D<double> LensPlane::getIndexCoordinate(
int xpos,
int ypos)
const
106 return Vector2D<double>((((double)xpos))*xstep+bottomleft.getX(),(((double)ypos))*ystep+bottomleft.getY());
109 inline bool LensPlane::getIndices(Vector2D<double> v,
int *xpos,
int *ypos)
const
113 x = (int)(((v.getX()-bottomleft.getX())/xstep)+0.5);
114 y = (int)(((v.getY()-bottomleft.getY())/ystep)+0.5);
116 if (x < 0 || y < 0 || x >= numx || y >= numy)
125 #endif // GRALE_LENSPLANE_H