changa  3.5
 All Classes Files Functions Variables Typedefs Enumerations Friends Macros Groups Pages
dumpframe.h
1 #ifndef DUMPFRAME_HINCLUDED
2 #define DUMPFRAME_HINCLUDED
3 /*
4  ** @file dumpframe.h
5  *
6  * Image dumping routines for movies from PKDGRAV
7  * Original author: James Wadsley, 2002
8  */
9 
10 #include "GravityParticle.h"
11 #include "cosmoType.h"
12 
13 /* PST */
14 
15 #ifdef USE_PNG
16 #include "png.h" /* libpng header; includes zlib.h and setjmp.h */
17 #include "writepng.h" /* typedefs, common macros, public prototypes */
18 #endif
19 
21 typedef struct dfImage {
22  float r,g,b;
23  } DFIMAGE;
24 
26 typedef struct dfColorVal {
27  float fVal;
28  DFIMAGE dfColor;
29  } DFCOLORVAL;
30 
31 const int DF_MAX_COLORENTRIES = 20;
32 
34 typedef struct dfColorTable {
35  int iProperty;
36  int nColors;
37  float fPropMin, fPropMax;
38  DFCOLORVAL dfColors[DF_MAX_COLORENTRIES];
39  } DFCOLORTABLE;
40 
41 /*
42  Projection can be 2D or voxels
43 
44  In principle you can render voxels
45  and encode them in different ways.
46  I will just build a treezip every time.
47  */
48 
49 enum df_dimension {
50  DF_2D, /* Generic 2D */
51  DF_3D /* Voxel */
52  };
53 
54 enum df_projectstyle {
55  DF_PROJECT_NULL,
56  DF_PROJECT_ORTHO,
57  DF_PROJECT_PERSPECTIVE
58  };
59 
60 /* in principle voxels can have encoding options
61  For now it will be treezip
62  */
63 enum df_encodestyle {
64  DF_ENCODE_NULL,
65  DF_ENCODE_PPM,
66  DF_ENCODE_PNG,
67  DF_ENCODE_RLE,
68  DF_ENCODE_TREEZIP
69  };
70 
71 /* in principle voxels can have rendering options
72  For now this is ignored
73  */
74 enum df_renderstyle {
75  DF_RENDER_NULL,
76  DF_RENDER_POINT,
77  DF_RENDER_TSC,
78  DF_RENDER_SOLID,
79  DF_RENDER_SHINE
80  };
81 
82 enum df_numbering {
83  DF_NUMBERING_FRAME,
84  DF_NUMBERING_STEP,
85  DF_NUMBERING_TIME
86  };
87 
88 enum df_target {
89  DF_TARGET_USER,
90  DF_TARGET_COM_GAS,
91  DF_TARGET_COM_DARK,
92  DF_TARGET_COM_STAR,
93  DF_TARGET_COM_ALL,
94  DF_TARGET_OLDEST_STAR,
95  DF_TARGET_PHOTOGENIC
96  };
97 
98 enum df_log {
99  DF_LOG_NULL,
100  DF_LOG_SATURATE,
101  DF_LOG_COLOURSAFE
102  };
103 
104 enum df_star_age_colour {
105  DF_STAR_AGE_BASIC,
106  DF_STAR_AGE_BRIGHT,
107  DF_STAR_AGE_COLOUR,
108  DF_STAR_AGE_BRIGHT_COLOUR
109  };
110 
111 /* PST */
112 /* There is a common subset with framesetup that needs it's own structure -- parent class even */
116 typedef
117 struct inDumpFrame {
118  double dTime;
119  double dStep;
120  double duTFac;
121  double dExp;
122  /* 2D Projection info */
123  double r[3]; /* Centre */
124  double x[3]; /* Projection vectors */
125  double y[3];
126  double z[3];
127  double zClipNear,zClipFar,zEye;
128  int bExpansion; /* Rescale lengths into physical units with Expansion factor? */
129  int bPeriodic; /* Is it periodic? */
130  double fPeriod[3];
131  int nxPix,nyPix; /* Pixmap dimensions */
132  int iProject; /* Projection */
133 
134  /* Rendering */
135  double pScale1,pScale2;
136  double dGasSoftMul,dDarkSoftMul,dStarSoftMul;
137  double xlim,ylim,hmul;
138  double dYearUnit;
139  DFCOLORTABLE dfGasCT, dfDarkCT, dfStarCT;
140  int bColMassWeight;
141  int bGasSph;
142  int iColStarAge;
143  int bColLogInterp;
144  int iLogScale;
145  int iTarget;
146  int iRender;
147  /* Render Particle interface */
148  int offsetp_r,offsetp_fMass,offsetp_fSoft,offsetp_fBall2,offsetp_iActive,offsetp_fTimeForm;
149  int sizeofp;
150  int iTypeGas,iTypeDark,iTypeStar;
151 
152  double dMassGasMin, dMassGasMax;
153  double dMassDarkMin,dMassDarkMax;
154  double dMassStarMin,dMassStarMax;
155  double dMinGasMass;
156 
157  int bNonLocal; /* Is this data going non-local? */
158  int bVDetails;
159  } InDumpFrame;
160 
164 struct dfFrameSetup {
165  double dTime;
166  double duTFac;
167  int bCooling;
168  double dYearUnit;
169  /* Projection info */
170  double target[3]; /* Centre */
171  double eye[3]; /* Eye Position */
172  double up[3]; /* up vector */
173  double FOV;
174  double zEye1,zEye2,zEye;
175  double zClipNear,zClipFar; /* clipping */
176  double eye2[3]; /* a second vector to add to the eye vector */
177  int bEye2;
178  int bzClipFrac; /* Is z clipping a fraction of eye to target distance? */
179  int bzEye,bzEye1,bzEye2; /* Is zEye a fixed distance? */
180  int bEyeAbsolute; /* Eye position is in absolute coordinates (default relative to target point) */
181  int bAnchor;
182  int nxPix,nyPix; /* Pixmap dimensions */
183  int bExpansion; /* Rescale lengths into physical units with Expansion factor? */
184  int bPeriodic; /* Is it periodic? */
185  double fPeriod[3];
186  int iProject; /* Projection */
187 
188  /* Rendering controllers */
189  double pScale1,pScale2;
190  DFCOLORTABLE dfGasCT, dfDarkCT, dfStarCT;
191  int bColMassWeight;
192  int bGasSph;
193  int iColStarAge;
194  int bColLogInterp;
195  int iLogScale;
196  int iTarget;
197  double dGasSoftMul,dDarkSoftMul,dStarSoftMul;
198  int iRender; /* Rendering */
199 
200 
201 
202  int bNonLocal; /* Is this data going non-local? */
203  };
204 
205 /* MSR level in PKDGRAV */
206 
210  int bAllocated; /* Was this malloc'ed? */
211 
212  int nFrame;
213  int iMaxRung;
214  double dStep;
215  double dTime;
216  double duTFac;
217  int bCooling;
218  double dDumpFrameStep;
219  double dDumpFrameTime;
220  double dYearUnit;
221  /* Particle Filters */
222  double dMassGasMin, dMassGasMax;
223  double dMassDarkMin,dMassDarkMax;
224  double dMassStarMin,dMassStarMax;
225 
226  /* Time dependent Frame setup data */
227  int iFrameSetup;
228  int nFrameSetup;
229  struct dfFrameSetup *fs;
230  struct dfFrameSetup a;
231  struct dfFrameSetup b;
232  struct dfFrameSetup c;
233  struct dfFrameSetup d;
234  double rdt;
235  double dTimeMod;
236  double dTimeLoop,dPeriodLoop;
237  int bLoop;
238  int bGetCentreOfMass;
239  int bGetOldestStar;
240  int bGetPhotogenic;
241 
242  int iDimension; /* 2D Pixel or 3D Voxel */
243  int iEncode;
244  int iNumbering;
245  int bVDetails;
246  char FileName[161];
247  };
248 
249 enum arraytypes {
250  OUT_TEMP_ARRAY,
251  OUT_DENSITY_ARRAY,
252  OUT_UDOT_ARRAY,
253  OUT_U_ARRAY,
254  OUT_METALS_ARRAY,
255  OUT_TIMEFORM_ARRAY,
256  OUT_GROUP_ARRAY,
257  OUT_AGE_ARRAY
258 };
259 std::string VecFilename(int iType);
260 
261 void dfInitialize( struct DumpFrameContext **pdf, double dYearUnit, double dTime,
262  double dDumpFrameTime, double dStep, double dDumpFrameStep,
263  double dDelta, int iMaxRung, int bVDetails, char*,
264  int bPeriodic, Vector3D<double> vPeriod);
265 void dfFinalize( struct DumpFrameContext *df );
266 
267 void *dfAllocateImage( int nxPix, int nyPix );
268 void dfFreeImage( void *Image );
269 
270 void dfParseOptions( struct DumpFrameContext *df, char * filename );
271 
272 void dfParseCameraDirections( struct DumpFrameContext *df, char * filename );
273 
274 void dfSetupFrame( struct DumpFrameContext *df, double dTime, double dStep, double dExp, double *com, struct inDumpFrame *in, int nxPix, int nyPix);
275 
276 void dfMergeImage( struct inDumpFrame *in, void *Image1, int *nImage1, void *Image2, int *nImage2 );
277 void dfClearImage( struct inDumpFrame *in, void *Image, int *nImage );
278 
279 class DataManager;
280 void dfRenderParticlePoint( struct inDumpFrame *in, void *vImage,
281  GravityParticle *p, DataManager *dm);
282 void dfRenderParticleTSC( struct inDumpFrame *in, void *vImage,
283  GravityParticle *p, DataManager *dm);
284 void dfRenderParticleSolid( struct inDumpFrame *in, void *vImage,
285  GravityParticle *p, DataManager *dm);
286 
287 void dfFinishFrame( struct DumpFrameContext *df, double dTime, double dStep, struct inDumpFrame *in, void *Image, int liveViz, unsigned char **outgray);
288 
289 /* Interpolation Functions */
290 
291 void dfGetCoeff4( struct DumpFrameContext *df, int ifs );
292 void dfGetCoeff3L( struct DumpFrameContext *df, int ifs );
293 void dfGetCoeff3R( struct DumpFrameContext *df, int ifs );
294 void dfGetCoeff2( struct DumpFrameContext *df, int ifs );
295 
296 void dfGetCoeff( struct DumpFrameContext *df, int ifs );
297 
298 void dfInterp( struct DumpFrameContext *df, struct dfFrameSetup *pfs, double x );
299 
300 /* #include "dumpvoxel.h" */
301 
302 #endif
pixel of a dumpframe image
Definition: dumpframe.h:21
Associate floating point value with color.
Definition: dumpframe.h:26
Definition: DataManager.h:60
Data needed for a TreePiece to render its part of the image.
Definition: dumpframe.h:116
Global simulation parameters for dumpframe.
Definition: dumpframe.h:209
Table of colors for a particle property.
Definition: dumpframe.h:34
Higher level information describing a frame. This is a table entry for later interpolation, changing properties of frames.
Definition: dumpframe.h:164
Fundamental type for a particle.
Definition: GravityParticle.h:316