- Timestamp:
- Mar 12, 2012, 10:31:30 AM (13 years ago)
- Location:
- trunk/packages/vizservers/nanovis
- Files:
-
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/Axis.cpp
r2808 r2844 5 5 #include <float.h> 6 6 #include <string.h> 7 7 8 #include "Axis.h" 8 9 -
trunk/packages/vizservers/nanovis/AxisRange.h
r2822 r2844 5 5 #include <string.h> 6 6 7 class AxisRange { 8 double min_, max_; 9 char *units_; 7 class AxisRange 8 { 10 9 public: 11 AxisRange(void) { 12 min(0.0); 13 max(1.0); 14 units_ = NULL; 10 AxisRange() : 11 _min(0.0), 12 _max(1.0), 13 _units(NULL) 14 { 15 15 } 16 ~AxisRange(void) { 17 if (units_ != NULL) { 18 delete [] units_; 19 } 16 17 ~AxisRange() 18 { 19 if (_units != NULL) { 20 delete [] _units; 21 } 20 22 } 21 void SetRange(double min, double max) { 22 min_ = min, max_ = max; 23 24 void SetRange(double min, double max) 25 { 26 _min = min; 27 _max = max; 23 28 } 24 double min(void) { 25 return min_; 29 30 double min() const 31 { 32 return _min; 26 33 } 27 void min(double min) { 28 min_ = min; 34 35 void min(double min) 36 { 37 _min = min; 29 38 } 30 double max(void) { 31 return max_; 39 40 double max() const 41 { 42 return _max; 32 43 } 33 void max(double max) { 34 max_ = max; 44 45 void max(double max) 46 { 47 _max = max; 35 48 } 36 const char *units(void) { 37 return units_; 49 50 const char *units() const 51 { 52 return _units; 38 53 } 39 void units(const char *units) { 40 if (units_ != NULL) { 41 delete [] units_; 42 } 43 if (units == NULL) { 44 units_ = NULL; 45 } else { 46 units_ = new char [strlen(units) + 1]; 47 strcpy(units_, units); 48 } 54 55 void units(const char *units) 56 { 57 if (_units != NULL) { 58 delete [] _units; 59 } 60 if (units == NULL) { 61 _units = NULL; 62 } else { 63 _units = new char[strlen(units) + 1]; 64 strcpy(_units, units); 65 } 49 66 } 67 68 private: 69 double _min, _max; 70 char *_units; 50 71 }; 51 72 -
trunk/packages/vizservers/nanovis/Color.cpp
r2798 r2844 14 14 * ====================================================================== 15 15 */ 16 17 16 #include <stdio.h> 18 17 #include <assert.h> … … 21 20 #include "define.h" 22 21 23 Color::Color() { 24 R=G=B=0.0; 25 next=0; 22 Color::Color() : 23 _r(0), 24 _g(0), 25 _b(0) 26 { 26 27 } 27 28 28 Color::Color(double r, double g, double b) {29 R=r; 30 G=g; 31 B=b; 32 next=0; 29 Color::Color(double r, double g, double b) : 30 _r(r), 31 _g(g), 32 _b(b) 33 { 33 34 } 34 35 35 Color::Color(const Color& c) 36 : R(c.R), G(c.G), B(c.B), next(c.next) 36 Color::Color(const Color& c) : 37 _r(c._r), 38 _g(c._g), 39 _b(c._b) 40 { 41 } 42 43 Color::~Color() 37 44 { 38 45 } … … 41 48 Color::operator=(const Color& c) 42 49 { 43 R = c.R; 44 G = c.G; 45 B = c.B; 46 next = c.next; 50 _r = c._r; 51 _g = c._g; 52 _b = c._b; 47 53 return *this; 48 54 } 49 55 50 void Color::LimitColors(){ //Limits the color to be in range of 0.0 and 1.0 51 if (R>1.0) R=1.0; 52 if (G>1.0) G=1.0; 53 if (B>1.0) B=1.0; 56 // Limits the color to be in range of [0,1] 57 void Color::clamp() 58 { 59 if (_r > 1.0) _r = 1.0; 60 if (_g > 1.0) _g = 1.0; 61 if (_b > 1.0) _b = 1.0; 54 62 55 if (R<0.0) R=0.0;56 if (G<0.0) G=0.0;57 if (B<0.0) B=0.0;63 if (_r < 0.0) _r = 0.0; 64 if (_g < 0.0) _g = 0.0; 65 if (_b < 0.0) _b = 0.0; 58 66 } 59 67 60 Color Color::operator*(double k){ 61 return Color(R*k, G*k, B*k); 68 Color Color::operator*(double k) const 69 { 70 return Color(_r * k, _g * k, _b * k); 62 71 } 63 72 64 65 //This is NOT member operator. It's used so we can write (k*V), not only (V*k) (V-vector k-scalar) 66 Color operator*(double k, Color &other){ 67 return Color(other.R*k, other.G*k, other.B*k); 73 Color Color::operator*(const Color& other) const 74 { 75 return Color(_r * other._r, _g * other._g, _b * other._b); 68 76 } 69 77 70 Color::~Color(){} 71 72 Color Color::operator +(Color &other){ 73 return Color(this->R+other.R,this->G+other.G,this->B+other.B); 78 Color Color::operator+(const Color& other) const 79 { 80 return Color(_r + other._r, _g + other._g, _b + other._b); 74 81 } 75 82 76 Color Color::operator *(Color &other){ 77 return Color(this->R*other.R,this->G*other.G,this->B*other.B); 83 void Color::getRGB(unsigned char *result) 84 { 85 result[0] = (unsigned char)(_r*255.0); 86 result[1] = (unsigned char)(_g*255.0); 87 result[2] = (unsigned char)(_b*255.0); 78 88 } 79 89 80 void Color::GetRGBA(double opacity, unsigned char *result){ 81 LimitColors(); 82 83 assert(opacity>=0 && opacity <=1); 84 85 result[0] = (unsigned char) (R*255.0); 86 result[1] = (unsigned char) (G*255.0); 87 result[2] = (unsigned char) (B*255.0); 88 result[3] = (unsigned char) (opacity*255.0); 90 void Color::getRGB(float *result) 91 { 92 result[0] = (float)_r; 93 result[1] = (float)_g; 94 result[2] = (float)_b; 89 95 } 90 91 void Color::SetRGBA(unsigned char *color){92 R = color[0];93 G = color[1];94 B = color[2];95 }96 97 void Color::GetRGB(unsigned char *result){98 result[0] = (unsigned char) (R*255.0);99 result[1] = (unsigned char) (G*255.0);100 result[2] = (unsigned char) (B*255.0);101 }102 103 void Color::GetRGB(float *result){104 result[0] = (float) (R);105 result[1] = (float) (G);106 result[2] = (float) (B);107 }108 -
trunk/packages/vizservers/nanovis/Color.h
r2798 r2844 14 14 * ====================================================================== 15 15 */ 16 17 #ifndef _COLOR_H_ 18 #define _COLOR_H_ 16 #ifndef COLOR_H 17 #define COLOR_H 19 18 20 19 class Color 21 20 { 22 21 public: 23 double R; // Red component 24 double G; // Green component 25 double B; // Blue component 22 Color(); 26 23 27 void GetRGB(unsigned char *result); 28 void GetRGB(float *result); 24 Color(double r, double g, double b); 29 25 30 void SetRGBA(unsigned char *color); 31 void GetRGBA(double opacity, unsigned char *result); 32 Color operator *(Color &other); 33 Color* next; //pointer to the next color 26 ~Color(); 34 27 35 Color(); 36 Color(double r, double g, double b); 37 Color(const Color& c); 38 Color& operator=(const Color& c); 39 ~Color(); 28 Color(const Color& c); 40 29 41 void LimitColors(); //Limits the color to be in range of 0.0 and 1.0 42 Color operator*(double k); 43 friend Color operator*(double k, Color &other); 44 Color operator+(Color &other); 30 Color& operator=(const Color& c); 31 32 void getRGB(unsigned char *result); 33 34 void getRGB(float *result); 35 36 /// Limits the color to be in range of [0,1] 37 void clamp(); 38 39 Color operator*(const Color& other) const; 40 41 Color operator*(double k) const; 42 43 Color operator+(const Color& other) const; 44 45 friend Color operator*(double k, const Color& other); 46 47 private: 48 double _r; ///< Red component 49 double _g; ///< Green component 50 double _b; ///< Blue component 45 51 }; 46 52 53 // This is NOT member operator. It's used so we can write (k*V), 54 // not only (V*k) (V-vector k-scalar) 55 inline Color operator*(double k, const Color& c) 56 { 57 return Color(c._r * k, c._g * k, c._b * k); 58 } 59 47 60 #endif -
trunk/packages/vizservers/nanovis/FlowCmd.h
r2831 r2844 49 49 50 50 struct FlowParticlesValues { 51 FlowPosition position; /* Position on axis of particle 52 * plane */ 53 FlowColor color; /* Color of particles */ 54 int isHidden; /* Indicates if particle injection 55 * plane is active or not. */ 56 float particleSize; /* Size of the particles. */ 51 FlowPosition position; ///< Position on axis of particle plane 52 FlowColor color; ///< Color of particles 53 /// Indicates if particle injection plane is active or not 54 int isHidden; 55 float particleSize; ///< Size of the particles 57 56 }; 58 57 … … 125 124 126 125 private: 127 const char *_name; /* Name of particle injection 128 * plane. Actual character string is 129 * stored in hash table. */ 126 /** 127 * Name of particle injection plane. Actual character string is 128 * stored in hash table. 129 */ 130 const char *_name; 130 131 Tcl_HashEntry *_hashPtr; 131 NvParticleRenderer *_rendererPtr; / * Particle renderer. */132 NvParticleRenderer *_rendererPtr; ///< Particle renderer 132 133 FlowParticlesValues _sv; 133 134 … … 141 142 142 143 struct FlowBoxValues { 143 float position; /* Position on axis of particle 144 * plane */ 145 FlowPoint corner1, corner2; /* Coordinates of the box. */ 146 147 FlowColor color; /* Color of particles */ 144 float position; ///< Position on axis of particle plane 145 FlowPoint corner1, corner2; ///< Coordinates of the box. 146 FlowColor color; ///< Color of particles 148 147 float lineWidth; 149 int isHidden; /* Indicates if particle injection150 * plance is active or not. */ 148 /// Indicates if particle injection plane is active or not 149 int isHidden; 151 150 }; 152 151 … … 391 390 Tcl_Interp *_interp; 392 391 Tcl_HashEntry *_hashPtr; 393 const char *_name; /* Name of the flow. This may differ 394 * from the name of the command 395 * associated with the flow, if the 396 * command was renamed. */ 397 Tcl_Command _cmdToken; /* Command associated with the flow. 398 * When the command is deleted, so is 399 * the flow. */ 400 Rappture::Unirect3d *_dataPtr; /* Uniform rectangular data 401 * representing the mesh and vector 402 * field values. These values are 403 * kept to regenerate the volume 404 * associated with the flow. */ 405 Volume *_volPtr; /* The volume associated with the 406 * flow. This isn't the same thing as 407 * a normal volume displayed. */ 408 409 NvVectorField *_fieldPtr; /* Vector field generated from the 410 * above volume. */ 411 412 Tcl_HashTable _particlesTable; /* For each field there can be one or 413 * more particle injection planes 414 * where the particles are injected 415 * into the flow. */ 416 417 Tcl_HashTable _boxTable; /* A table of boxes. There maybe 418 * zero or more boxes associated 419 * with each field. */ 392 /** 393 * Name of the flow. This may differ 394 * from the name of the command 395 * associated with the flow, if the 396 * command was renamed. */ 397 const char *_name; 398 399 /** 400 * Command associated with the flow. 401 * When the command is deleted, so is 402 * the flow. */ 403 Tcl_Command _cmdToken; 404 405 /** 406 * Uniform rectangular data 407 * representing the mesh and vector 408 * field values. These values are 409 * kept to regenerate the volume 410 * associated with the flow. */ 411 Rappture::Unirect3d *_dataPtr; 412 413 /** 414 * The volume associated with the 415 * flow. This isn't the same thing as 416 * a normal volume displayed. */ 417 Volume *_volPtr; 418 419 /** 420 * Vector field generated from the 421 * above volume */ 422 NvVectorField *_fieldPtr; 423 424 /** 425 * For each field there can be one or 426 * more particle injection planes 427 * where the particles are injected 428 * into the flow. */ 429 Tcl_HashTable _particlesTable; 430 431 /** 432 * A table of boxes. There maybe 433 * zero or more boxes associated 434 * with each field. */ 435 Tcl_HashTable _boxTable; 436 437 FlowValues _sv; 420 438 421 439 static Rappture::SwitchSpec _switches[]; 422 FlowValues _sv;423 440 }; 424 441 -
trunk/packages/vizservers/nanovis/GradientFilter.cpp
r2813 r2844 6 6 #include <string.h> 7 7 #include <stdio.h> 8 8 9 #include "Trace.h" 9 10 #include "GradientFilter.h" … … 14 15 15 16 #define GRADIENTS_EXT ".grd" 16 int g_numOfSlices[3] = { 256, 256, 256 };17 void*g_volData = 0;18 float g_sliceDists[3];17 static int g_numOfSlices[3] = { 256, 256, 256 }; 18 static void *g_volData = 0; 19 static float g_sliceDists[3]; 19 20 20 21 #define SOBEL 1 … … 287 288 } 288 289 } 289 290 290 } 291 291 -
trunk/packages/vizservers/nanovis/GradientFilter.h
r2798 r2844 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef _GRADIENT_FILTER_H3 #define _GRADIENT_FILTER_H2 #ifndef GRADIENT_FILTER_H 3 #define GRADIENT_FILTER_H 4 4 5 typedef enum {DATRAW_UCHAR, DATRAW_FLOAT, DATRAW_USHORT} DataType; 5 typedef enum { 6 DATRAW_UCHAR, 7 DATRAW_FLOAT, 8 DATRAW_USHORT 9 } DataType; 6 10 7 extern void computeGradients(float *gradients, void* volData, int *sizes, DataType dataType); 11 extern void computeGradients(float *gradients, void *volData, int *sizes, DataType dataType); 12 8 13 extern void filterGradients(float *gradients, int *sizes); 14 9 15 extern void quantizeGradients(float *gradientsIn, void *gradientsOut, 10 16 int *sizes, DataType dataType); 11 17 12 #endif /*_GRADIENT_FILTER_H*/18 #endif -
trunk/packages/vizservers/nanovis/Grid.cpp
r2798 r2844 9 9 #define GRID_TICK 0.05 10 10 11 Grid::Grid() : 11 Grid::Grid() : 12 xAxis("X"), 13 yAxis("Y"), 14 zAxis("Z"), 12 15 _axisColor(1.0f, 1.0f, 1.0f, 1.0f), 13 16 _majorColor(1.0f, 1.0f, 1.0f, 1.0f), 14 17 _minorColor(0.5f, 0.5f, 0.5f, 1.0f), 15 18 _font(0), 16 _visible(false), 17 xAxis("X"), 18 yAxis("Y"), 19 zAxis("Z") 19 _visible(false) 20 20 { 21 /*empty*/22 21 } 23 22 -
trunk/packages/vizservers/nanovis/Grid.h
r2798 r2844 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef _GRID_H_3 #define _GRID_H_2 #ifndef GRID_H 3 #define GRID_H 4 4 5 5 #include <R2/R2Fonts.h> 6 6 7 #include "Axis.h" 7 8 #include "AxisRange.h" 8 9 9 class RGBA { 10 class RGBA 11 { 10 12 public: 13 RGBA(float r, float g, float b, float a) : 14 red(r), 15 green(g), 16 blue(b), 17 alpha(a) 18 {} 19 20 void SetColor(float r, float g, float b, float a) 21 { 22 red = r; 23 green = g; 24 blue = b; 25 alpha = a; 26 } 27 11 28 float red, green, blue, alpha; 12 RGBA(float r, float g, float b, float a) :13 red(r), green(g), blue(b), alpha(a)14 { /*empty*/ }15 void SetColor(float r, float g, float b, float a) {16 red = r;17 green = g;18 blue = b;19 alpha = a;20 }21 29 }; 22 30 23 class Grid {24 RGBA _axisColor, _majorColor, _minorColor; 25 R2Fonts* _font; 26 bool _visible;31 class Grid 32 { 33 public: 34 Grid(); 27 35 28 public : 36 bool isVisible() const 37 { 38 return _visible; 39 } 40 41 void setVisible(bool visible) 42 { 43 _visible = visible; 44 } 45 46 void setAxisColor(float r, float g, float b, float a) 47 { 48 _axisColor.SetColor(r, g, b, a); 49 } 50 51 void setLineColor(float r, float g, float b, float a) 52 { 53 _majorColor.SetColor(r, g, b, a); 54 _minorColor = _majorColor; 55 } 56 57 void render(); 58 59 void setFont(R2Fonts *font); 60 29 61 Axis xAxis; 30 62 Axis yAxis; 31 63 Axis zAxis; 32 64 33 Grid(); 34 bool isVisible() const { 35 return _visible; 36 } 37 void setVisible(bool visible) { 38 _visible = visible; 39 } 40 void setAxisColor(float r, float g, float b, float a) { 41 _axisColor.SetColor(r, g, b, a); 42 } 43 void setLineColor(float r, float g, float b, float a) { 44 _majorColor.SetColor(r, g, b, a); 45 _minorColor = _majorColor; 46 } 47 void render(); 48 void setFont(R2Fonts* font); 65 private: 66 RGBA _axisColor, _majorColor, _minorColor; 67 R2Fonts *_font; 68 bool _visible; 49 69 }; 50 70 -
trunk/packages/vizservers/nanovis/HeightMap.cpp
r2827 r2844 7 7 #include <fcntl.h> 8 8 #include <stdlib.h> 9 9 10 #include <GL/glew.h> 10 11 #include <GL/gl.h> 12 11 13 #include "Grid.h" 12 14 #include "HeightMap.h" … … 532 534 glTranslatef(0.0, 0.0, -10.0); 533 535 534 // put camera rotation and tra slation536 // put camera rotation and translation 535 537 //glScalef(1 / _scale.x, 1 / _scale.y , 1 / _scale.z); 536 538 … … 647 649 glPopAttrib(); 648 650 } 649 -
trunk/packages/vizservers/nanovis/NvParticleRenderer.h
r2837 r2844 14 14 * ====================================================================== 15 15 */ 16 #ifndef NV _PARTICLE_SYSTEM_H17 #define NV _PARTICLE_SYSTEM_H16 #ifndef NVPARTICLERENDERER_H 17 #define NVPARTICLERENDERER_H 18 18 19 19 #include <vector> -
trunk/packages/vizservers/nanovis/NvStdVertexShader.cpp
r2798 r2844 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 2 #include <stdio.h> 3 3 4 #include "global.h" 4 5 #include "NvStdVertexShader.h" … … 16 17 { 17 18 _cgVP = LoadCgSourceProgram(g_context, "vertex_std.cg", CG_PROFILE_VP30, 18 19 "main"); 19 20 _mvp_vert_std_param = cgGetNamedParameter(_cgVP, "modelViewProjMatrix"); 20 21 _mvi_vert_std_param = cgGetNamedParameter(_cgVP, "modelViewInv"); 21 22 } 22 -
trunk/packages/vizservers/nanovis/NvStdVertexShader.h
r2798 r2844 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __NV_STD_VERTEX_SHADER_H__3 #define __NV_STD_VERTEX_SHADER_H__2 #ifndef NV_STD_VERTEX_SHADER_H 3 #define NV_STD_VERTEX_SHADER_H 4 4 5 5 #include "NvShader.h" 6 6 7 class NvStdVertexShader : public NvShader { 8 /** 9 * @brief A parameter id for ModelViewProjection matrix of Cg program 10 */ 7 class NvStdVertexShader : public NvShader 8 { 9 public: 10 NvStdVertexShader(); 11 12 ~NvStdVertexShader(); 13 14 void bind(); 15 void unbind(); 16 17 private: 18 void init(); 19 20 /// A parameter id for ModelViewProjection matrix of Cg program 11 21 CGparameter _mvp_vert_std_param; 12 22 13 /** 14 * @brief A parameter id for ModelViewInverse matrix of Cg program 15 */ 23 /// A parameter id for ModelViewInverse matrix of Cg program 16 24 CGparameter _mvi_vert_std_param; 17 18 public :19 /**20 * @brief Constructor21 */22 NvStdVertexShader();23 24 /**25 * @brief Destructor26 */27 ~NvStdVertexShader();28 private :29 void init();30 31 public :32 void bind();33 void unbind();34 25 }; 35 26 … … 40 31 cgGLBindProgram(_cgVP); 41 32 cgGLEnableProfile(CG_PROFILE_VP30); 42 43 33 } 44 34 -
trunk/packages/vizservers/nanovis/NvVolumeShader.h
r2798 r2844 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __NV_VOLUME_SHADER_H__3 #define __NV_VOLUME_SHADER_H__2 #ifndef NV_VOLUME_SHADER_H 3 #define NV_VOLUME_SHADER_H 4 4 5 #include <Cg/cg.h>6 #include <Cg/cgGL.h>7 5 #include "NvShader.h" 8 6 9 7 class Volume; 10 8 11 class NvVolumeShader : public NvShader { 12 protected : 13 NvVolumeShader(); 14 9 class NvVolumeShader : public NvShader 10 { 15 11 public : 16 12 virtual ~NvVolumeShader(); 17 13 18 public : 19 virtual void bind(unsigned int tfID, Volume* volume, int sliceMode) = 0; 14 virtual void bind(unsigned int tfID, Volume *volume, int sliceMode) = 0; 15 20 16 virtual void unbind() = 0; 17 18 protected : 19 NvVolumeShader(); 21 20 }; 22 21 -
trunk/packages/vizservers/nanovis/NvZincBlendeReconstructor.cpp
r2822 r2844 3 3 #include <string.h> 4 4 #include <stdlib.h> 5 5 6 #include "NvZincBlendeReconstructor.h" 6 7 #include "ZincBlendeVolume.h" … … 149 150 { 150 151 // NOTE 151 // Zinc blende data has different ax ises from OpenGL152 // Zinc blende data has different axes from OpenGL 152 153 // + z -> +x (OpenGL) 153 154 // + x -> +y (OpenGL) 154 155 // + y -> +z (OpenGL), But in 3D texture coordinate is the opposite direction of z 155 // The reason e why index is multiplied by 4 is that one unit cell has half of eight atoms156 // ,i.e. four atoms are mapped into RGBA component of one texel156 // The reason why index is multiplied by 4 is that one unit cell has half of eight atoms, 157 // i.e. four atoms are mapped into RGBA component of one texel 157 158 //return ((int) (indexZ - 1)+ (int) (indexX - 1) * width + (int) (indexY - 1) * width * height) * 4; 158 159 return ((int)(indexX - 1) + (int)(indexY - 1) * width + (int)(indexZ - 1) * width * height) * 4; … … 194 195 ZincBlendeVolume * 195 196 NvZincBlendeReconstructor::buildUp(const Vector3& origin, const Vector3& delta, 196 int width, int height, int depth, void *data)197 int width, int height, int depth, void *data) 197 198 { 198 199 ZincBlendeVolume *zincBlendeVolume = NULL; -
trunk/packages/vizservers/nanovis/NvZincBlendeReconstructor.h
r2822 r2844 28 28 class NvZincBlendeReconstructor 29 29 { 30 char buff[255];31 32 /**33 * @brief A ZincBlendeReconstructor Singleton instance34 */35 static NvZincBlendeReconstructor* _instance;36 private:37 /**38 * @brief Constructor39 */40 NvZincBlendeReconstructor();41 42 /**43 * @brief Destructor44 */45 ~NvZincBlendeReconstructor();46 47 public:48 /**49 * @brief Return a singleton instance50 */51 static NvZincBlendeReconstructor* getInstance();52 53 private:54 /**55 * @brief Get a line from file. It is used for reading header because header is written in ascii.56 * @param fp A file pointer of data file57 */58 void getLine(std::istream& stream);59 void getLine(unsigned char*& stream);60 61 30 public: 62 31 /** … … 64 33 * @param fileName Zinc blende file name, which data is generated by NEMO-3D 65 34 */ 66 ZincBlendeVolume *loadFromFile(const char *fileName);35 ZincBlendeVolume *loadFromFile(const char *fileName); 67 36 68 37 /** … … 71 40 */ 72 41 ZincBlendeVolume *loadFromStream(std::istream& stream); 42 73 43 ZincBlendeVolume *loadFromMemory(void *dataBlock); 74 44 … … 84 54 ZincBlendeVolume *buildUp(const Vector3& origin, const Vector3& delta, 85 55 int width, int height, int depth, void *data); 56 86 57 ZincBlendeVolume *buildUp(const Vector3& origin, const Vector3& delta, 87 58 int width, int height, int depth, 88 59 int datacount, double emptyvalue, void *data); 60 61 /** 62 * @brief Return a singleton instance 63 */ 64 static NvZincBlendeReconstructor* getInstance(); 65 66 private: 67 NvZincBlendeReconstructor(); 68 69 ~NvZincBlendeReconstructor(); 70 71 /** 72 * @brief Get a line from file. It is used for reading header because header is written in ascii. 73 * @param fp A file pointer of data file 74 */ 75 void getLine(std::istream& stream); 76 void getLine(unsigned char*& stream); 77 78 char buff[255]; 79 80 /// A ZincBlendeReconstructor Singleton instance 81 static NvZincBlendeReconstructor* _instance; 89 82 }; 90 83 -
trunk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.h
r2822 r2844 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __NV_ZINCBLENDE_SHADER_H__3 #define __NV_ZINCBLENDE_SHADER_H__2 #ifndef NV_ZINCBLENDE_SHADER_H 3 #define NV_ZINCBLENDE_SHADER_H 4 4 5 5 #include "ZincBlendeVolume.h" 6 6 #include "NvVolumeShader.h" 7 7 8 class NvZincBlendeVolumeShader : public NvVolumeShader { 8 class NvZincBlendeVolumeShader : public NvVolumeShader 9 { 10 public : 11 NvZincBlendeVolumeShader(); 12 13 ~NvZincBlendeVolumeShader(); 14 15 void bind(unsigned int tfID, Volume *volume, int sliceMode); 16 17 void unbind(); 18 19 private : 20 void init(); 21 9 22 CGparameter _tfParam; 10 23 CGparameter _volumeAParam; … … 14 27 CGparameter _renderParam; 15 28 CGparameter _option_one_volume_param; 16 17 private :18 void init();19 public :20 NvZincBlendeVolumeShader();21 ~NvZincBlendeVolumeShader();22 23 void bind(unsigned int tfID, Volume* volume, int sliceMode);24 void unbind();25 29 }; 26 30 27 inline void NvZincBlendeVolumeShader::bind(unsigned int tfID, Volume *volume, int sliceMode)31 inline void NvZincBlendeVolumeShader::bind(unsigned int tfID, Volume *volume, int sliceMode) 28 32 { 29 ZincBlendeVolume * vol = (ZincBlendeVolume*)volume;33 ZincBlendeVolume *vol = (ZincBlendeVolume *)volume; 30 34 cgGLSetStateMatrixParameter(_mviParam, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_INVERSE); 31 35 cgGLSetTextureParameter(_tfParam, tfID); 32 36 cgGLSetParameter4f(_cellSizeParam, vol->cell_size.x, vol->cell_size.y, vol->cell_size.z, 0.); 33 37 34 if (!sliceMode)38 if (!sliceMode) { 35 39 cgGLSetParameter4f(_renderParam, 36 vol->n_slices(),37 vol->opacity_scale(),38 vol->diffuse(),39 vol->specular());40 else40 vol->n_slices(), 41 vol->opacity_scale(), 42 vol->diffuse(), 43 vol->specular()); 44 } else { 41 45 cgGLSetParameter4f(_renderParam, 42 0., 43 vol->opacity_scale(), 44 vol->diffuse(), 45 vol->specular()); 46 0., 47 vol->opacity_scale(), 48 vol->diffuse(), 49 vol->specular()); 50 } 46 51 47 52 cgGLSetParameter4f(_option_one_volume_param, 48 49 50 51 53 0.0f, 54 volume->isosurface(), 55 0.0f, 56 0.0f); 52 57 53 cgGLSetTextureParameter(_volumeAParam, 58 cgGLSetTextureParameter(_volumeAParam, vol->zincblende_tex[0]->id); 54 59 cgGLSetTextureParameter(_volumeBParam, vol->zincblende_tex[1]->id); 55 60 cgGLEnableTextureParameter(_volumeAParam); -
trunk/packages/vizservers/nanovis/PCASplit.cpp
r2832 r2844 111 111 finalSize = sqrt (finalSize) + maxSize; 112 112 } 113 114 void 113 114 void 115 115 PCASplit::init() 116 116 { 117 _curClusterNode = 0;117 _curClusterNode = NULL; 118 118 _curClusterCount = 0; 119 119 } 120 120 121 Cluster * 121 Cluster * 122 122 PCASplit::createClusterBlock(ClusterListNode *clusterList, int count, int level) 123 123 { … … 179 179 ClusterListNode *clustNodeList = &(_memClusterChunk2[0]); 180 180 clustNodeList->data = cluster_t; 181 clustNodeList->next = 0;181 clustNodeList->next = NULL; 182 182 183 183 _curRoot = root; … … 189 189 190 190 // swap memory buffer & init 191 _curMemClusterChunk = (_curMemClusterChunk == _memClusterChunk1) ?191 _curMemClusterChunk = (_curMemClusterChunk == _memClusterChunk1) ? 192 192 _memClusterChunk2 : _memClusterChunk1; 193 193 _memClusterChunkIndex = 0; … … 233 233 computeCovariant(data, count, mean, m); 234 234 235 // Begin newmat11 dependency 236 235 237 SymmetricMatrix A(3); 236 238 for (int i = 1; i <= 3; ++i) { … … 242 244 Matrix U; 243 245 DiagonalMatrix D; 244 eigenvalues(A, D,U);246 eigenvalues(A, D ,U); 245 247 Vector3 emax(U(1, 3), U(2, 3), U(3, 3)); 248 249 // End newmat11 dependency 246 250 247 251 int left = 0, right = count - 1; … … 370 374 } 371 375 } 372 -
trunk/packages/vizservers/nanovis/PCASplit.h
r2832 r2844 19 19 20 20 Vector3 position; 21 // histogram Index;22 //unsigned char color;23 21 Vector4 color; 24 22 float size; … … 30 28 public: 31 29 Cluster() : 32 color(1.0f, 1.0f, 1.0f, 1.0f), 33 scale(0.0f), 34 numOfChildren(0), 30 centroid(0.0f, 0.0f, 0.0f), 31 color(1.0f, 1.0f, 1.0f, 1.0f), 32 scale(0.0f), 33 numOfChildren(0), 35 34 numOfPoints(0), 36 points( 0),37 children( 0),38 vbo(0) /*, minValue(0.0f), maxValue(0.0f)*/39 ,level(0)35 points(NULL), 36 children(NULL), 37 vbo(0), 38 level(0) 40 39 { 41 40 } … … 46 45 numOfChildren = count; 47 46 } 47 48 48 void setPoints(Point *points, int count) 49 49 { … … 67 67 { 68 68 public: 69 ClusterAccel(int maxlevel) 70 : root(0),71 69 ClusterAccel(int maxlevel) : 70 root(NULL), 71 maxLevel(maxlevel) 72 72 { 73 73 startPointerCluster = new Cluster *[maxLevel]; 74 74 numOfClusters = new int[maxLevel]; 75 _vbo = new unsigned int[maxLevel];76 memset( _vbo, 0, sizeof(unsigned int) * maxLevel);75 vbo = new unsigned int[maxLevel]; 76 memset(vbo, 0, sizeof(unsigned int) * maxLevel); 77 77 } 78 78 … … 81 81 Cluster **startPointerCluster; 82 82 int *numOfClusters; 83 unsigned int * _vbo;83 unsigned int *vbo; 84 84 }; 85 85 -
trunk/packages/vizservers/nanovis/PointSet.cpp
r2814 r2844 6 6 7 7 void 8 PointSet::initialize(Vector4 *values, const unsigned int count,8 PointSet::initialize(Vector4 *values, const unsigned int count, 9 9 const Vector3& scale, const Vector3& origin, 10 10 float min, float max) … … 17 17 _max = max; 18 18 19 PCA::Point * points = (PCA::Point*)malloc(sizeof(PCA::Point) * count);19 PCA::Point *points = (PCA::Point *)malloc(sizeof(PCA::Point) * count); 20 20 for (unsigned int i = 0; i < count; ++i) { 21 21 points[i].position.set(values[i].x, values[i].y, values[i].z); … … 34 34 35 35 void 36 PointSet::updateColor(float * color,int colorCount)36 PointSet::updateColor(float *color, int colorCount) 37 37 { 38 38 if (_cluster == 0) { … … 41 41 int level = 4; 42 42 43 PCA::Cluster *cluster = _cluster->startPointerCluster[level - 1];44 PCA::Cluster *c = &(cluster[0]);45 PCA::Cluster *end = &(cluster[_cluster->numOfClusters[level - 1] - 1]);46 43 PCA::Cluster *cluster = _cluster->startPointerCluster[level - 1]; 44 PCA::Cluster *c = &(cluster[0]); 45 PCA::Cluster *end = &(cluster[_cluster->numOfClusters[level - 1] - 1]); 46 47 47 Vector3 pos; 48 49 PCA::Point *points;50 Vector4 * colors = (Vector4*)color;48 49 PCA::Point *points; 50 Vector4 *colors = (Vector4 *)color; 51 51 int numOfPoints; 52 52 int index; 53 53 float d = _max - _min; 54 for (; c <= end; c = (PCA::Cluster *)((char *)c+sizeof(PCA::Cluster))){54 for (; c <= end; c = (PCA::Cluster *)((char *)c + sizeof(PCA::Cluster))) { 55 55 points = c->points; 56 56 numOfPoints = c->numOfPoints; -
trunk/packages/vizservers/nanovis/PointSet.h
r2831 r2844 29 29 float min, float max); 30 30 31 void updateColor(float *color, int 31 void updateColor(float *color, int count); 32 32 33 33 bool isVisible() const … … 73 73 private: 74 74 unsigned int _sortLevel; 75 PCA::ClusterAccel *_cluster;75 PCA::ClusterAccel *_cluster; 76 76 77 77 Vector3 _scale; -
trunk/packages/vizservers/nanovis/PointSetRenderer.h
r2831 r2844 29 29 30 30 #endif 31 -
trunk/packages/vizservers/nanovis/Renderable.cpp
r2837 r2844 21 21 22 22 Renderable::Renderable(const Vector3& loc) : 23 location(loc),24 enabled(true)23 _location(loc), 24 _enabled(true) 25 25 { 26 26 } … … 31 31 void Renderable::move(const Vector3& new_loc) 32 32 { 33 location = new_loc;33 _location = new_loc; 34 34 } 35 35 36 36 void Renderable::enable() 37 37 { 38 enabled = true;38 _enabled = true; 39 39 } 40 40 41 41 void Renderable::disable() 42 42 { 43 enabled = false;43 _enabled = false; 44 44 } 45 45 46 46 bool Renderable::is_enabled() const 47 47 { 48 return enabled;48 return _enabled; 49 49 } 50 50 -
trunk/packages/vizservers/nanovis/Renderable.h
r2837 r2844 20 20 21 21 struct BoundBox { 22 Vector3 low; //lower coordinates23 Vector3 high; // higher coordinates22 Vector3 low; ///< lower coordinates 23 Vector3 high; ///< higher coordinates 24 24 25 25 BoundBox() … … 53 53 54 54 protected: 55 Vector3 location; //the location (x,y,z) of the object56 bool enabled; //display is enabled57 BoundBox boundary; //the bounding box55 Vector3 _location; ///< the location (x,y,z) of the object 56 bool _enabled; ///< display is enabled 57 BoundBox _boundary; ///< the bounding box 58 58 }; 59 59 -
trunk/packages/vizservers/nanovis/RpDX.cpp
r2798 r2844 15 15 * ====================================================================== 16 16 */ 17 #include <math.h> 18 #include <stdio.h> 19 #include <stdlib.h> 20 #include <float.h> 21 17 22 #include "nvconf.h" 18 23 #ifdef HAVE_DX_DX_H … … 20 25 #undef ERROR 21 26 #include "Trace.h" 22 #include <math.h>23 #include <stdio.h>24 #include <stdlib.h>25 #include <float.h>26 27 27 28 using namespace Rappture; … … 136 137 memset(_max, 0, _numAxis); 137 138 138 __findPosMax();139 findPosMax(); 139 140 140 141 // parse out the gridconnections (length of each axis) array … … 186 187 _positions[pt+6],_positions[pt+7],_positions[pt+8],_data[lcv+2]); 187 188 } 188 __collectDataStats();189 collectDataStats(); 189 190 } 190 191 … … 200 201 201 202 void 202 DX:: __findPosMax()203 DX::findPosMax() 203 204 { 204 205 int lcv = 0; … … 219 220 220 221 void 221 DX:: __collectDataStats()222 DX::collectDataStats() 222 223 { 223 224 _dataMin = FLT_MAX; … … 251 252 */ 252 253 void 253 DX:: __getInterpPos()254 DX::getInterpPos() 254 255 { 255 256 Array dxpos; … … 286 287 */ 287 288 void 288 DX:: __getInterpData()289 DX::getInterpData() 289 290 { 290 291 int pts = _n; … … 317 318 } 318 319 319 __collectDataStats();320 collectDataStats(); 320 321 } 321 322 … … 337 338 } 338 339 } 339 __getInterpPos();340 __getInterpData();340 getInterpPos(); 341 getInterpData(); 341 342 TRACE("----end interpolation----\n"); 342 343 return *this; -
trunk/packages/vizservers/nanovis/RpDX.h
r2818 r2844 19 19 20 20 #include <dx/dx.h> 21 21 22 #include <RpOutcome.h> 22 23 23 24 namespace Rappture { 24 25 25 class DX { 26 class DX 27 { 26 28 public: 27 29 DX(); 28 DX(Rappture::Outcome &result, const char* filename); 30 31 DX(Rappture::Outcome& result, const char *filename); 32 29 33 DX(const DX& rpdx); 34 30 35 DX& operator=(const DX& rpdx); 36 31 37 virtual ~DX(); 32 38 … … 37 43 virtual double valueMax() const; 38 44 */ 39 virtual DX& interpolate(int *newAxisLen);45 virtual DX& interpolate(int *newAxisLen); 40 46 41 int n(void) const { 42 return _n; 43 } 44 int rank(void) const { 45 return _rank; 46 } 47 int shape(void) const { 48 return _shape; 49 } 50 const float* delta(void) const { 51 // FIXME: Delta is always three numbers. 52 return _delta; 53 } 54 const float *max(void) const { 55 return _max; 56 } 57 const float *origin(void) const { 58 return _origin; 59 } 60 const float * positions(void) const { 61 return _positions; 62 } 63 const int *axisLen(void) const { 64 return _axisLen; 65 } 66 const float *data(void) const { 67 return _data; 68 } 69 float dataMin(void) const { 70 return _dataMin; 71 } 72 float dataMax(void) const { 73 return _dataMax; 74 } 75 float nzero_min(void) const { 76 return _nzero_min; 47 int n() const 48 { 49 return _n; 77 50 } 78 51 79 protected: 52 int rank() const 53 { 54 return _rank; 55 } 56 57 int shape() const 58 { 59 return _shape; 60 } 61 62 const float *delta() const 63 { 64 // FIXME: Delta is always three numbers. 65 return _delta; 66 } 67 68 const float *max() const 69 { 70 return _max; 71 } 72 73 const float *origin() const 74 { 75 return _origin; 76 } 77 78 const float * positions() const 79 { 80 return _positions; 81 } 82 83 const int *axisLen() const 84 { 85 return _axisLen; 86 } 87 88 const float *data() const 89 { 90 return _data; 91 } 92 93 float dataMin() const 94 { 95 return _dataMin; 96 } 97 98 float dataMax() const 99 { 100 return _dataMax; 101 } 102 103 float nzero_min() const 104 { 105 return _nzero_min; 106 } 80 107 81 108 private: 109 void findPosMax(); 110 void collectDataStats(); 111 void getInterpPos(); 112 void getInterpData(); 113 82 114 float _dataMin; 83 115 float _dataMax; 84 116 float _nzero_min; 85 int _numAxis; // same as _shape if _rank == 186 int *_axisLen; // number of points on each axis87 float *_data;117 int _numAxis; ///< same as _shape if _rank == 1 118 int *_axisLen; ///< number of points on each axis 119 float *_data; 88 120 89 int _n; // number of points in the position array90 int _rank; // number of dimensions in each item91 int _shape; // array of the extents of each dimension92 float * _positions; //array holding the x,y,z coord of each point93 float * _delta; //array holding deltas of the uniform mesh94 float * _max; //array hodling coord of most distant pt from origin95 float * _origin; //array holding coord of origin121 int _n; ///< number of points in the position array 122 int _rank; ///< number of dimensions in each item 123 int _shape; ///< array of the extents of each dimension 124 float *_positions; ///< array holding the x,y,z coord of each point 125 float *_delta; ///< array holding deltas of the uniform mesh 126 float *_max; ///< array hodling coord of most distant pt from origin 127 float *_origin; ///< array holding coord of origin 96 128 97 129 Object _dxobj; 98 99 void __findPosMax();100 void __collectDataStats();101 void __getInterpPos();102 void __getInterpData();103 104 105 130 }; 106 131 107 } // namespace Rappture132 } 108 133 109 134 #endif -
trunk/packages/vizservers/nanovis/TransferFunction.h
r2831 r2844 74 74 75 75 private: 76 int _size; //the resolution of the color map, how many77 //(RGBA) quadraples 78 float *_data;79 Texture1D * _tex; //the texture storing the colors76 /// the resolution of the color map, how many (RGBA) quadraples 77 int _size; 78 float *_data; 79 Texture1D *_tex; ///< the texture storing the colors 80 80 const char *_name; 81 GLuint _id; //OpenGL'stexture identifier81 GLuint _id; ///< OpenGL texture identifier 82 82 }; 83 83 -
trunk/packages/vizservers/nanovis/Volume.cpp
r2816 r2844 14 14 * ====================================================================== 15 15 */ 16 17 16 #include <memory.h> 18 17 #include <assert.h> 18 19 19 #include "Volume.h" 20 20 #include "Trace.h" … … 26 26 Volume::Volume(float x, float y, float z, 27 27 int w, int h, int d, float s, 28 int n, float* data, double v0, double v1, double nz_min) : 28 int n, float *data, 29 double v0, double v1, double nz_min) : 30 aspect_ratio_width(1), 31 aspect_ratio_height(1), 32 aspect_ratio_depth(1), 33 id(0), 34 width(w), 35 height(h), 36 depth(d), 37 size(s), 38 pointsetIndex(-1), 29 39 _tfPtr(NULL), 30 40 _specular(6.), // default value … … 32 42 _opacity_scale(10.), // default value 33 43 _name(NULL), 44 _data(NULL), 34 45 _n_components(n), 35 46 _nonzero_min(nz_min), 36 _pointsetIndex(-1), 47 _tex(NULL), 48 _location(x, y, z), 37 49 _n_slices(512), // default value 38 50 _enabled(true), 39 //n_slice(256), // default value40 51 _data_enabled(true), // default value 41 52 _outline_enabled(true), // default value 42 _outline_color(1., 1.,1.), // default value53 _outline_color(1., 1., 1.), // default value 43 54 _volume_type(CUBIC), // default is a cubic volume 44 _iso_surface(0), 45 width(w), 46 height(h), 47 depth(d), 48 size(s) 55 _iso_surface(0) 49 56 { 50 57 _tex = new Texture3D(w, h, d, GL_FLOAT, GL_LINEAR, n); … … 71 78 aspect_ratio_depth = s * _tex->aspect_ratio_depth; 72 79 73 _location = Vector3(x, y, z);74 75 80 //Add cut planes. We create 3 default cut planes facing x, y, z directions. 76 81 //The default location of cut plane is in the middle of the data. … … 90 95 Volume::~Volume() 91 96 { 92 if ( _pointsetIndex != -1) {97 if (pointsetIndex != -1) { 93 98 // TBD... 94 99 } 95 100 96 101 delete [] _data; 97 98 102 delete _tex; 99 103 } -
trunk/packages/vizservers/nanovis/Volume.h
r2816 r2844 14 14 * ====================================================================== 15 15 */ 16 17 #ifndef _VOLUME_H_ 18 #define _VOLUME_H_ 16 #ifndef VOLUME_H 17 #define VOLUME_H 19 18 20 19 #include <string> 21 20 #include <vector> 21 22 #include <R2/R2Object.h> 22 23 23 24 #include "define.h" … … 26 27 #include "Vector3.h" 27 28 #include "AxisRange.h" 28 #include "R2/R2Object.h"29 29 #include "TransferFunction.h" 30 30 31 31 struct CutPlane { 32 int orient; // orientation - 1: xy slice, 2: yz slice, 3:33 // xz slice 34 float offset; //normalized offset [0,1] in the volume32 /// orientation - 1: xy slice, 2: yz slice, 3: xz slice 33 int orient; 34 float offset; ///< normalized offset [0,1] in the volume 35 35 bool enabled; 36 36 … … 38 38 orient(_orient), 39 39 offset(_offset), 40 40 enabled(true) 41 41 { 42 42 } … … 47 47 class Volume 48 48 { 49 public: 50 enum VolumeType { 51 CUBIC, 52 VOLQD, 53 ZINCBLENDE 54 }; 55 56 Volume(float x, float y, float z, 57 int width, int height, int depth, 58 float size, int n_component, 59 float *data, 60 double vmin, double vmax, 61 double nonzero_min); 62 63 virtual ~Volume(); 64 65 void visible(bool value) 66 { 67 _enabled = value; 68 } 69 70 bool visible() const 71 { 72 return _enabled; 73 } 74 75 void location(const Vector3& loc) 76 { 77 _location = loc; 78 } 79 80 Vector3 location() const 81 { 82 return _location; 83 } 84 85 int isosurface() const 86 { 87 return _iso_surface; 88 } 89 90 void isosurface(int iso) 91 { 92 _iso_surface = iso; 93 } 94 95 int n_components() const 96 { 97 return _n_components; 98 } 99 100 double nonzero_min() const 101 { 102 return _nonzero_min; 103 } 104 105 double range_nzero_min() const 106 { 107 return _nonzero_min; 108 } 109 110 int volume_type() const 111 { 112 return _volume_type; 113 } 114 115 float *data() 116 { 117 return _data; 118 } 119 120 Texture3D *tex() 121 { 122 return _tex; 123 } 124 125 int n_slices() const 126 { 127 return _n_slices; 128 } 129 130 void n_slices(int n) 131 { 132 _n_slices = n; 133 } 134 135 /// set the drawing size of volume 136 void set_size(float s); 137 138 // methods related to cutplanes 139 /// add a plane and returns its index 140 int add_cutplane(int orientation, float location); 141 142 void enable_cutplane(int index); 143 144 void disable_cutplane(int index); 145 146 void move_cutplane(int index, float location); 147 148 CutPlane *get_cutplane(int index); 149 150 /// returns the number of cutplanes in the volume 151 int get_cutplane_count(); 152 153 /// check if a cutplane is enabled 154 bool cutplane_is_enabled(int index) const; 155 156 // methods related to shading. These parameters are per volume 157 float specular() const 158 { 159 return _specular; 160 } 161 162 void specular(float value) 163 { 164 _specular = value; 165 } 166 167 float diffuse() const 168 { 169 return _diffuse; 170 } 171 172 void diffuse(float value) 173 { 174 _diffuse = value; 175 } 176 177 float opacity_scale() const 178 { 179 return _opacity_scale; 180 } 181 182 void opacity_scale(float value) 183 { 184 _opacity_scale = value; 185 } 186 187 void data_enabled(bool value) 188 { 189 _data_enabled = value; 190 } 191 192 bool data_enabled() const 193 { 194 return _data_enabled; 195 } 196 197 void outline(bool value) 198 { 199 _outline_enabled = value; 200 } 201 202 bool outline() 203 { 204 return _outline_enabled; 205 } 206 207 TransferFunction *transferFunction() 208 { 209 return _tfPtr; 210 } 211 212 void transferFunction(TransferFunction *tfPtr) 213 { 214 _tfPtr = tfPtr; 215 } 216 217 void set_outline_color(float *rgb); 218 219 void get_outline_color(float *rgb); 220 221 /// change the label displayed on an axis 222 void set_label(int axis, const char *txt); 223 224 void setPhysicalBBox(const Vector3& min, const Vector3& max); 225 226 const Vector3& getPhysicalBBoxMin() const; 227 228 const Vector3& getPhysicalBBoxMax() const; 229 230 const char *name() const 231 { 232 return _name; 233 } 234 235 void name(const char *name) 236 { 237 _name = name; 238 } 239 240 float aspect_ratio_width; 241 float aspect_ratio_height; 242 float aspect_ratio_depth; 243 244 GLuint id; ///< OpenGL textue identifier (==_tex->id) 245 246 // Width, height and depth are point resolution, NOT physical 247 // units 248 /// The resolution of the data (how many points in X direction) 249 int width; 250 /// The resolution of the data (how many points in Y direction) 251 int height; 252 /// The resolution of the data (how many points in Z direction) 253 int depth; 254 /** 255 * This is the scaling factor that will size the volume on screen. 256 * A render program drawing different objects, always knows how 257 * large an object is in relation to other objects. This size is 258 * provided by the render engine. 259 */ 260 float size; 261 262 int pointsetIndex; 263 264 AxisRange xAxis, yAxis, zAxis, wAxis; 265 std::string label[3]; ///< the labels along each axis 0:x, 1:y, 2:z 266 267 static bool update_pending; 268 static double valueMin, valueMax; 269 49 270 protected: 50 TransferFunction *_tfPtr; // This is the designated transfer 51 // to use to render this volume. 52 53 float _specular; // Specular lighting parameter 54 float _diffuse; // Diffuse lighting parameter 55 float _opacity_scale; // The scale multiplied to the opacity 56 // assigned by the transfer function. 57 // Rule of thumb: higher opacity_scale 58 // the object is to appear like 59 // plastic 271 /** 272 * This is the designated transfer function to use to 273 * render this volume. 274 */ 275 TransferFunction *_tfPtr; 276 277 float _specular; ///< Specular lighting parameter 278 float _diffuse; ///< Diffuse lighting parameter 279 /** 280 * The scale multiplied to the opacity assigned by the 281 * transfer function. Rule of thumb: higher opacity_scale 282 * the object is to appear like plastic 283 */ 284 float _opacity_scale; 285 60 286 const char *_name; 61 287 Vector3 _physical_min; … … 67 293 double _nonzero_min; 68 294 69 std::vector<CutPlane> _plane; // cut planes 70 71 Texture3D* _tex; // OpenGL texture storing the volume 72 73 int _pointsetIndex; 295 std::vector<CutPlane> _plane; ///< cut planes 296 297 Texture3D *_tex; ///< OpenGL texture storing the volume 74 298 75 299 Vector3 _location; 76 300 77 int _n_slices; // Number of slices when rendered. The greater 78 // the better quality, lower speed. 79 301 /** 302 * Number of slices when rendered. The greater 303 * the better quality, lower speed. 304 */ 305 int _n_slices; 80 306 bool _enabled; 81 82 bool _data_enabled; // show/hide cloud of volume data 83 84 bool _outline_enabled; // show/hide outline around volume 85 86 Color _outline_color; // color for outline around volume 87 88 int _volume_type; // cubic or zincblende 89 307 bool _data_enabled; ///< show/hide cloud of volume data 308 bool _outline_enabled; ///< show/hide outline around volume 309 Color _outline_color; ///< color for outline around volume 310 int _volume_type; ///< cubic or zincblende 90 311 int _iso_surface; 91 92 public:93 enum { CUBIC, VOLQD, ZINCBLENDE };94 float aspect_ratio_width;95 float aspect_ratio_height;96 float aspect_ratio_depth;97 98 GLuint id; //OpenGL textue identifier (==tex->id)99 100 int width; // The resolution of the data (how many points101 // in each direction.102 int height; // It is different from the size of the volume103 // object drawn on screen.104 int depth; // Width, height and depth together determing105 // the proprotion of the volume ONLY.106 float size; // This is the scaling factor that will size107 // the volume on screen. A render program108 // drawing different objects, always knows how109 // large an object is in relation to other110 // objects. This size is provided by the111 // render engine.112 113 AxisRange xAxis, yAxis, zAxis, wAxis;114 static bool update_pending;115 static double valueMin, valueMax;116 117 Volume(float x, float y, float z, int width, int height, int depth,118 float size, int n_component, float* data, double vmin, double vmax,119 double nonzero_min);120 virtual ~Volume();121 122 void visible(bool value) {123 _enabled = value;124 }125 bool visible(void) {126 return _enabled;127 }128 void location(Vector3 loc) {129 _location = loc;130 }131 Vector3 location(void) const {132 return _location;133 }134 int isosurface(void) const {135 return _iso_surface;136 }137 void isosurface(int iso) {138 _iso_surface = iso;139 }140 int n_components(void) {141 return _n_components;142 }143 double nonzero_min(void) {144 return _nonzero_min;145 }146 int volume_type(void) {147 return _volume_type;148 }149 float *data(void) {150 return _data;151 }152 Texture3D *tex(void) {153 return _tex;154 }155 156 double range_nzero_min() { return _nonzero_min; }157 158 int n_slices(void) const {159 return _n_slices;160 }161 void n_slices(int n) {162 _n_slices = n;163 }164 165 void set_size(float s); //set the drawing size of volume166 167 //methods related to cutplanes168 int add_cutplane(int _orientation, float _location); // add a plane and169 // returns its index170 void enable_cutplane(int index);171 void disable_cutplane(int index);172 void move_cutplane(int index, float _location);173 CutPlane* get_cutplane(int index);174 int get_cutplane_count(); //returns the number of cutplanes in the volume175 bool cutplane_is_enabled(int index); //check if a cutplane is enabled176 177 //methods related to shading. These parameters are per volume178 float specular(void) {179 return _specular;180 }181 void specular(float value) {182 _specular = value;183 }184 float diffuse(void) {185 return _diffuse;186 }187 void diffuse(float value) {188 _diffuse = value;189 }190 float opacity_scale(void) {191 return _opacity_scale;192 }193 void opacity_scale(float value) {194 _opacity_scale = value;195 }196 void data_enabled(bool value) {197 _data_enabled = value;198 }199 bool data_enabled(void) {200 return _data_enabled;201 }202 void outline(bool value) {203 _outline_enabled = value;204 }205 bool outline(void) {206 return _outline_enabled;207 }208 TransferFunction *transferFunction(void) {209 return _tfPtr;210 }211 void transferFunction(TransferFunction *tfPtr) {212 _tfPtr = tfPtr;213 }214 void set_outline_color(float* rgb);215 void get_outline_color(float* rgb);216 217 void set_label(int axis, const char* txt); // change the label displayed218 // on an axis219 std::string label[3]; // the labels along each axis 0:x , 1:y, 2:z220 221 void setPhysicalBBox(const Vector3& min, const Vector3& max);222 Vector3& getPhysicalBBoxMin();223 Vector3& getPhysicalBBoxMax();224 225 const char *name(void) {226 return _name;227 }228 void name(const char *name) {229 _name = name;230 }231 312 }; 232 313 … … 258 339 } 259 340 260 inline CutPlane *341 inline CutPlane * 261 342 Volume::get_cutplane(int index) 262 343 { … … 272 353 273 354 inline bool 274 Volume::cutplane_is_enabled(int index) 355 Volume::cutplane_is_enabled(int index) const 275 356 { 276 357 //assert(index < plane.size()); … … 290 371 Volume::set_outline_color(float *rgb) 291 372 { 292 _outline_color = Color(rgb[0], rgb[1],rgb[2]);373 _outline_color = Color(rgb[0], rgb[1], rgb[2]); 293 374 } 294 375 … … 296 377 Volume::get_outline_color(float *rgb) 297 378 { 298 _outline_color. GetRGB(rgb);379 _outline_color.getRGB(rgb); 299 380 } 300 381 … … 322 403 } 323 404 324 inline Vector3&325 Volume::getPhysicalBBoxMin() 405 inline const Vector3& 406 Volume::getPhysicalBBoxMin() const 326 407 { 327 408 return _physical_min; 328 409 } 329 410 330 inline Vector3&331 Volume::getPhysicalBBoxMax() 411 inline const Vector3& 412 Volume::getPhysicalBBoxMax() const 332 413 { 333 414 return _physical_max; -
trunk/packages/vizservers/nanovis/ZincBlendeVolume.cpp
r2827 r2844 17 17 18 18 #include <assert.h> 19 19 20 #include "ZincBlendeVolume.h" 20 21 21 22 ZincBlendeVolume::ZincBlendeVolume(float x, float y, float z, 22 23 int w, int h, int d, float s, int n, 23 float * dataVolumeA, float*dataVolumeB,24 float *dataVolumeA, float *dataVolumeB, 24 25 double v0, double v1, double non_zeromin, 25 26 const Vector3& cellSize) : … … 35 36 36 37 //now add another tex as zincblende_tex[1] 37 Texture3D *secondTex = new Texture3D(w, h, d, GL_FLOAT, GL_LINEAR, n);38 Texture3D *secondTex = new Texture3D(w, h, d, GL_FLOAT, GL_LINEAR, n); 38 39 assert(secondTex); 39 40 secondTex->initialize(dataVolumeB); … … 45 46 { 46 47 // This data will be deleted in a destrutor of Volume class 47 //if (zincblende_tex[0])48 //if (zincblende_tex[0]) 48 49 // delete zincblende_tex[0]; 49 if (zincblende_tex[1])50 if (zincblende_tex[1]) 50 51 delete zincblende_tex[1]; 51 52 } -
trunk/packages/vizservers/nanovis/ZincBlendeVolume.h
r2798 r2844 15 15 * ====================================================================== 16 16 */ 17 18 17 #ifndef _ZINCBLENDE_VOLUME_H_ 19 18 #define _ZINCBLENDE_VOLUME_H_ 20 21 19 22 20 #include "Volume.h" … … 25 23 { 26 24 public: 27 Texture3D* zincblende_tex[2]; //the textures of two cubic volumes 28 Vector3 cell_size; //the cell size in texture space 25 ZincBlendeVolume(float x, float y, float z, 26 int width, int height, int depth, float size, int n_component, 27 float *dataVolumeA, float *dataVolumeB, 28 double vmin, double vmax, double non_zeromin, const Vector3& cellSize); 29 29 30 virtual ~ZincBlendeVolume(); 30 31 31 ZincBlendeVolume(float x, float y, float z, 32 int width, int height, int depth, float size, int n_component, 33 float* dataVolumeA, float* dataVolumeB, 34 double vmin, double vmax, double non_zeromin, const Vector3& cellSize); 35 36 virtual ~ZincBlendeVolume(); 32 Texture3D *zincblende_tex[2]; //the textures of two cubic volumes 33 Vector3 cell_size; //the cell size in texture space 37 34 }; 38 35 -
trunk/packages/vizservers/nanovis/dxReaderCommon.cpp
r2798 r2844 7 7 8 8 float * 9 merge(float * scalar, float*gradient, int size)9 merge(float *scalar, float *gradient, int size) 10 10 { 11 float * data = (float*)malloc(sizeof(float) * 4 * size);11 float *data = (float *)malloc(sizeof(float) * 4 * size); 12 12 13 Vector3 * g = (Vector3*)gradient;13 Vector3 *g = (Vector3 *)gradient; 14 14 15 15 int ngen = 0, sindex = 0; 16 for (sindex = 0; sindex < size; ++sindex) {17 data[ngen++] = scalar[sindex];18 data[ngen++] = g[sindex].x;19 data[ngen++] = g[sindex].y;20 data[ngen++] = g[sindex].z;16 for (sindex = 0; sindex < size; ++sindex) { 17 data[ngen++] = scalar[sindex]; 18 data[ngen++] = g[sindex].x; 19 data[ngen++] = g[sindex].y; 20 data[ngen++] = g[sindex].z; 21 21 } 22 22 return data; … … 24 24 25 25 void 26 normalizeScalar(float *fdata, int count, float min, float max)26 normalizeScalar(float *fdata, int count, float min, float max) 27 27 { 28 28 float v = max - min; … … 30 30 for (int i = 0; i < count; ++i) { 31 31 fdata[i] = fdata[i] / v; 32 }32 } 33 33 } 34 34 } 35 35 36 float *37 computeGradient(float *fdata, int width, int height, int depth,38 float min, float max)36 float * 37 computeGradient(float *fdata, int width, int height, int depth, 38 float min, float max) 39 39 { 40 float *gradients = (float *)malloc(width * height * depth * 3 *41 sizeof(float));42 float *tempGradients = (float *)malloc(width * height * depth * 3 *43 sizeof(float));40 float *gradients = (float *)malloc(width * height * depth * 3 * 41 sizeof(float)); 42 float *tempGradients = (float *)malloc(width * height * depth * 3 * 43 sizeof(float)); 44 44 int sizes[3] = { width, height, depth }; 45 45 computeGradients(tempGradients, fdata, sizes, DATRAW_FLOAT); … … 47 47 quantizeGradients(tempGradients, gradients, sizes, DATRAW_FLOAT); 48 48 normalizeScalar(fdata, width * height * depth, min, max); 49 float *data = merge(fdata, gradients, width * height * depth);49 float *data = merge(fdata, gradients, width * height * depth); 50 50 return data; 51 51 } 52 52 53 53 void 54 computeSimpleGradient(float *data, int nx, int ny, int nz)54 computeSimpleGradient(float *data, int nx, int ny, int nz) 55 55 { 56 56 // Compute the gradient of this data. BE CAREFUL: center 57 57 // calculation on each node to avoid skew in either direction. 58 58 int ngen = 0; 59 for (int iz =0; iz < nz; iz++) {60 for (int iy =0; iy < ny; iy++) {61 for (int ix =0; ix < nx; ix++) {59 for (int iz = 0; iz < nz; iz++) { 60 for (int iy = 0; iy < ny; iy++) { 61 for (int ix = 0; ix < nx; ix++) { 62 62 // gradient in x-direction 63 64 // INSOO -teST65 63 double valm1 = (ix == 0) ? 0.0 : data[ngen - 4]; 66 64 double valp1 = (ix == nx-1) ? 0.0 : data[ngen + 4]; 67 if (valm1 < 0 || valp1 <0) {65 if (valm1 < 0.0 || valp1 < 0.0) { 68 66 data[ngen+1] = 0.0; 69 67 } else { 70 data[ngen+1] = valp1-valm1; // assume dx=1 // ISO71 //data[ngen+1] = ((valp1-valm1) + 1 ) * 0.5; // assume dx=168 data[ngen+1] = valp1-valm1; // assume dx=1 69 //data[ngen+1] = ((valp1-valm1) + 1.0) * 0.5; // assume dx=1 (ISO) 72 70 } 73 71 74 72 // gradient in y-direction 75 valm1 = (iy == 0) ? 0.0 : data[ngen -4*nx];76 valp1 = (iy == ny-1) ? 0.0 : data[ngen +4*nx];77 if (valm1 < 0 || valp1 <0) {73 valm1 = (iy == 0) ? 0.0 : data[ngen - 4*nx]; 74 valp1 = (iy == ny-1) ? 0.0 : data[ngen + 4*nx]; 75 if (valm1 < 0.0 || valp1 < 0.0) { 78 76 data[ngen+2] = 0.0; 79 77 } else { 80 data[ngen+2] = valp1-valm1; // assume d x=181 //data[ngen+2] = ((valp1-valm1) + 1) * 0.5; // assume dy=1 // ISO78 data[ngen+2] = valp1-valm1; // assume dy=1 79 //data[ngen+2] = ((valp1-valm1) + .01) * 0.5; // assume dy=1 (ISO) 82 80 } 83 81 84 82 // gradient in z-direction 85 valm1 = (iz == 0) ? 0.0 : data[ngen -4*nx*ny];86 valp1 = (iz == nz-1) ? 0.0 : data[ngen +4*nx*ny];87 if (valm1 < 0 || valp1 <0) {83 valm1 = (iz == 0) ? 0.0 : data[ngen - 4*nx*ny]; 84 valp1 = (iz == nz-1) ? 0.0 : data[ngen + 4*nx*ny]; 85 if (valm1 < 0.0 || valp1 < 0.0) { 88 86 data[ngen+3] = 0.0; 89 87 } else { 90 data[ngen+3] = valp1-valm1; // assume d x=191 //data[ngen+3] = ((valp1-valm1) + 1.0) * 0.5; // assume dz=1 //ISO88 data[ngen+3] = valp1-valm1; // assume dz=1 89 //data[ngen+3] = ((valp1-valm1) + 1.0) * 0.5; // assume dz=1 (ISO) 92 90 } 93 91 -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrMatrix4x4f.h
r2842 r2844 3 3 #define VRMATRIX4X4_H 4 4 5 #include <memory.h> 6 5 7 #include <vrmath/vrLinmath.h> 6 8 #include <vrmath/vrVector3f.h> 7 9 #include <vrmath/vrRotation.h> 8 #include <memory.h>9 10 10 11 class vrMatrix4x4f … … 121 122 } 122 123 123 124 124 inline void vrMatrix4x4f::getTranslation(vrVector3f& translation) 125 125 { 126 translation.set(_data[12], _data[13], _data[14]);126 translation.set(_data[12], _data[13], _data[14]); 127 127 } 128 128 129 inline void vrMatrix4x4f::makeTRS(const vrVector3f& translation, const vrRotation& rotation, const vrVector3f& scale) 129 inline void vrMatrix4x4f::makeTRS(const vrVector3f& translation, 130 const vrRotation& rotation, 131 const vrVector3f& scale) 130 132 { 131 133 vrMatrix4x4f mat; … … 137 139 } 138 140 139 inline void vrMatrix4x4f::makeTR(const vrVector3f& translation, const vrRotation& rotation) 141 inline void vrMatrix4x4f::makeTR(const vrVector3f& translation, 142 const vrRotation& rotation) 140 143 { 141 144 makeRotation(rotation); -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrRotation.h
r2842 r2844 9 9 10 10 /** 11 * Represents an axis/angle rotation 11 * Represents an axis/angle rotation (angle in radians) 12 12 */ 13 13 class vrRotation -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrVector2f.h
r2841 r2844 3 3 #define VRVECTOR2F_H 4 4 5 #include <vrmath/vrLinmath.h>6 7 5 #include <cstdlib> 8 6 #include <cmath> 7 8 #include <vrmath/vrLinmath.h> 9 9 10 10 class vrVector2f -
trunk/packages/vizservers/nanovis/vrmath/vrMatrix4x4f.cpp
r2842 r2844 44 44 } 45 45 46 float xAxis = rotation.getX(), yAxis = rotation.getY(), zAxis = rotation.getZ(); 46 float xAxis = rotation.getX(); 47 float yAxis = rotation.getY(); 48 float zAxis = rotation.getZ(); 47 49 float invLen = 1.0f / sqrt(xAxis * xAxis + yAxis * yAxis + zAxis * zAxis); 48 50 float cosine = cos(rotation.getAngle());
Note: See TracChangeset
for help on using the changeset viewer.