Ignore:
Timestamp:
May 30, 2009 8:07:17 PM (15 years ago)
Author:
gah
Message:

Fix volume management routines to handle deletion

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/Volume.h

    r1477 r1478  
    2626#include "AxisRange.h"
    2727#include "R2/R2Object.h"
     28#include "TransferFunction.h"
    2829
    2930struct CutPlane{
     
    3839};
    3940
    40 enum {CUBIC, VOLQD, ZINCBLENDE};
    41 
    42 class Volume : public R2Object {
     41class VolumeInterpolator;
     42
     43
     44class Volume {
     45protected:
     46    TransferFunction *_tfPtr;           // This is the designated transfer
     47                                        // to use to render this volume.
     48
     49    float _specular;                    // Specular lighting parameter
     50    float _diffuse;                     // Diffuse lighting parameter
     51    float _opacity_scale;               // The scale multiplied to the opacity
     52                                        // assigned by the transfer function.
     53                                        // Rule of thumb: higher opacity_scale
     54                                        // the object is to appear like
     55                                        // plastic
     56    int _volumeDataID;
     57    Vector3 _physical_min;
     58    Vector3 _physical_max;
     59    float* _data;
     60   
     61    int _n_components;
     62
     63    double _nonzero_min;
     64   
     65    std::vector <CutPlane> _plane; // cut planes
     66
     67    Texture3D* _tex;            // OpenGL texture storing the volume
     68
     69   
     70    int _pointsetIndex;
     71
     72    Vector3 _location;
     73
     74    int _n_slices;              // Number of slices when rendered. The greater
     75                                // the better quality, lower speed.
     76
     77    bool _enabled;
     78
     79    bool _data_enabled;         // show/hide cloud of volume data
     80   
     81    bool _outline_enabled;      // show/hide outline around volume
     82
     83    Color _outline_color;       // color for outline around volume
     84
     85    int _volume_type;           // cubic or zincblende
     86   
     87    int _iso_surface;
     88
    4389public:
    44     int                         _volumeDataID;
     90    enum { CUBIC, VOLQD, ZINCBLENDE };
     91    float aspect_ratio_width;
     92    float aspect_ratio_height;
     93    float aspect_ratio_depth;
     94
     95    NVISid id;                  //OpenGL textue identifier (==tex->id)
    4596
    4697    int width;                  // The resolution of the data (how many points
     
    50101    int depth;                  // Width, height and depth together determing
    51102                                // the proprotion of the volume ONLY.
    52        
    53103    float size;                 // This is the scaling factor that will size
    54104                                // the volume on screen.  A render program
     
    57107                                // objects. This size is provided by the
    58108                                // render engine.
    59     Vector3 _physical_min;
    60     Vector3 _physical_max;
    61109
    62110    AxisRange xAxis, yAxis, zAxis, wAxis;
    63111    static bool update_pending;
    64112    static double valueMin, valueMax;
    65 
    66     int n_components;
    67 
    68     double nonzero_min;
    69    
    70     std::vector <CutPlane> plane; // cut planes
    71 
    72     Texture3D* tex;             // OpenGL texture storing the volume
    73 
    74     float* _data;
    75    
    76     int pointsetIndex;
    77 
    78     Vector3 location;
    79 
    80     bool enabled;
    81 
    82     int n_slice;                // Number of slices when rendered. The greater
    83                                 // the better quality, lower speed.
    84 
    85     float _specular;            // specular lighting parameter
    86     float _diffuse;             // diffuse lighting parameter
    87     float _opacity_scale;       // The scale multiplied to the opacity assigned
    88                                 // by the transfer function.  Rule of thumb:
    89                                 // higher opacity_scale the object is to appear
    90                                 // like plastic
    91    
    92     bool data_enabled;          // show/hide cloud of volume data
    93    
    94     bool outline_enabled;       // show/hide outline around volume
    95 
    96     Color outline_color;        // color for outline around volume
    97 
    98     int volume_type;            // cubic or zincblende
    99    
    100     float aspect_ratio_width;
    101     float aspect_ratio_height;
    102     float aspect_ratio_depth;
    103 
    104     NVISid id;                  //OpenGL textue identifier (==tex->id)
    105 
    106     int iso_surface;
    107113
    108114public :
     
    110116           float size, int n_component, float* data, double vmin, double vmax,
    111117           double nonzero_min);
    112 
    113 protected :
    114     virtual ~Volume();
     118    ~Volume();
    115119       
    116120public :
    117121    void visible(bool value) {
    118         enabled = value;
     122        _enabled = value;
    119123    }
    120124    bool visible(void) {
    121         return enabled;
    122     }
    123     void move(Vector3 _loc) {
    124         location = _loc;
    125     }
    126 
    127     Vector3* get_location();
    128    
    129     void set_isosurface(int iso);
    130     int get_isosurface() const;
    131 
    132     double range_nzero_min() { return nonzero_min; }
    133    
    134     void set_n_slice(int val);  // set number of slices
    135     int get_n_slice();          // return number of slices
    136    
     125        return _enabled;
     126    }
     127    void location(Vector3 loc) {
     128        _location = loc;
     129    }
     130    Vector3 location(void) const {
     131        return _location;
     132    }
     133    int isosurface(void) const {
     134        return _iso_surface;
     135    }
     136    void isosurface(int iso) {
     137        _iso_surface = iso;
     138    }
     139    int n_components(void) {
     140        return _n_components;
     141    }
     142    double nonzero_min(void) {
     143        return _nonzero_min;
     144    }
     145    int volume_type(void) {
     146        return _volume_type;
     147    }
     148    float *data(void) {
     149        return _data;
     150    }
     151    Texture3D *tex(void) {
     152        return _tex;
     153    }
     154
     155    double range_nzero_min() { return _nonzero_min; }
     156   
     157    int n_slices(void) const {
     158        return _n_slices;
     159    }
     160    void n_slices(int n) {
     161        _n_slices = n;
     162    }
     163
    137164    void set_size(float s);     //set the drawing size of volume
    138165
     
    166193        _opacity_scale = value;
    167194    }
    168     void data(bool value) {
    169         data_enabled = value;
    170     }
    171     bool data(void) {
    172         return data_enabled;
     195    void data_enabled(bool value) {
     196        _data_enabled = value;
     197    }
     198    bool data_enabled(void) {
     199        return _data_enabled;
    173200    }
    174201    void outline(bool value) {
    175         outline_enabled = value;
     202        _outline_enabled = value;
    176203    }
    177204    bool outline(void) {
    178         return outline_enabled;
     205        return _outline_enabled;
     206    }
     207    TransferFunction *transferFunction(void) {
     208        return _tfPtr;
     209    }
     210    void transferFunction(TransferFunction *tfPtr) {
     211        _tfPtr = tfPtr;
    179212    }
    180213    void set_outline_color(float* rgb);
     
    189222    Vector3& getPhysicalBBoxMax();
    190223
    191     void setDataID(int id);
    192     int getDataID() const;
     224    void dataID(size_t index) {
     225        _volumeDataID = index;
     226    }
     227    size_t dataID(void) const {
     228        return _volumeDataID;
     229    }
    193230};
    194231
    195 inline Vector3* Volume::get_location() {
    196     return &location;
    197 }
    198232inline
    199 int Volume::add_cutplane(int _orientation, float _location) {
    200     plane.push_back(CutPlane(1, 0.5));
    201     return plane.size() - 1;
     233int Volume::add_cutplane(int orientation, float location) {
     234    _plane.push_back(CutPlane(1, 0.5));
     235    return _plane.size() - 1;
    202236}
    203237
     
    206240{
    207241    //assert(index < plane.size());
    208     plane[index].enabled = true;
     242    _plane[index].enabled = true;
    209243}
    210244inline void
     
    212246{
    213247    //assert(index < plane.size());
    214     plane[index].enabled = false;
     248    _plane[index].enabled = false;
    215249}
    216250
     
    219253{
    220254    //assert(index < plane.size());
    221     plane[index].offset = location;
     255    _plane[index].offset = location;
    222256}
    223257
     
    226260{
    227261    //assert(index < plane.size());
    228     return &plane[index];
     262    return &_plane[index];
    229263}
    230264
     
    232266Volume::get_cutplane_count()
    233267{
    234     return plane.size();
     268    return _plane.size();
    235269}
    236270
     
    239273{
    240274    //assert(index < plane.size());
    241     return plane[index].enabled;
    242 }
    243 
    244 inline void
    245 Volume::set_n_slice(int n)
    246 {
    247     n_slice = n;
    248 }
    249 
    250 inline int
    251 Volume::get_n_slice()
    252 {
    253     return n_slice;
     275    return _plane[index].enabled;
    254276}
    255277
     
    258280{
    259281    size = s;
    260     aspect_ratio_width = s*tex->aspect_ratio_width;
    261     aspect_ratio_height = s*tex->aspect_ratio_height;
    262     aspect_ratio_depth = s*tex->aspect_ratio_depth;
     282    aspect_ratio_width  = s * _tex->aspect_ratio_width;
     283    aspect_ratio_height = s * _tex->aspect_ratio_height;
     284    aspect_ratio_depth  = s * _tex->aspect_ratio_depth;
    263285}
    264286
     
    266288Volume::set_outline_color(float *rgb)
    267289{
    268     outline_color = Color(rgb[0],rgb[1],rgb[2]);
     290    _outline_color = Color(rgb[0],rgb[1],rgb[2]);
    269291}
    270292
     
    272294Volume::get_outline_color(float *rgb)
    273295{
    274     outline_color.GetRGB(rgb);
     296    _outline_color.GetRGB(rgb);
    275297}
    276298
     
    281303}
    282304
    283 inline int
    284 Volume::get_isosurface() const
    285 {
    286     return iso_surface;
    287 }
    288 
    289 inline void
    290 Volume::set_isosurface(int iso)
    291 {
    292     iso_surface = iso;
    293 }
    294305
    295306inline void
     
    322333}
    323334
    324 inline void
    325 Volume::setDataID(int id)
    326 {
    327         _volumeDataID = id;
    328 }
    329 
    330 inline int
    331 Volume::getDataID() const
    332 {
    333         return _volumeDataID;
    334 }
    335335
    336336#endif
Note: See TracChangeset for help on using the changeset viewer.