- Timestamp:
- Mar 8, 2007, 5:56:29 PM (18 years ago)
- Location:
- trunk/gui/vizservers/nanovis
- Files:
-
- 3 added
- 5 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/vizservers/nanovis/Makefile
r604 r617 4 4 ColorGradientGLUTWindow.o TransferFunctionGLUTWindow.o MainWindow.o Event.o \ 5 5 Lic.o Renderable.o Camera.o ScreenSnapper.o VolumeRenderer.o PlaneRenderer.o Nv.o \ 6 NvZincBlendeVolumeShader.o NvShader.o NvVolumeShader.o NvRegularVolumeShader.o NvVolQDVolumeShader.o\7 NvLoadFile.o Nv VolQDVolume.o NvDefaultTFData.o NvColorTableShader.o NvColorTableRenderer.o NvParticleAdvectionShader.o \8 NvEventLog.o NvParticleRenderer.o NvLIC.o NvZincBlendeReconstructor.o \6 NvZincBlendeVolumeShader.o NvShader.o NvVolumeShader.o NvRegularVolumeShader.o \ 7 NvLoadFile.o NvDefaultTFData.o NvColorTableShader.o NvColorTableRenderer.o NvParticleAdvectionShader.o \ 8 NvEventLog.o NvParticleRenderer.o NvLIC.o NvZincBlendeReconstructor.o NvStdVertexShader.o \ 9 9 R2string.o R2FilePath.o R2Fonts.o R2Object.o 10 10 … … 46 46 gcc $(CFLAG) Nv.cpp 47 47 48 NvStdVertexShader.o: NvStdVertexShader.cpp NvStdVertexShader.h 49 gcc $(CFLAG) NvStdVertexShader.cpp 50 48 51 NvLoadFile.o: NvLoadFile.cpp NvLoadFile.cpp 49 52 gcc $(CFLAG) NvLoadFile.cpp … … 75 78 NvDefaultTFData.o: NvDefaultTFData.cpp 76 79 gcc $(CFLAG) NvDefaultTFData.cpp 77 78 NvVolQDVolume.o: NvVolQDVolume.cpp NvVolQDVolume.h79 gcc $(CFLAG) NvVolQDVolume.cpp80 81 NvVolQDVolumeShader.o: NvVolQDVolumeShader.cpp NvVolQDVolumeShader.h82 gcc $(CFLAG) NvVolQDVolumeShader.cpp83 80 84 81 NvRegularVolumeShader.o: NvRegularVolumeShader.cpp NvRegularVolumeShader.h -
trunk/gui/vizservers/nanovis/NvLoadFile.cpp
r580 r617 5 5 #include <assert.h> 6 6 7 extern void load_volqd_volume(int index, int width, int height, int depth,8 int n_component, float* data, double vmin, double vmax, Vector3& cellSize);9 10 extern void load_zinc_volume(int index, int width, int height, int depth,11 int n_component, float* data, double vmin, double vmax, Vector3& cellSize);12 13 void NvLoadVolumeBinFile(int index, char* filename)14 {15 //read file16 FILE* file = fopen(filename, "rb");17 assert(file!=NULL);18 19 int width, height, depth, n_components;20 unsigned int type;21 unsigned int interp;22 23 fread(&width, sizeof(int), 1, file);24 fread(&height, sizeof(int), 1, file);25 fread(&depth, sizeof(int), 1, file);26 fread(&n_components, sizeof(int), 1, file);27 fread(&type, sizeof(unsigned int), 1, file);28 fread(&interp, sizeof(unsigned int), 1, file);29 30 int size = n_components*width*depth*height;31 32 float* data;33 data = new float[size];34 35 fread(data, sizeof(float) * size, 1, file);36 fclose(file);37 38 float min = data[0], max = data[0];39 float non_zero_min = -1e27f;40 for (int i=0; i<n_components*width*depth*height; i++)41 {42 if(data[i]>max)43 max = data[i];44 if(data[i]<min)45 min = data[i];46 47 if(data[i]<non_zero_min && data[i] != 0)48 {49 non_zero_min = data[i];50 }51 }52 53 54 int i = 0;55 if (max != 0.0f)56 {57 for (i=0; i < size; ++i) {58 data[i] = data[i] / max;59 }60 }61 62 Vector3 cellsize;63 cellsize.x = width * 0.25;64 cellsize.y = height * 0.25;65 cellsize.z = depth * 0.25;66 67 load_volqd_volume(index, width, height, depth, 4, data, min, max, cellsize);68 69 delete [] data;70 }71 72 void NvLoadVolumeBinFile2(int index, char* filename)73 {74 //read file75 FILE* file = fopen(filename, "rb");76 assert(file!=NULL);77 78 int width, height, depth, n_components;79 unsigned int type;80 unsigned int interp;81 82 fread(&width, sizeof(int), 1, file);83 fread(&height, sizeof(int), 1, file);84 fread(&depth, sizeof(int), 1, file);85 fread(&n_components, sizeof(int), 1, file);86 fread(&type, sizeof(unsigned int), 1, file);87 fread(&interp, sizeof(unsigned int), 1, file);88 89 int size = n_components*width*depth*height;90 91 float* data;92 data = new float[size];93 94 fread(data, sizeof(float) * size, 1, file);95 fclose(file);96 97 float min = data[0], max = data[0];98 float non_zero_min = -1e27f;99 for (int i=0; i<n_components*width*depth*height; i++)100 {101 if(data[i]>max)102 max = data[i];103 if(data[i]<min)104 min = data[i];105 106 if(data[i]<non_zero_min && data[i] != 0)107 {108 non_zero_min = data[i];109 }110 }111 112 113 int i = 0;114 if (max != 0.0f)115 {116 for (i=0; i < size; ++i) {117 data[i] = data[i] / max;118 }119 }120 121 Vector3 cellsize;122 cellsize.x = width * 0.25;123 cellsize.y = height * 0.25;124 cellsize.z = depth * 0.25;125 126 load_zinc_volume(index, width, height, depth, 4, data, min, max, cellsize);127 128 delete [] data;129 } -
trunk/gui/vizservers/nanovis/NvZincBlendeReconstructor.cpp
r601 r617 22 22 } 23 23 24 ZincBlendeVolume* NvZincBlendeReconstructor::load (const char* fileName)24 ZincBlendeVolume* NvZincBlendeReconstructor::loadFromFile(const char* fileName) 25 25 { 26 26 Vector3 origin, delta; 27 double temp; 27 28 int width = 0, height = 0, depth = 0; 28 29 void* data = NULL; 29 30 30 // TBD 31 // INSOO 32 // I have to handle the header of the file 31 ifstream stream; 32 stream.open(fileName, ios::binary); 33 34 ZincBlendeVolume* volume = loadFromStream(stream); 35 36 stream.close(); 37 38 return volume; 39 } 40 41 ZincBlendeVolume* NvZincBlendeReconstructor::loadFromStream(std::istream& stream) 42 { 43 Vector3 origin, delta; 44 double temp; 45 int width = 0, height = 0, depth = 0; 46 void* data = NULL; 47 48 char str[5][20]; 49 do { 50 getLine(stream); 51 } while(strstr(buff, "object") == 0); 52 53 54 sscanf(buff, "%s%s%s%s%s%d%d%d", str[0], str[1], str[2], str[3], str[4],&width, &height, &depth); 55 getLine(stream); 56 sscanf(buff, "%s%f%f%f", str[0], &(origin.x), &(origin.y), &(origin.z)); 57 getLine(stream); 58 sscanf(buff, "%s%f%f%f", str[0], &(delta.x), &temp, &temp); 59 getLine(stream); 60 sscanf(buff, "%s%f%f%f", str[0], &temp, &(delta.y), &temp); 61 getLine(stream); 62 sscanf(buff, "%s%f%f%f", str[0], &temp, &temp, &(delta.z)); 63 64 do { 65 getLine(stream); 66 } while(strcmp(buff, "<\\HDR>") != 0); 67 33 68 69 width = width / 4; 70 height = height / 4; 71 depth = depth / 4; 72 data = new double[width * height * depth * 8 * 4]; // 8 atom per cell, 4 double (x, y, z, and probability) per atom 73 74 try { 75 stream.read((char*) data, width * height * depth * 8 * 4 * sizeof(double)); 76 } 77 catch (...) 78 { 79 printf("ERROR\n"); 80 } 81 34 82 return buildUp(origin, delta, width, height, depth, data); 35 83 } 36 84 37 struct _Nv UnitCellInfo {38 floatindexX, indexY, indexZ;39 float atoms[8];85 struct _NvAtomInfo { 86 double indexX, indexY, indexZ; 87 double atom; 40 88 41 89 int getIndex(int width, int height) const … … 48 96 // The reasone why index is multiplied by 4 is that one unit cell has half of eight atoms 49 97 // ,i.e. four atoms are mapped into RGBA component of one texel 50 return ( indexZ + indexX * width + indexY* width * height) * 4;98 return ((int) (indexZ - 1)+ (int) (indexX - 1) * width + (int) (indexY - 1) * width * height) * 4; 51 99 } 52 100 }; 53 101 54 template<class T> 55 inline int _NvMax2(T a, T b) { return ((a >= b)? a : b); } 56 57 template<class T> 58 inline int _NvMin2(T a, T b) { return ((a >= b)? a : b); } 59 60 template<class T> 61 inline int _NvMax3(T a, T b, T c) { return ((a >= b)? ((a >= c) ? a : c) : ((b >= c)? b : c)); } 62 63 template<class T> 64 inline int _NvMin3(T a, T b, T c) { return ((a <= b)? ((a <= c) ? a : c) : ((b <= c)? b : c)); } 65 66 template<class T> 67 inline int _NvMax9(T* a, T curMax) { return _NvMax3(_NvMax3(a[0], a[1], a[2]), _NvMax3(a[3], a[4], a[5]), _NvMax3(a[6], a[7], curMax)); } 68 69 template<class T> 70 inline int _NvMin9(T* a, T curMax) { return _NvMin3(_NvMax3(a[0], a[1], a[2]), _NvMin3(a[3], a[4], a[5]), _NvMin3(a[6], a[7], curMax)); } 102 103 template<class T> 104 inline T _NvMax2(T a, T b) { return ((a >= b)? a : b); } 105 106 template<class T> 107 inline T _NvMin2(T a, T b) { return ((a >= b)? a : b); } 108 109 template<class T> 110 inline T _NvMax3(T a, T b, T c) { return ((a >= b)? ((a >= c) ? a : c) : ((b >= c)? b : c)); } 111 112 template<class T> 113 inline T _NvMin3(T a, T b, T c) { return ((a <= b)? ((a <= c) ? a : c) : ((b <= c)? b : c)); } 114 115 template<class T> 116 inline T _NvMax9(T* a, T curMax) { return _NvMax3(_NvMax3(a[0], a[1], a[2]), _NvMax3(a[3], a[4], a[5]), _NvMax3(a[6], a[7], curMax)); } 117 118 template<class T> 119 inline T _NvMin9(T* a, T curMax) { return _NvMin3(_NvMax3(a[0], a[1], a[2]), _NvMin3(a[3], a[4], a[5]), _NvMin3(a[6], a[7], curMax)); } 120 121 template<class T> 122 inline T _NvMax4(T* a) { return _NvMax2(_NvMax2(a[0], a[1]), _NvMax2(a[2], a[3])); } 123 124 template<class T> 125 inline T _NvMin4(T* a) { return _NvMin2(_NvMin2(a[0], a[1]), _NvMin2(a[2], a[3])); } 126 71 127 72 128 ZincBlendeVolume* NvZincBlendeReconstructor::buildUp(const Vector3& origin, const Vector3& delta, int width, int height, int depth, void* data) … … 74 130 ZincBlendeVolume* zincBlendeVolume = NULL; 75 131 76 float * dataVolumeA, *dataVolumeB;132 float *fourAnionVolume, *fourCationVolume; 77 133 int cellCount = width * height * depth; 78 dataVolumeA= new float[cellCount * sizeof(float) * 4];79 dataVolumeB= new float[cellCount * sizeof(float) * 4];80 81 _Nv UnitCellInfo* srcPtr = (_NvUnitCellInfo*) data;134 fourAnionVolume = new float[cellCount * sizeof(float) * 4]; 135 fourCationVolume = new float[cellCount * sizeof(float) * 4]; 136 137 _NvAtomInfo* srcPtr = (_NvAtomInfo*) data; 82 138 83 139 float vmin, vmax; … … 85 141 int index; 86 142 87 vmin = vmax = srcPtr->atoms[0]; 88 for (int i = 0; i < cellCount; ++i) 143 vmin = vmax = srcPtr->atom; 144 145 int i; 146 for (i = 0; i < cellCount; ++i) 89 147 { 90 148 index = srcPtr->getIndex(width, height); 91 component4A = dataVolumeA + index; 92 component4B = dataVolumeB + index; 93 94 95 component4A[0] = srcPtr->atoms[0]; 96 component4A[1] = srcPtr->atoms[1]; 97 component4A[2] = srcPtr->atoms[2]; 98 component4A[3] = srcPtr->atoms[3]; 99 100 component4B[0] = srcPtr->atoms[4]; 101 component4B[1] = srcPtr->atoms[5]; 102 component4B[2] = srcPtr->atoms[6]; 103 component4B[3] = srcPtr->atoms[7]; 104 105 vmin = _NvMax9((float*) srcPtr->atoms, vmin); 106 vmax = _NvMax9((float*) srcPtr->atoms, vmax); 107 108 ++srcPtr; 109 } 110 111 /* 112 zincBlendeVolume = new ZincBlendeVolume(origin.x, origin.y, origin.z, 113 width, height, depth, size, 4, 114 dataVolumeA, dataVolumeB, 115 vmin, vmax, cellSize); 116 */ 149 component4A = fourAnionVolume + index; 150 component4B = fourCationVolume + index; 151 152 component4A[0] = (float) srcPtr->atom; srcPtr++; 153 component4A[1] = (float) srcPtr->atom; srcPtr++; 154 component4A[2] = (float) srcPtr->atom; srcPtr++; 155 component4A[3] = (float) srcPtr->atom; srcPtr++; 156 157 component4B[0] = (float) srcPtr->atom; srcPtr++; 158 component4B[1] = (float) srcPtr->atom; srcPtr++; 159 component4B[2] = (float) srcPtr->atom; srcPtr++; 160 component4B[3] = (float) srcPtr->atom; srcPtr++; 161 162 vmax = _NvMax3(_NvMax4(component4A), _NvMax4(component4B), vmax); 163 vmin = _NvMin3(_NvMin4(component4A), _NvMin4(component4B), vmin); 164 } 165 166 double dv = vmax - vmin; 167 if (vmax != 0.0f) 168 { 169 for (i=0; i < cellCount; ++i) 170 { 171 fourAnionVolume[i] = (fourAnionVolume[i] - vmin)/ dv; 172 fourCationVolume[i] = (fourCationVolume[i] - vmin) / dv; 173 } 174 } 175 176 Vector3 cellSize; 177 cellSize.x = 0.25 / width; 178 cellSize.y = 0.25 / height; 179 cellSize.z = 0.25 / depth; 180 181 zincBlendeVolume = new ZincBlendeVolume(origin.x, origin.y, origin.z, 182 width, height, depth, 1, 4, 183 fourAnionVolume, fourCationVolume, 184 vmin, vmax, cellSize); 117 185 118 186 return zincBlendeVolume; 119 187 } 120 188 189 void NvZincBlendeReconstructor::getLine(std::istream& sin) 190 { 191 char ch; 192 int index = 0; 193 do { 194 sin.get(ch); 195 if (ch == '\n') break; 196 buff[index++] = ch; 197 if (ch == '>') 198 { 199 if (buff[1] == '\\') 200 break; 201 } 202 } while (!sin.eof()); 203 204 buff[index] = '\0'; 205 } 206 -
trunk/gui/vizservers/nanovis/NvZincBlendeReconstructor.h
r601 r617 17 17 #define __NV_ZINC_BLENDE_RECONSTRUCTOR_H__ 18 18 19 #include <stdio.h> 20 #include <ostream> 21 #include <sstream> 22 #include <fstream> 19 23 20 24 #include "Vector3.h" … … 23 27 24 28 class NvZincBlendeReconstructor { 29 char buff[255]; 25 30 26 31 /** … … 44 49 */ 45 50 static NvZincBlendeReconstructor* getInstance(); 51 52 private : 53 /** 54 * @brief Get a line from file. It is used for reading header because header is written in ascii. 55 * @param fp A file pointer of data file 56 */ 57 void getLine(std::istream& stream); 46 58 47 59 public : … … 50 62 * @param fileName Zinc blende file name, which data is generated by NEMO-3D 51 63 */ 52 ZincBlendeVolume* load(const char* fileName); 64 ZincBlendeVolume* loadFromFile(const char* fileName); 65 66 /** 67 * @brief Load Zinc blende binary volume data and create ZincBlendeVolume with the file 68 * @param data Zinc blende binary volume data, which data is generated by NEMO-3D and transferred from nanoscale 69 */ 70 ZincBlendeVolume* loadFromStream(std::istream& stream); 53 71 54 72 /** -
trunk/gui/vizservers/nanovis/NvZincBlendeVolumeShader.h
r580 r617 26 26 inline void NvZincBlendeVolumeShader::bind(unsigned int tfID, Volume* volume, int sliceMode) 27 27 { 28 //ZincBlendeVolume* vol = reinterpret_cast<ZincBlendeVolume*)>(volume);29 28 ZincBlendeVolume* vol = (ZincBlendeVolume*)volume; 30 29 cgGLSetStateMatrixParameter(_mviParam, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_INVERSE); -
trunk/gui/vizservers/nanovis/VolumeRenderer.cpp
r580 r617 14 14 */ 15 15 16 #include <R2/R2string.h> 17 #include <R2/R2FilePath.h> 16 18 #include "VolumeRenderer.h" 17 18 19 VolumeRenderer::VolumeRenderer(CGcontext _context): 19 #include "NvStdVertexShader.h" 20 21 22 VolumeRenderer::VolumeRenderer(): 20 23 n_volumes(0), 21 g_context(_context),22 24 slice_mode(false), 23 25 volume_mode(true) 24 26 { 25 volume.clear(); 26 tf.clear(); 27 28 init_shaders(); 29 init_font("/opt/nanovis/lib/font/Font.bmp"); 27 volume.clear(); 28 tf.clear(); 29 30 init_shaders(); 31 32 R2string path = R2FilePath::getInstance()->getPath("Font.bmp"); 33 init_font((const char*) path); 30 34 } 31 35 32 36 VolumeRenderer::~VolumeRenderer() 33 37 { 34 delete m_zincBlendeShader;35 delete m_regularVolumeShader;36 delete m_volQDVolumeShader;38 delete _zincBlendeShader; 39 delete _regularVolumeShader; 40 delete _stdVertexShader; 37 41 } 38 42 … … 41 45 42 46 //standard vertex program 43 m_vert_std_vprog = loadProgram(g_context, CG_PROFILE_VP30, CG_SOURCE, "/opt/nanovis/lib/shaders/vertex_std.cg"); 44 m_mvp_vert_std_param = cgGetNamedParameter(m_vert_std_vprog, "modelViewProjMatrix"); 45 m_mvi_vert_std_param = cgGetNamedParameter(m_vert_std_vprog, "modelViewInv"); 46 47 _stdVertexShader = new NvStdVertexShader(); 47 48 48 49 //volume rendering shader: one cubic volume 49 m_regularVolumeShader = new NvRegularVolumeShader();50 _regularVolumeShader = new NvRegularVolumeShader(); 50 51 51 52 //volume rendering shader: one zincblende orbital volume. … … 57 58 //The engine is already capable of rendering multiple volumes and combine them. Thus, we just invoke this shader on 58 59 //S, P, D and SS orbitals with different transfor functions. The result is a multi-orbital rendering. 59 m_zincBlendeShader = new NvZincBlendeVolumeShader(); 60 61 m_volQDVolumeShader = new NvVolQDVolumeShader(); 60 _zincBlendeShader = new NvZincBlendeVolumeShader(); 62 61 } 63 62 … … 669 668 670 669 671 void VolumeRenderer::activate_volume_shader(int volume_index, bool slice_mode) {672 670 void VolumeRenderer::activate_volume_shader(int volume_index, bool slice_mode) 671 { 673 672 //vertex shader 674 cgGLSetStateMatrixParameter(m_mvp_vert_std_param, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY); 675 cgGLSetStateMatrixParameter(m_mvi_vert_std_param, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_INVERSE); 676 cgGLBindProgram(m_vert_std_vprog); 677 cgGLEnableProfile(CG_PROFILE_VP30); 678 673 _stdVertexShader->bind(); 679 674 680 675 if (volume[volume_index]->volume_type == CUBIC) 681 676 { 682 677 //regular cubic volume 683 m_regularVolumeShader->bind(tf[volume_index]->id, volume[volume_index], slice_mode); 684 } 685 678 _regularVolumeShader->bind(tf[volume_index]->id, volume[volume_index], slice_mode); 679 } 686 680 else if (volume[volume_index]->volume_type == ZINCBLENDE) 687 681 { 688 m_zincBlendeShader->bind(tf[volume_index]->id, volume[volume_index], slice_mode); 689 } 690 else if (volume[volume_index]->volume_type == VOLQD) 691 { 692 m_volQDVolumeShader->bind(tf[volume_index]->id, volume[volume_index], slice_mode); 682 _zincBlendeShader->bind(tf[volume_index]->id, volume[volume_index], slice_mode); 693 683 } 694 684 } … … 697 687 void VolumeRenderer::deactivate_volume_shader() 698 688 { 699 cgGLDisableProfile(CG_PROFILE_VP30); 700 701 m_regularVolumeShader->unbind(); 702 m_zincBlendeShader->unbind(); 689 _stdVertexShader->unbind(); 690 _regularVolumeShader->unbind(); 691 _zincBlendeShader->unbind(); 703 692 } 704 693 … … 756 745 757 746 758 void VolumeRenderer::init_font(c har* filename) {747 void VolumeRenderer::init_font(const char* filename) { 759 748 760 749 FILE *file; -
trunk/gui/vizservers/nanovis/VolumeRenderer.h
r580 r617 35 35 #include "PerfQuery.h" 36 36 #include "NvRegularVolumeShader.h" 37 #include "NvVolQDVolumeShader.h"38 37 #include "NvZincBlendeVolumeShader.h" 38 #include "NvStdVertexShader.h" 39 39 40 40 using namespace std; … … 43 43 44 44 private: 45 vector <Volume*> volume; //array of volumes46 vector <TransferFunction*> tf;//array of corresponding transfer functions47 int n_volumes;45 vector <Volume*> volume; //!<- array of volumes 46 vector <TransferFunction*> tf; //!<- array of corresponding transfer functions 47 int n_volumes; 48 48 49 bool slice_mode; //enable cut planes 50 bool volume_mode; //enable full volume rendering 49 bool slice_mode; //!<- enable cut planes 50 bool volume_mode; //!<- enable full volume rendering 51 52 /** 53 * shader parameters for rendering a single cubic volume 54 */ 55 NvRegularVolumeShader* _regularVolumeShader; 51 56 52 57 53 //cg related 54 CGcontext g_context; //the Nvidia cg context 55 56 //shader parameters for rendering a single cubic volume 57 NvRegularVolumeShader* m_regularVolumeShader; 58 NvVolQDVolumeShader* m_volQDVolumeShader; 59 60 61 //Shader parameters for rendering a single zincblende orbital. 62 //A simulation contains S, P, D and SS, total of 4 orbitals. A full rendering requires 4 zincblende orbital volumes. 63 //A zincblende orbital volume is decomposed into two "interlocking" cubic volumes and passed to the shader. 64 //We render each orbital with its own independent transfer functions then blend the result. 65 // 66 //The engine is already capable of rendering multiple volumes and combine them. Thus, we just invoke this shader on 67 //S, P, D and SS orbitals with different transfor functions. The result is a multi-orbital rendering. 68 //This is equivalent to rendering 4 unrelated data sets occupying the same space. 69 NvZincBlendeVolumeShader* m_zincBlendeShader; 58 /** 59 * Shader parameters for rendering a single zincblende orbital. 60 * A simulation contains S, P, D and SS, total of 4 orbitals. A full rendering requires 4 zincblende orbital volumes. 61 * A zincblende orbital volume is decomposed into two "interlocking" cubic volumes and passed to the shader. 62 * We render each orbital with its own independent transfer functions then blend the result. 63 * 64 * The engine is already capable of rendering multiple volumes and combine them. Thus, we just invoke this shader on 65 * S, P, D and SS orbitals with different transfor functions. The result is a multi-orbital rendering. 66 * This is equivalent to rendering 4 unrelated data sets occupying the same space. 67 */ 68 NvZincBlendeVolumeShader* _zincBlendeShader; 70 69 71 70 71 /** 72 * standard vertex shader 73 */ 74 NvStdVertexShader* _stdVertexShader; 72 75 73 76 //standard vertex shader parameters … … 87 90 void get_near_far_z(Mat4x4 mv, double &zNear, double &zFar); 88 91 89 void init_font(c har* filename);92 void init_font(const char* filename); 90 93 GLuint font_texture; //the id of the font texture 91 94 void glPrint(char* string, int set); //there are two sets of font in the texture. 0, 1 … … 95 98 96 99 public: 97 VolumeRenderer( CGcontext _context);100 VolumeRenderer(); 98 101 ~VolumeRenderer(); 99 102 -
trunk/gui/vizservers/nanovis/ZincBlendeVolume.cpp
r580 r617 25 25 : Volume(x, y, z, w, h, d, s, n, dataVolumeA, v0, v1), cell_size(cellSize) 26 26 { 27 28 27 //label it as zincblende 29 28 volume_type = ZINCBLENDE; 30 31 //compute cellsize32 cell_size = Vector3(0.25/w, 0.25/h, 0.25/d);33 34 29 35 30 //store member tex initialize in Volume() as zincblende_tex[0] … … 44 39 45 40 zincblende_tex[1] = secondTex; 46 47 41 } 48 42 -
trunk/gui/vizservers/nanovis/nanovis.cpp
r611 r617 43 43 #include "ZincBlendeVolume.h" 44 44 #include "NvLoadFile.h" 45 #include "NvVolQDVolume.h"46 45 #include "NvColorTableRenderer.h" 47 46 #include "NvEventLog.h" 47 #include "NvZincBlendeReconstructor.h" 48 48 49 49 // R2 headers … … 286 286 } 287 287 288 /*289 {290 glEnable(GL_TEXTURE_2D);291 glEnable(GL_BLEND);292 293 glViewport(0, 0, 1024, 1024);294 glMatrixMode(GL_PROJECTION);295 glLoadIdentity();296 gluOrtho2D(0, render_width, 0, render_height);297 glMatrixMode(GL_MODELVIEW);298 glLoadIdentity();299 300 glBegin(GL_QUADS);301 glTexCoord2f(0, 0); glVertex2f(30, 30);302 glTexCoord2f(1, 0); glVertex2f(1024 - 60, 30);303 glTexCoord2f(1, 1); glVertex2f(1024 - 60, 1024 - 60);304 glTexCoord2f(0, 1); glVertex2f(30, 1024 - 60);305 glEnd();306 }307 */308 309 288 static int 310 289 ScreenShotCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]) 311 290 { 312 // INSOO313 /*314 291 int old_win_width = win_width; 315 292 int old_win_height = win_height; 293 316 294 #ifdef XINETD 317 295 resize_offscreen_buffer(1024, 1024); … … 320 298 display(); 321 299 300 // INSOO 322 301 // TBD 323 302 Volume* vol = volume[0]; … … 336 315 read_screen(); 337 316 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 317 338 318 // INSOO 339 319 // TBD 320 //bmp_write("nv>screenshot -bytes"); 340 321 bmp_write_to_file(); 341 //bmp_write("nv>screenshot -bytes");322 342 323 resize_offscreen_buffer(old_win_width, old_win_height); 343 324 #endif 344 */345 346 325 347 326 return TCL_OK; … … 824 803 825 804 char buffer[8096]; 826 while (nbytes > 0) { 805 while (nbytes > 0) 806 { 827 807 int chunk = (sizeof(buffer) < nbytes) ? sizeof(buffer) : nbytes; 828 808 int status = fread(buffer, 1, chunk, stdin); … … 842 822 return TCL_ERROR; 843 823 } 844 std::stringstream fdata; 845 fdata.write(buf.bytes(),buf.size()); 824 846 825 847 826 int n = n_volumes; 848 err = load_volume_stream(n, fdata); 849 850 if (err) { 851 Tcl_AppendResult(interp, err.remark().c_str(), (char*)NULL); 852 return TCL_ERROR; 853 } 827 char header[6]; 828 memcpy(header, buf.bytes(), sizeof(char) * 5); 829 header[5] = '\0'; 830 831 if (!strcmp(header, "<HDR>")) 832 { 833 std::stringstream fdata(std::ios_base::out|std::ios_base::in|std::ios_base::binary); 834 fdata.write(buf.bytes(),buf.size()); 835 836 Volume* vol = NULL; 837 vol = NvZincBlendeReconstructor::getInstance()->loadFromStream(fdata); 838 if (vol) 839 { 840 while (n_volumes <= n) 841 { 842 volume.push_back((Volume*) NULL); 843 n_volumes++; 844 } 845 846 if (volume[n] != NULL) 847 { 848 delete volume[n]; 849 volume[n] = NULL; 850 } 851 852 float dx0 = -0.5; 853 float dy0 = -0.5*vol->height/vol->width; 854 float dz0 = -0.5*vol->depth/vol->width; 855 vol->move(Vector3(dx0, dy0, dz0)); 856 857 volume[n] = vol; 858 } 859 } 860 else 861 { 862 std::stringstream fdata; 863 fdata.write(buf.bytes(),buf.size()); 864 err = load_volume_stream(n, fdata); 865 if (err) { 866 Tcl_AppendResult(interp, err.remark().c_str(), (char*)NULL); 867 return TCL_ERROR; 868 } 869 } 870 854 871 855 872 // … … 861 878 // appear at all. 862 879 // 863 volume[n]->set_n_slice(256-n); 864 volume[n]->disable_cutplane(0); 865 volume[n]->disable_cutplane(1); 866 volume[n]->disable_cutplane(2); 867 g_vol_render->add_volume(volume[n], get_transfunc("default")); 880 if (volume[n]) 881 { 882 volume[n]->set_n_slice(256-n); 883 volume[n]->disable_cutplane(0); 884 volume[n]->disable_cutplane(1); 885 volume[n]->disable_cutplane(2); 886 887 g_vol_render->add_volume(volume[n], get_transfunc("default")); 888 } 868 889 869 890 return TCL_OK; … … 1072 1093 ++iter; 1073 1094 } 1074 return TCL_OK;1075 }1076 else if (c == 'v' && strcmp(argv[1],"volqd") == 0) {1077 int n = n_volumes;1078 1079 NvLoadVolumeBinFile(n, "/home/nanohub/vrinside/grid_1_0");1080 1081 volume[n]->set_n_slice(256-n);1082 volume[n]->disable_cutplane(0);1083 volume[n]->disable_cutplane(1);1084 volume[n]->disable_cutplane(2);1085 g_vol_render->add_volume(volume[n], get_transfunc("default"));1086 1087 return TCL_OK;1088 }1089 else if (c == 'z' && strcmp(argv[1],"zinc") == 0) {1090 int n = n_volumes;1091 1092 NvLoadVolumeBinFile2(n, "/home/nanohub/vrinside/grid_1_0");1093 1094 volume[n]->set_n_slice(256-n);1095 volume[n]->disable_cutplane(0);1096 volume[n]->disable_cutplane(1);1097 volume[n]->disable_cutplane(2);1098 g_vol_render->add_volume(volume[n], get_transfunc("default"));1099 1100 1095 return TCL_OK; 1101 1096 } … … 1906 1901 n_component, data, vmin, vmax); 1907 1902 assert(volume[index]!=0); 1908 }1909 1910 //INSOO1911 extern float tfdefaultdata[];1912 void load_volqd_volume(int index, int width, int height, int depth,1913 int n_component, float* data, double vmin, double vmax, Vector3& cellSize)1914 {1915 while (n_volumes <= index) {1916 volume.push_back(NULL);1917 n_volumes++;1918 }1919 1920 if (volume[index] != NULL) {1921 delete volume[index];1922 volume[index] = NULL;1923 }1924 1925 volume[index] = new NvVolQDVolume(0.f, 0.f, 0.f, width, height, depth, 1.,1926 n_component, data, vmin, vmax, cellSize);1927 1928 float dx0 = -0.5;1929 float dy0 = -0.5*height/width;1930 float dz0 = -0.5*depth/width;1931 volume[index]->move(Vector3(dx0, dy0, dz0));1932 1933 // INSOO1934 // Tentatively1935 TransferFunction* tf = new TransferFunction(256, tfdefaultdata);1936 g_vol_render->shade_volume(volume[index], tf);1937 }1938 1939 // INSOO1940 void load_zinc_volume(int index, int width, int height, int depth,1941 int n_component, float* data, double vmin, double vmax, Vector3& cellSize)1942 {1943 while (n_volumes <= index) {1944 volume.push_back(NULL);1945 n_volumes++;1946 }1947 1948 if (volume[index] != NULL) {1949 delete volume[index];1950 volume[index] = NULL;1951 }1952 1953 volume[index] = new ZincBlendeVolume(0.f, 0.f, 0.f, width, height, depth, 1.,1954 n_component, data, data, vmin, vmax, cellSize);1955 1956 float dx0 = -0.5;1957 float dy0 = -0.5*height/width;1958 float dz0 = -0.5*depth/width;1959 volume[index]->move(Vector3(dx0, dy0, dz0));1960 1903 } 1961 1904 … … 2201 2144 2202 2145 //create volume renderer and add volumes to it 2203 g_vol_render = new VolumeRenderer( g_context);2146 g_vol_render = new VolumeRenderer(); 2204 2147 2205 2148 -
trunk/gui/vizservers/nanovis/shaders/zincblende_volume.cg
r580 r617 29 29 PixelOut OUT; 30 30 31 // INSOO32 //float4 tex_coord = mul(modelViewInv, IN.TexCoord) + float4(0.5, 0.5, 0.5, 0.5);33 31 float4 tex_coord = mul(modelViewInv, IN.TexCoord); 34 32 float4 twice_cell_size = cellSize * 2.0; … … 43 41 float4 voxel_face_center_c = f4tex3D(volumeA, tex_coord_c) + f4tex3D(volumeB, tex_coord_c - cellSize); 44 42 45 46 43 //combine 8 sampling results 47 44 float sample = (voxel_corner.x + voxel_face_center_a.y + voxel_face_center_b.z + voxel_face_center_c.w) * 0.125;
Note: See TracChangeset
for help on using the changeset viewer.