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