-
Notifications
You must be signed in to change notification settings - Fork 16
/
VolRender.H
117 lines (100 loc) · 4 KB
/
VolRender.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
// ---------------------------------------------------------------
// VolRender.H
// ---------------------------------------------------------------
#ifndef _VOLRENDER_H_
#define _VOLRENDER_H_
#include <cstdio>
#include <string>
using std::string;
#include <AMReX_Vector.H>
#include <AMReX_REAL.H>
#include <AMReX_Box.H>
#include <AMReX_AmrvisConstants.H>
#include <AMReX_DataServices.H>
#include <Volume.H>
#include <Palette.H>
#ifdef BL_VOLUMERENDER
#include <volpack.h>
#endif
using amrex::Real;
using amrex::DataServices;
class VolRender {
private:
VolRender();
public:
VolRender(const amrex::Vector<amrex::Box> &drawdomain, int mindrawnlevel,
int maxdrawnlevel, Palette *pptr, const string &asLightFileName);
~VolRender();
private:
unsigned int nPoints, bPoints;
int minDrawnLevel, maxDataLevel;
amrex::Vector<amrex::Box> drawnDomain;
char buffer[BUFSIZ];
int nDenRampPts, nGradRampPts, nShadeRampPts;
int maxDenRampPts, maxGradRampPts, maxShadeRampPts;
bool bVolRenderDefined;
Palette *palettePtr;
int paletteSize;
private:
vpContext *vpc;
amrex::Vector<float> density_ramp; // opacity as a function of density
amrex::Vector<float> gradient_ramp; // opacity as a function of grad magnitude
amrex::Vector<float> shade_table; // shading lookup table
amrex::Vector<float> value_shade_table; //for the value model
int rows, cols, planes;
unsigned char *swfData;
int swfDataSize;
bool swfDataAllocated, vpDataValid, swfDataValid, vpCreated;
int classifyFields, shadeFields;
amrex::Vector<int> densityRampX, gradientRampX;
amrex::Vector<float> densityRampY, gradientRampY;
float minRayOpacity, maxRayOpacity;
RawVoxel *volData;
public:
vpContext *GetVPContext() { return vpc; }
void MakeVPData();
void MakeSWFData(DataServices *dataServicesPtr, Real rDataMin, Real rDataMax,
const string &derivedName,
int iPaletteStart, int iPaletteEnd,
int iBlackIndex, int iWhiteIndex, int iColorSlots,
const bool bdrawboxes);
void MakePicture(Real mvmat[4][4], Real Length, int width, int height);
void SetImage(unsigned char *image_data, int width, int height, int pixel_type);
void WriteSWFData(const string &filenamebase, bool SWFLight);
unsigned char *GetSWFData() { return swfData; }
int GetSWFDataSize() const { return swfDataSize; }
bool VPDataValid() const { return vpDataValid; }
void InvalidateVPData();
bool SWFDataValid() const { return swfDataValid; }
void InvalidateSWFData();
bool SWFDataAllocated() const { return swfDataAllocated; }
const amrex::Vector<int> &DensityRampX() const { return densityRampX; }
const amrex::Vector<float> &DensityRampY() const { return densityRampY; }
void SetLightingModel(bool);
bool GetLightingModel() const { return lightingModel; }
void SetPreClassifyAlgorithm(bool);
bool GetPreClassifyAlgorithm() const { return preClassify; }
void SetAspect( Real newAspect) { vpAspect = newAspect; }
void SetTransferProperties();
void SetLighting(Real ambient, Real diffuse, Real specular, Real shiny,
Real minRay, Real maxRay);
Real GetDiffuse() { return diffuseMat; }
Real GetAmbient() { return ambientMat; }
Real GetSpecular() { return specularMat; }
Real GetShiny() { return shinyMat; }
Real GetMinRayOpacity() { return minRayOpacity; }
Real GetMaxRayOpacity() { return maxRayOpacity; }
private:
Real diffuseMat, shinyMat, specularMat, ambientMat;
Real vpLen, vpAspect;
bool lightingModel, preClassify;
bool bDrawAllBoxes;
int voxelFields;
int normalField, normalOffset, normalSize, normalMax;
int densityField, densityOffset, densitySize, densityMax;
int gradientField, gradientOffset, gradientSize, gradientMax;
bool AllocateSWFData();
void MakeDefaultTransProperties();
void SetProperties();
};
#endif