Ignore:
Timestamp:
Mar 12, 2012 10:31:30 AM (12 years ago)
Author:
ldelgass
Message:

Cleanups, no functional changes

Location:
trunk/packages/vizservers/nanovis
Files:
36 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/Axis.cpp

    r2808 r2844  
    55#include <float.h>
    66#include <string.h>
     7
    78#include "Axis.h"
    89
  • trunk/packages/vizservers/nanovis/AxisRange.h

    r2822 r2844  
    55#include <string.h>
    66
    7 class AxisRange {
    8     double min_, max_;
    9     char *units_;
     7class AxisRange
     8{
    109public:
    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    {
    1515    }
    16     ~AxisRange(void) {
    17         if (units_ != NULL) {
    18             delete [] units_;
    19         }
     16
     17    ~AxisRange()
     18    {
     19        if (_units != NULL) {
     20            delete [] _units;
     21        }
    2022    }
    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;
    2328    }
    24     double min(void) {
    25         return min_;
     29
     30    double min() const
     31    {
     32        return _min;
    2633    }
    27     void min(double min) {
    28         min_ = min;
     34
     35    void min(double min)
     36    {
     37        _min = min;
    2938    }
    30     double max(void) {
    31         return max_;
     39
     40    double max() const
     41    {
     42        return _max;
    3243    }
    33     void max(double max) {
    34         max_ = max;
     44
     45    void max(double max)
     46    {
     47        _max = max;
    3548    }
    36     const char *units(void) {
    37         return units_;
     49
     50    const char *units() const
     51    {
     52        return _units;
    3853    }
    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        }
    4966    }
     67
     68private:
     69    double _min, _max;
     70    char *_units;
    5071};
    5172
  • trunk/packages/vizservers/nanovis/Color.cpp

    r2798 r2844  
    1414 * ======================================================================
    1515 */
    16 
    1716#include <stdio.h>
    1817#include <assert.h>
     
    2120#include "define.h"
    2221
    23 Color::Color() {
    24         R=G=B=0.0;
    25         next=0;
     22Color::Color() :
     23    _r(0),
     24    _g(0),
     25    _b(0)
     26{
    2627}
    2728
    28 Color::Color(double r, double g, double b) {
    29         R=r;
    30         G=g;
    31         B=b;
    32         next=0;
     29Color::Color(double r, double g, double b) :
     30    _r(r),
     31    _g(g),
     32    _b(b)
     33{
    3334}
    3435
    35 Color::Color(const Color& c)
    36  : R(c.R), G(c.G), B(c.B), next(c.next)
     36Color::Color(const Color& c) :
     37    _r(c._r),
     38    _g(c._g),
     39    _b(c._b)
     40{
     41}
     42
     43Color::~Color()
    3744{
    3845}
     
    4148Color::operator=(const Color& c)
    4249{
    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;
    4753    return *this;
    4854}
    4955
    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]
     57void 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;
    5462
    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;
    5866}
    5967
    60 Color Color::operator*(double k){
    61         return Color(R*k, G*k, B*k);
     68Color Color::operator*(double k) const
     69{
     70    return Color(_r * k, _g * k, _b * k);
    6271}
    6372
    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);
     73Color Color::operator*(const Color& other) const
     74{
     75    return Color(_r * other._r, _g * other._g, _b * other._b);
    6876}
    6977
    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);
     78Color Color::operator+(const Color& other) const
     79{
     80    return Color(_r + other._r, _g + other._g, _b + other._b);
    7481}
    7582
    76 Color Color::operator *(Color &other){
    77         return Color(this->R*other.R,this->G*other.G,this->B*other.B);
     83void 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);
    7888}
    7989
    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);
     90void Color::getRGB(float *result)
     91{
     92    result[0] = (float)_r;
     93    result[1] = (float)_g;
     94    result[2] = (float)_b;
    8995}
    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  
    1414 * ======================================================================
    1515 */
    16 
    17 #ifndef _COLOR_H_
    18 #define _COLOR_H_
     16#ifndef COLOR_H
     17#define COLOR_H
    1918
    2019class Color 
    2120{
    2221public:
    23         double R;               // Red component
    24         double G;               // Green component
    25         double B;               // Blue component
     22    Color();
    2623
    27         void GetRGB(unsigned char *result);
    28         void GetRGB(float *result);
     24    Color(double r, double g, double b);
    2925
    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();
    3427
    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);
    4029
    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
     47private:
     48    double _r;  ///< Red component
     49    double _g;  ///< Green component
     50    double _b;  ///< Blue component
    4551};
    4652
     53// This is NOT member operator. It's used so we can write (k*V),
     54// not only (V*k) (V-vector k-scalar)
     55inline Color operator*(double k, const Color& c)
     56{
     57    return Color(c._r * k, c._g * k, c._b * k);
     58}
     59
    4760#endif
  • trunk/packages/vizservers/nanovis/FlowCmd.h

    r2831 r2844  
    4949
    5050struct 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
    5756};
    5857
     
    125124
    126125private:
    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;
    130131    Tcl_HashEntry *_hashPtr;
    131     NvParticleRenderer *_rendererPtr;   /* Particle renderer. */
     132    NvParticleRenderer *_rendererPtr;   ///< Particle renderer
    132133    FlowParticlesValues _sv;
    133134
     
    141142
    142143struct 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
    148147    float lineWidth;
    149     int isHidden;                       /* Indicates if particle injection
    150                                          * plance is active or not. */
     148    /// Indicates if particle injection plane is active or not
     149    int isHidden;
    151150};
    152151
     
    391390    Tcl_Interp *_interp;
    392391    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;
    420438
    421439    static Rappture::SwitchSpec _switches[];
    422     FlowValues _sv;
    423440};
    424441
  • trunk/packages/vizservers/nanovis/GradientFilter.cpp

    r2813 r2844  
    66#include <string.h>
    77#include <stdio.h>
     8
    89#include "Trace.h"
    910#include "GradientFilter.h"
     
    1415
    1516#define GRADIENTS_EXT       ".grd"
    16 int g_numOfSlices[3] = { 256, 256, 256 };
    17 void* g_volData = 0;
    18 float g_sliceDists[3];
     17static int g_numOfSlices[3] = { 256, 256, 256 };
     18static void *g_volData = 0;
     19static float g_sliceDists[3];
    1920
    2021#define SOBEL               1
     
    287288        }
    288289    }
    289 
    290290}
    291291
  • trunk/packages/vizservers/nanovis/GradientFilter.h

    r2798 r2844  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #ifndef _GRADIENT_FILTER_H
    3 #define _GRADIENT_FILTER_H
     2#ifndef GRADIENT_FILTER_H
     3#define GRADIENT_FILTER_H
    44
    5 typedef enum {DATRAW_UCHAR, DATRAW_FLOAT, DATRAW_USHORT} DataType;
     5typedef enum {
     6    DATRAW_UCHAR,
     7    DATRAW_FLOAT,
     8    DATRAW_USHORT
     9} DataType;
    610
    7 extern void computeGradients(float *gradients, void* volData, int *sizes, DataType dataType);
     11extern void computeGradients(float *gradients, void *volData, int *sizes, DataType dataType);
     12
    813extern void filterGradients(float *gradients, int *sizes);
     14
    915extern void quantizeGradients(float *gradientsIn, void *gradientsOut,
    10                                            int *sizes, DataType dataType);
     16                              int *sizes, DataType dataType);
    1117
    12 #endif /*_GRADIENT_FILTER_H*/
     18#endif
  • trunk/packages/vizservers/nanovis/Grid.cpp

    r2798 r2844  
    99#define GRID_TICK       0.05
    1010
    11 Grid::Grid() :
     11Grid::Grid() :
     12    xAxis("X"),
     13    yAxis("Y"),
     14    zAxis("Z"),
    1215    _axisColor(1.0f, 1.0f, 1.0f, 1.0f),
    1316    _majorColor(1.0f, 1.0f, 1.0f, 1.0f),
    1417    _minorColor(0.5f, 0.5f, 0.5f, 1.0f),
    1518    _font(0),
    16     _visible(false),
    17     xAxis("X"),
    18     yAxis("Y"),
    19     zAxis("Z")
     19    _visible(false)
    2020{
    21     /*empty*/
    2221}
    2322
  • trunk/packages/vizservers/nanovis/Grid.h

    r2798 r2844  
    11/* -*- 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
    44
    55#include <R2/R2Fonts.h>
     6
    67#include "Axis.h"
    78#include "AxisRange.h"
    89
    9 class RGBA {
     10class RGBA
     11{
    1012public:
     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
    1128    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     }
    2129};
    2230
    23 class Grid {
    24     RGBA _axisColor, _majorColor, _minorColor;
    25     R2Fonts* _font;
    26     bool _visible;
     31class Grid
     32{
     33public:
     34    Grid();
    2735
    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
    2961    Axis xAxis;
    3062    Axis yAxis;
    3163    Axis zAxis;
    3264
    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);
     65private:
     66    RGBA _axisColor, _majorColor, _minorColor;
     67    R2Fonts *_font;
     68    bool _visible;
    4969};
    5070
  • trunk/packages/vizservers/nanovis/HeightMap.cpp

    r2827 r2844  
    77#include <fcntl.h>
    88#include <stdlib.h>
     9
    910#include <GL/glew.h>
    1011#include <GL/gl.h>
     12
    1113#include "Grid.h"
    1214#include "HeightMap.h"
     
    532534    glTranslatef(0.0, 0.0, -10.0);
    533535
    534     // put camera rotation and traslation
     536    // put camera rotation and translation
    535537    //glScalef(1 / _scale.x, 1 / _scale.y , 1 / _scale.z);
    536538
     
    647649    glPopAttrib();
    648650}
    649 
  • trunk/packages/vizservers/nanovis/NvParticleRenderer.h

    r2837 r2844  
    1414 * ======================================================================
    1515 */
    16 #ifndef NV_PARTICLE_SYSTEM_H
    17 #define NV_PARTICLE_SYSTEM_H
     16#ifndef NVPARTICLERENDERER_H
     17#define NVPARTICLERENDERER_H
    1818
    1919#include <vector>
  • trunk/packages/vizservers/nanovis/NvStdVertexShader.cpp

    r2798 r2844  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    22#include <stdio.h>
     3
    34#include "global.h"
    45#include "NvStdVertexShader.h"
     
    1617{
    1718    _cgVP = LoadCgSourceProgram(g_context, "vertex_std.cg", CG_PROFILE_VP30,
    18         "main");
     19                                "main");
    1920    _mvp_vert_std_param = cgGetNamedParameter(_cgVP, "modelViewProjMatrix");
    2021    _mvi_vert_std_param = cgGetNamedParameter(_cgVP, "modelViewInv");
    2122}
    22 
  • trunk/packages/vizservers/nanovis/NvStdVertexShader.h

    r2798 r2844  
    11/* -*- 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
    44
    55#include "NvShader.h"
    66
    7 class NvStdVertexShader : public NvShader {
    8     /**
    9      * @brief A parameter id for ModelViewProjection matrix of Cg program
    10      */
     7class NvStdVertexShader : public NvShader
     8{
     9public:
     10    NvStdVertexShader();
     11
     12    ~NvStdVertexShader();
     13
     14    void bind();
     15    void unbind();
     16
     17private:
     18    void init();
     19
     20    /// A parameter id for ModelViewProjection matrix of Cg program
    1121    CGparameter _mvp_vert_std_param;
    1222
    13     /**
    14      * @brief A parameter id for ModelViewInverse matrix of Cg program
    15      */
     23    /// A parameter id for ModelViewInverse matrix of Cg program
    1624    CGparameter _mvi_vert_std_param;
    17 
    18 public :
    19     /**
    20      * @brief Constructor
    21      */
    22     NvStdVertexShader();
    23 
    24     /**
    25      * @brief Destructor
    26      */
    27     ~NvStdVertexShader();
    28 private :
    29     void init();
    30 
    31 public :
    32     void bind();
    33     void unbind();
    3425};
    3526
     
    4031    cgGLBindProgram(_cgVP);
    4132    cgGLEnableProfile(CG_PROFILE_VP30);
    42 
    4333}
    4434
  • trunk/packages/vizservers/nanovis/NvVolumeShader.h

    r2798 r2844  
    11/* -*- 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
    44
    5 #include <Cg/cg.h>
    6 #include <Cg/cgGL.h>
    75#include "NvShader.h"
    86
    97class Volume;
    108
    11 class NvVolumeShader : public NvShader {
    12 protected :
    13     NvVolumeShader();
    14 
     9class NvVolumeShader : public NvShader
     10{
    1511public :
    1612    virtual ~NvVolumeShader();
    1713
    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
    2016    virtual void unbind() = 0;
     17
     18protected :
     19    NvVolumeShader();
    2120};
    2221
  • trunk/packages/vizservers/nanovis/NvZincBlendeReconstructor.cpp

    r2822 r2844  
    33#include <string.h>
    44#include <stdlib.h>
     5
    56#include "NvZincBlendeReconstructor.h"
    67#include "ZincBlendeVolume.h"
     
    149150    {
    150151        // NOTE
    151         // Zinc blende data has different axises from OpenGL
     152        // Zinc blende data has different axes from OpenGL
    152153        // + z -> +x (OpenGL)
    153154        // + x -> +y (OpenGL)
    154155        // + y -> +z (OpenGL), But in 3D texture coordinate is the opposite direction of z
    155         // The reasone why index is multiplied by 4 is that one unit cell has half of eight atoms
    156         // ,i.e. four atoms are mapped into RGBA component of one texel
     156        // 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
    157158        //return ((int) (indexZ - 1)+ (int) (indexX - 1) * width + (int) (indexY - 1) * width * height) * 4;
    158159        return ((int)(indexX - 1) + (int)(indexY - 1) * width + (int)(indexZ - 1) * width * height) * 4;
     
    194195ZincBlendeVolume *
    195196NvZincBlendeReconstructor::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)
    197198{
    198199    ZincBlendeVolume *zincBlendeVolume = NULL;
  • trunk/packages/vizservers/nanovis/NvZincBlendeReconstructor.h

    r2822 r2844  
    2828class NvZincBlendeReconstructor
    2929{
    30     char buff[255];
    31 
    32     /**
    33      * @brief A ZincBlendeReconstructor Singleton instance
    34      */
    35     static NvZincBlendeReconstructor* _instance;
    36 private:
    37     /**
    38      * @brief Constructor
    39      */
    40     NvZincBlendeReconstructor();
    41 
    42     /**
    43      * @brief Destructor
    44      */
    45     ~NvZincBlendeReconstructor();
    46 
    47 public:
    48     /**
    49      * @brief Return a singleton instance
    50      */
    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 file
    57      */
    58     void getLine(std::istream& stream);
    59     void getLine(unsigned char*& stream);
    60 
    6130public:
    6231    /**
     
    6433     * @param fileName Zinc blende file name, which data is generated by NEMO-3D
    6534     */
    66     ZincBlendeVolume *loadFromFile(const char* fileName);
     35    ZincBlendeVolume *loadFromFile(const char *fileName);
    6736
    6837    /**
     
    7140     */
    7241    ZincBlendeVolume *loadFromStream(std::istream& stream);
     42
    7343    ZincBlendeVolume *loadFromMemory(void *dataBlock);
    7444
     
    8454    ZincBlendeVolume *buildUp(const Vector3& origin, const Vector3& delta,
    8555                              int width, int height, int depth, void *data);
     56
    8657    ZincBlendeVolume *buildUp(const Vector3& origin, const Vector3& delta,
    8758                              int width, int height, int depth,
    8859                              int datacount, double emptyvalue, void *data);
     60
     61    /**
     62     * @brief Return a singleton instance
     63     */
     64    static NvZincBlendeReconstructor* getInstance();
     65
     66private:
     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;
    8982};
    9083
  • trunk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.h

    r2822 r2844  
    11/* -*- 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
    44
    55#include "ZincBlendeVolume.h"
    66#include "NvVolumeShader.h"
    77
    8 class NvZincBlendeVolumeShader : public NvVolumeShader {
     8class NvZincBlendeVolumeShader : public NvVolumeShader
     9{
     10public :
     11    NvZincBlendeVolumeShader();
     12
     13    ~NvZincBlendeVolumeShader();
     14
     15    void bind(unsigned int tfID, Volume *volume, int sliceMode);
     16
     17    void unbind();
     18
     19private :
     20    void init();
     21
    922    CGparameter _tfParam;
    1023    CGparameter _volumeAParam;
     
    1427    CGparameter _renderParam;
    1528    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();
    2529};
    2630
    27 inline void NvZincBlendeVolumeShader::bind(unsigned int tfID, Volume* volume, int sliceMode)
     31inline void NvZincBlendeVolumeShader::bind(unsigned int tfID, Volume *volume, int sliceMode)
    2832{
    29     ZincBlendeVolume* vol = (ZincBlendeVolume*)volume;
     33    ZincBlendeVolume *vol = (ZincBlendeVolume *)volume;
    3034    cgGLSetStateMatrixParameter(_mviParam, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_INVERSE);
    3135    cgGLSetTextureParameter(_tfParam, tfID);
    3236    cgGLSetParameter4f(_cellSizeParam, vol->cell_size.x, vol->cell_size.y, vol->cell_size.z, 0.);
    3337
    34     if(!sliceMode)
     38    if (!sliceMode) {
    3539        cgGLSetParameter4f(_renderParam,
    36             vol->n_slices(),
    37             vol->opacity_scale(),
    38             vol->diffuse(),
    39             vol->specular());
    40     else
     40                           vol->n_slices(),
     41                           vol->opacity_scale(),
     42                           vol->diffuse(),
     43                           vol->specular());
     44    } else {
    4145        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    }
    4651
    4752    cgGLSetParameter4f(_option_one_volume_param,
    48         0.0f,
    49         volume->isosurface(),
    50         0.0f,
    51         0.0f);
     53                       0.0f,
     54                       volume->isosurface(),
     55                       0.0f,
     56                       0.0f);
    5257
    53     cgGLSetTextureParameter(_volumeAParam,  vol->zincblende_tex[0]->id);
     58    cgGLSetTextureParameter(_volumeAParam, vol->zincblende_tex[0]->id);
    5459    cgGLSetTextureParameter(_volumeBParam, vol->zincblende_tex[1]->id);
    5560    cgGLEnableTextureParameter(_volumeAParam);
  • trunk/packages/vizservers/nanovis/PCASplit.cpp

    r2832 r2844  
    111111    finalSize = sqrt (finalSize) + maxSize;
    112112}
    113      
    114 void 
     113
     114void
    115115PCASplit::init()
    116116{
    117     _curClusterNode = 0;
     117    _curClusterNode = NULL;
    118118    _curClusterCount = 0;
    119119}
    120120
    121 Cluster * 
     121Cluster *
    122122PCASplit::createClusterBlock(ClusterListNode *clusterList, int count, int level)
    123123{
     
    179179    ClusterListNode *clustNodeList = &(_memClusterChunk2[0]);
    180180    clustNodeList->data = cluster_t;
    181     clustNodeList->next = 0;
     181    clustNodeList->next = NULL;
    182182
    183183    _curRoot = root;
     
    189189
    190190        // swap memory buffer & init
    191         _curMemClusterChunk = (_curMemClusterChunk == _memClusterChunk1)?
     191        _curMemClusterChunk = (_curMemClusterChunk == _memClusterChunk1) ?
    192192            _memClusterChunk2 : _memClusterChunk1;
    193193        _memClusterChunkIndex = 0;
     
    233233    computeCovariant(data, count, mean, m);
    234234
     235    // Begin newmat11 dependency
     236
    235237    SymmetricMatrix A(3);
    236238    for (int i = 1; i <= 3; ++i) {
     
    242244    Matrix U;
    243245    DiagonalMatrix D;
    244     eigenvalues(A,D,U);
     246    eigenvalues(A, D ,U);
    245247    Vector3 emax(U(1, 3), U(2, 3), U(3, 3));
     248
     249    // End newmat11 dependency
    246250
    247251    int left = 0, right = count - 1;
     
    370374    }
    371375}
    372 
  • trunk/packages/vizservers/nanovis/PCASplit.h

    r2832 r2844  
    1919
    2020    Vector3 position;
    21     // histogram Index;
    22     //unsigned char color;
    2321    Vector4 color;
    2422    float size;
     
    3028public:
    3129    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),
    3534        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)
    4039    {
    4140    }
     
    4645        numOfChildren = count;
    4746    }
     47
    4848    void setPoints(Point *points, int count)
    4949    {
     
    6767{
    6868public:
    69     ClusterAccel(int maxlevel)
    70         : root(0),
    71           maxLevel(maxlevel)
     69    ClusterAccel(int maxlevel) :
     70        root(NULL),
     71        maxLevel(maxlevel)
    7272    {
    7373        startPointerCluster = new Cluster *[maxLevel];
    7474        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);
    7777    }
    7878
     
    8181    Cluster **startPointerCluster;
    8282    int *numOfClusters;
    83     unsigned int *_vbo;
     83    unsigned int *vbo;
    8484};
    8585
  • trunk/packages/vizservers/nanovis/PointSet.cpp

    r2814 r2844  
    66
    77void
    8 PointSet::initialize(Vector4* values, const unsigned int count,
     8PointSet::initialize(Vector4 *values, const unsigned int count,
    99                     const Vector3& scale, const Vector3& origin,
    1010                     float min, float max)
     
    1717    _max = max;
    1818
    19     PCA::Point* points = (PCA::Point*) malloc(sizeof(PCA::Point) * count);
     19    PCA::Point *points = (PCA::Point *)malloc(sizeof(PCA::Point) * count);
    2020    for (unsigned int i = 0; i < count; ++i) {
    2121        points[i].position.set(values[i].x, values[i].y, values[i].z);
     
    3434
    3535void
    36 PointSet::updateColor(float* color, int colorCount)
     36PointSet::updateColor(float *color, int colorCount)
    3737{
    3838    if (_cluster == 0) {
     
    4141    int level = 4;
    4242
    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
    4747    Vector3 pos;
    48    
    49     PCA::Point* points;
    50     Vector4* colors = (Vector4*) color;
     48
     49    PCA::Point *points;
     50    Vector4 *colors = (Vector4 *)color;
    5151    int numOfPoints;
    5252    int index;
    5353    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))) {
    5555        points = c->points;
    5656        numOfPoints = c->numOfPoints;
  • trunk/packages/vizservers/nanovis/PointSet.h

    r2831 r2844  
    2929                    float min, float max);
    3030
    31     void updateColor(float *color, int  count);
     31    void updateColor(float *color, int count);
    3232
    3333    bool isVisible() const
     
    7373private:
    7474    unsigned int _sortLevel;
    75     PCA::ClusterAccel* _cluster;
     75    PCA::ClusterAccel *_cluster;
    7676
    7777    Vector3 _scale;
  • trunk/packages/vizservers/nanovis/PointSetRenderer.h

    r2831 r2844  
    2929
    3030#endif
    31 
  • trunk/packages/vizservers/nanovis/Renderable.cpp

    r2837 r2844  
    2121
    2222Renderable::Renderable(const Vector3& loc) :
    23     location(loc),
    24     enabled(true)
     23    _location(loc),
     24    _enabled(true)
    2525{
    2626}
     
    3131void Renderable::move(const Vector3& new_loc)
    3232{
    33     location = new_loc;
     33    _location = new_loc;
    3434}
    3535
    3636void Renderable::enable()
    3737{
    38     enabled = true;
     38    _enabled = true;
    3939}
    4040
    4141void Renderable::disable()
    4242{
    43     enabled = false;
     43    _enabled = false;
    4444}
    4545
    4646bool Renderable::is_enabled() const
    4747{
    48     return enabled;
     48    return _enabled;
    4949}
    5050
  • trunk/packages/vizservers/nanovis/Renderable.h

    r2837 r2844  
    2020
    2121struct BoundBox {
    22     Vector3 low; //lower coordinates
    23     Vector3 high; //higher coordinates
     22    Vector3 low;  ///< lower coordinates
     23    Vector3 high; ///< higher coordinates
    2424
    2525    BoundBox()
     
    5353
    5454protected:
    55     Vector3 location;   //the location (x,y,z) of the object
    56     bool enabled;       //display is enabled
    57     BoundBox boundary;  //the bounding box
     55    Vector3 _location;  ///< the location (x,y,z) of the object
     56    bool _enabled;      ///< display is enabled
     57    BoundBox _boundary; ///< the bounding box
    5858};
    5959
  • trunk/packages/vizservers/nanovis/RpDX.cpp

    r2798 r2844  
    1515 * ======================================================================
    1616 */
     17#include <math.h>
     18#include <stdio.h>
     19#include <stdlib.h>
     20#include <float.h>
     21
    1722#include "nvconf.h"
    1823#ifdef HAVE_DX_DX_H
     
    2025#undef ERROR
    2126#include "Trace.h"
    22 #include <math.h>
    23 #include <stdio.h>
    24 #include <stdlib.h>
    25 #include <float.h>
    2627
    2728using namespace Rappture;
     
    136137    memset(_max, 0, _numAxis);
    137138
    138     __findPosMax();
     139    findPosMax();
    139140
    140141    // parse out the gridconnections (length of each axis) array
     
    186187            _positions[pt+6],_positions[pt+7],_positions[pt+8],_data[lcv+2]);
    187188    }
    188     __collectDataStats();
     189    collectDataStats();
    189190}
    190191
     
    200201
    201202void
    202 DX::__findPosMax()
     203DX::findPosMax()
    203204{
    204205    int lcv = 0;
     
    219220
    220221void
    221 DX::__collectDataStats()
     222DX::collectDataStats()
    222223{
    223224    _dataMin = FLT_MAX;
     
    251252 */
    252253void
    253 DX::__getInterpPos()
     254DX::getInterpPos()
    254255{
    255256    Array dxpos;
     
    286287 */
    287288void
    288 DX::__getInterpData()
     289DX::getInterpData()
    289290{
    290291    int pts = _n;
     
    317318    }
    318319
    319     __collectDataStats();
     320    collectDataStats();
    320321}
    321322
     
    337338        }
    338339    }
    339     __getInterpPos();
    340     __getInterpData();
     340    getInterpPos();
     341    getInterpData();
    341342    TRACE("----end interpolation----\n");
    342343    return *this;
  • trunk/packages/vizservers/nanovis/RpDX.h

    r2818 r2844  
    1919
    2020#include <dx/dx.h>
     21
    2122#include <RpOutcome.h>
    2223
    2324namespace Rappture {
    2425
    25 class DX {
     26class DX
     27{
    2628public:
    2729    DX();
    28     DX(Rappture::Outcome &result, const char* filename);
     30
     31    DX(Rappture::Outcome& result, const char *filename);
     32
    2933    DX(const DX& rpdx);
     34
    3035    DX& operator=(const DX& rpdx);
     36
    3137    virtual ~DX();
    3238
     
    3743    virtual double valueMax() const;
    3844    */
    39     virtual DX& interpolate(int* newAxisLen);
     45    virtual DX& interpolate(int *newAxisLen);
    4046
    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;
    7750    }
    7851
    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    }
    80107
    81108private:
     109    void findPosMax();
     110    void collectDataStats();
     111    void getInterpPos();
     112    void getInterpData();
     113
    82114    float _dataMin;
    83115    float _dataMax;
    84116    float _nzero_min;
    85     int _numAxis;       // same as _shape if _rank == 1
    86     int *_axisLen;      // number of points on each axis
    87     float* _data;
     117    int _numAxis;       ///< same as _shape if _rank == 1
     118    int *_axisLen;      ///< number of points on each axis
     119    float *_data;
    88120
    89     int _n;             // number of points in the position array
    90     int _rank;          // number of dimensions in each item
    91     int _shape;         // array of the extents of each dimension
    92     float* _positions;  // array holding the x,y,z coord of each point
    93     float* _delta;      // array holding deltas of the uniform mesh
    94     float* _max;        // array hodling coord of most distant pt from origin
    95     float* _origin;     // array holding coord of origin
     121    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
    96128
    97129    Object _dxobj;
    98 
    99     void __findPosMax();
    100     void __collectDataStats();
    101     void __getInterpPos();
    102     void __getInterpData();
    103 
    104 
    105130};
    106131
    107 } // namespace Rappture
     132}
    108133
    109134#endif
  • trunk/packages/vizservers/nanovis/TransferFunction.h

    r2831 r2844  
    7474
    7575private:
    76    int _size;                   //the resolution of the color map, how many
    77                                 //(RGBA) quadraples
    78     float* _data;
    79     Texture1D* _tex;            //the texture storing the colors
     76    /// the resolution of the color map, how many (RGBA) quadraples
     77    int _size;
     78    float *_data;
     79    Texture1D *_tex;    ///< the texture storing the colors
    8080    const char *_name;
    81     GLuint _id;                 //OpenGL's texture identifier
     81    GLuint _id;         ///< OpenGL texture identifier
    8282};
    8383
  • trunk/packages/vizservers/nanovis/Volume.cpp

    r2816 r2844  
    1414 * ======================================================================
    1515 */
    16 
    1716#include <memory.h>
    1817#include <assert.h>
     18
    1919#include "Volume.h"
    2020#include "Trace.h"
     
    2626Volume::Volume(float x, float y, float z,
    2727               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),
    2939    _tfPtr(NULL),
    3040    _specular(6.),              // default value
     
    3242    _opacity_scale(10.),        // default value
    3343    _name(NULL),
     44    _data(NULL),
    3445    _n_components(n),
    3546    _nonzero_min(nz_min),
    36     _pointsetIndex(-1),
     47    _tex(NULL),
     48    _location(x, y, z),
    3749    _n_slices(512),             // default value
    3850    _enabled(true),
    39     //n_slice(256),             // default value
    4051    _data_enabled(true),        // default value
    4152    _outline_enabled(true),     // default value
    42     _outline_color(1.,1.,1.),   // default value
     53    _outline_color(1., 1., 1.), // default value
    4354    _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)
    4956{
    5057    _tex = new Texture3D(w, h, d, GL_FLOAT, GL_LINEAR, n);
     
    7178    aspect_ratio_depth =  s * _tex->aspect_ratio_depth;
    7279
    73     _location = Vector3(x, y, z);
    74 
    7580    //Add cut planes. We create 3 default cut planes facing x, y, z directions.
    7681    //The default location of cut plane is in the middle of the data.
     
    9095Volume::~Volume()
    9196{
    92     if (_pointsetIndex != -1) {
     97    if (pointsetIndex != -1) {
    9398        // TBD...
    9499    }
    95100
    96101    delete [] _data;
    97 
    98102    delete _tex;
    99103}
  • trunk/packages/vizservers/nanovis/Volume.h

    r2816 r2844  
    1414 * ======================================================================
    1515 */
    16 
    17 #ifndef _VOLUME_H_
    18 #define _VOLUME_H_
     16#ifndef VOLUME_H
     17#define VOLUME_H
    1918
    2019#include <string>
    2120#include <vector>
     21
     22#include <R2/R2Object.h>
    2223
    2324#include "define.h"
     
    2627#include "Vector3.h"
    2728#include "AxisRange.h"
    28 #include "R2/R2Object.h"
    2929#include "TransferFunction.h"
    3030
    3131struct CutPlane {
    32     int orient;                 // orientation - 1: xy slice, 2: yz slice, 3:
    33                                 // xz slice
    34     float offset;               // normalized offset [0,1] in the volume
     32    /// orientation - 1: xy slice, 2: yz slice, 3: xz slice
     33    int orient;
     34    float offset;       ///< normalized offset [0,1] in the volume
    3535    bool enabled;
    3636
     
    3838        orient(_orient),
    3939        offset(_offset),
    40         enabled(true)
     40        enabled(true)
    4141    {
    4242    }
     
    4747class Volume
    4848{
     49public:
     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
    49270protected:
    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
    60286    const char *_name;
    61287    Vector3 _physical_min;
     
    67293    double _nonzero_min;
    68294
    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
    74298
    75299    Vector3 _location;
    76300
    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;
    80306    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
    90311    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 points
    101                                 // in each direction.
    102     int height;                 // It is different from the size of the volume
    103                                 // object drawn on screen.
    104     int depth;                  // Width, height and depth together determing
    105                                 // the proprotion of the volume ONLY.
    106     float size;                 // This is the scaling factor that will size
    107                                 // the volume on screen.  A render program
    108                                 // drawing different objects, always knows how
    109                                 // large an object is in relation to other
    110                                 // objects. This size is provided by the
    111                                 // 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 volume
    166 
    167     //methods related to cutplanes
    168     int add_cutplane(int _orientation, float _location); // add a plane and
    169                                                          // returns its index
    170     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 volume
    175     bool cutplane_is_enabled(int index); //check if a cutplane is enabled
    176 
    177     //methods related to shading. These parameters are per volume
    178     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 displayed
    218                                                // on an axis
    219     std::string label[3];       // the labels along each axis 0:x , 1:y, 2:z
    220 
    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     }
    231312};
    232313
     
    258339}
    259340
    260 inline CutPlane*
     341inline CutPlane *
    261342Volume::get_cutplane(int index)
    262343{
     
    272353
    273354inline bool
    274 Volume::cutplane_is_enabled(int index)
     355Volume::cutplane_is_enabled(int index) const
    275356{
    276357    //assert(index < plane.size());
     
    290371Volume::set_outline_color(float *rgb)
    291372{
    292     _outline_color = Color(rgb[0],rgb[1],rgb[2]);
     373    _outline_color = Color(rgb[0], rgb[1], rgb[2]);
    293374}
    294375
     
    296377Volume::get_outline_color(float *rgb)
    297378{
    298     _outline_color.GetRGB(rgb);
     379    _outline_color.getRGB(rgb);
    299380}
    300381
     
    322403}
    323404
    324 inline Vector3&
    325 Volume::getPhysicalBBoxMin()
     405inline const Vector3&
     406Volume::getPhysicalBBoxMin() const
    326407{
    327408    return _physical_min;
    328409}
    329410
    330 inline Vector3&
    331 Volume::getPhysicalBBoxMax()
     411inline const Vector3&
     412Volume::getPhysicalBBoxMax() const
    332413{
    333414    return _physical_max;
  • trunk/packages/vizservers/nanovis/ZincBlendeVolume.cpp

    r2827 r2844  
    1717
    1818#include <assert.h>
     19
    1920#include "ZincBlendeVolume.h"
    2021
    2122ZincBlendeVolume::ZincBlendeVolume(float x, float y, float z,
    2223                                   int w, int h, int d, float s, int n,
    23                                    float* dataVolumeA, float* dataVolumeB,
     24                                   float *dataVolumeA, float *dataVolumeB,
    2425                                   double v0, double v1, double non_zeromin,
    2526                                   const Vector3& cellSize) :
     
    3536
    3637    //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);
    3839    assert(secondTex);
    3940    secondTex->initialize(dataVolumeB);
     
    4546{
    4647    // This data will be deleted in a destrutor of Volume class
    47     //if(zincblende_tex[0])
     48    //if (zincblende_tex[0])
    4849    //  delete zincblende_tex[0];
    49     if(zincblende_tex[1])
     50    if (zincblende_tex[1])
    5051        delete zincblende_tex[1];
    5152}
  • trunk/packages/vizservers/nanovis/ZincBlendeVolume.h

    r2798 r2844  
    1515 * ======================================================================
    1616 */
    17 
    1817#ifndef _ZINCBLENDE_VOLUME_H_
    1918#define _ZINCBLENDE_VOLUME_H_
    20 
    2119
    2220#include "Volume.h"
     
    2523{
    2624public:
    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);
    2929
     30    virtual ~ZincBlendeVolume();
    3031
    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
    3734};
    3835
  • trunk/packages/vizservers/nanovis/dxReaderCommon.cpp

    r2798 r2844  
    77
    88float *
    9 merge(float* scalar, float* gradient, int size)
     9merge(float *scalar, float *gradient, int size)
    1010{
    11     float* data = (float*) malloc(sizeof(float) * 4 * size);
     11    float *data = (float *)malloc(sizeof(float) * 4 * size);
    1212
    13     Vector3* g = (Vector3*) gradient;
     13    Vector3 *g = (Vector3 *)gradient;
    1414
    1515    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;
    2121    }
    2222    return data;
     
    2424
    2525void
    26 normalizeScalar(float* fdata, int count, float min, float max)
     26normalizeScalar(float *fdata, int count, float min, float max)
    2727{
    2828    float v = max - min;
     
    3030        for (int i = 0; i < count; ++i) {
    3131            fdata[i] = fdata[i] / v;
    32     }
     32        }
    3333    }
    3434}
    3535
    36 float*
    37 computeGradient(float* fdata, int width, int height, int depth,
    38         float min, float max)
     36float *
     37computeGradient(float *fdata, int width, int height, int depth,
     38                float min, float max)
    3939{
    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));
    4444    int sizes[3] = { width, height, depth };
    4545    computeGradients(tempGradients, fdata, sizes, DATRAW_FLOAT);
     
    4747    quantizeGradients(tempGradients, gradients, sizes, DATRAW_FLOAT);
    4848    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);
    5050    return data;
    5151}
    5252
    5353void
    54 computeSimpleGradient(float* data, int nx, int ny, int nz)
     54computeSimpleGradient(float *data, int nx, int ny, int nz)
    5555{
    5656    // Compute the gradient of this data.  BE CAREFUL: center
    5757    // calculation on each node to avoid skew in either direction.
    5858    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++) {
    6262                // gradient in x-direction
    63                
    64                 // INSOO -teST
    6563                double valm1 = (ix == 0) ? 0.0 : data[ngen - 4];
    6664                double valp1 = (ix == nx-1) ? 0.0 : data[ngen + 4];
    67                 if (valm1 < 0 || valp1 < 0) {
     65                if (valm1 < 0.0 || valp1 < 0.0) {
    6866                    data[ngen+1] = 0.0;
    6967                } else {
    70                     data[ngen+1] = valp1-valm1; // assume dx=1                  // ISO
    71                     //data[ngen+1] = ((valp1-valm1) + 1) *  0.5; // assume dx=1
     68                    data[ngen+1] = valp1-valm1; // assume dx=1
     69                    //data[ngen+1] = ((valp1-valm1) + 1.0) * 0.5; // assume dx=1 (ISO)
    7270                }
    7371
    7472                // 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) {
    7876                    data[ngen+2] = 0.0;
    7977                } else {
    80                     data[ngen+2] = valp1-valm1; // assume dx=1
    81                     //data[ngen+2] = ((valp1-valm1) + 1) *  0.5; // assume dy=1 // ISO
     78                    data[ngen+2] = valp1-valm1; // assume dy=1
     79                    //data[ngen+2] = ((valp1-valm1) + .01) * 0.5; // assume dy=1 (ISO)
    8280                }
    8381
    8482                // 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) {
    8886                    data[ngen+3] = 0.0;
    8987                } else {
    90                     data[ngen+3] = valp1-valm1; // assume dx=1
    91                     //data[ngen+3] = ((valp1-valm1) + 1.0) * 0.5; // assume dz=1 //ISO
     88                    data[ngen+3] = valp1-valm1; // assume dz=1
     89                    //data[ngen+3] = ((valp1-valm1) + 1.0) * 0.5; // assume dz=1 (ISO)
    9290                }
    9391
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrMatrix4x4f.h

    r2842 r2844  
    33#define VRMATRIX4X4_H
    44
     5#include <memory.h>
     6
    57#include <vrmath/vrLinmath.h>
    68#include <vrmath/vrVector3f.h>
    79#include <vrmath/vrRotation.h>
    8 #include <memory.h>
    910
    1011class vrMatrix4x4f
     
    121122}
    122123
    123 
    124124inline void vrMatrix4x4f::getTranslation(vrVector3f& translation)
    125125{
    126     translation.set(_data[12],_data[13], _data[14]);
     126    translation.set(_data[12], _data[13], _data[14]);
    127127}
    128128
    129 inline void vrMatrix4x4f::makeTRS(const vrVector3f& translation, const vrRotation& rotation, const vrVector3f& scale)
     129inline void vrMatrix4x4f::makeTRS(const vrVector3f& translation,
     130                                  const vrRotation& rotation,
     131                                  const vrVector3f& scale)
    130132{
    131133    vrMatrix4x4f mat;
     
    137139}
    138140
    139 inline void vrMatrix4x4f::makeTR(const vrVector3f& translation, const vrRotation& rotation)
     141inline void vrMatrix4x4f::makeTR(const vrVector3f& translation,
     142                                 const vrRotation& rotation)
    140143{
    141144    makeRotation(rotation);
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrRotation.h

    r2842 r2844  
    99
    1010/**
    11  * Represents an axis/angle rotation
     11 * Represents an axis/angle rotation (angle in radians)
    1212 */
    1313class vrRotation
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrVector2f.h

    r2841 r2844  
    33#define VRVECTOR2F_H
    44
    5 #include <vrmath/vrLinmath.h>
    6 
    75#include <cstdlib>
    86#include <cmath>
     7
     8#include <vrmath/vrLinmath.h>
    99
    1010class vrVector2f
  • trunk/packages/vizservers/nanovis/vrmath/vrMatrix4x4f.cpp

    r2842 r2844  
    4444    }
    4545
    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();
    4749    float invLen = 1.0f / sqrt(xAxis * xAxis + yAxis * yAxis + zAxis * zAxis);
    4850    float cosine = cos(rotation.getAngle());
Note: See TracChangeset for help on using the changeset viewer.