Equalizer  1.2.1
rawVolModel.h
00001 
00002 /* Copyright (c) 2007       Maxim Makhinya
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are met:
00006  *
00007  * - Redistributions of source code must retain the above copyright notice, this
00008  *   list of conditions and the following disclaimer.
00009  * - Redistributions in binary form must reproduce the above copyright notice,
00010  *   this list of conditions and the following disclaimer in the documentation
00011  *   and/or other materials provided with the distribution.
00012  * - Neither the name of Eyescale Software GmbH nor the names of its
00013  *   contributors may be used to endorse or promote products derived from this
00014  *   software without specific prior written permission.
00015  *
00016  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00019  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00020  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00021  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00022  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00023  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00024  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00025  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00026  * POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00029 #ifndef EVOLVE_RAW_VOL_MODEL_H
00030 #define EVOLVE_RAW_VOL_MODEL_H
00031 
00032 #include <eq/eq.h>
00033 
00034 namespace eVolve
00035 {
00036 
00052     struct DataInTextureDimensions
00053     {
00054         float W;    
00055         float H;    
00056         float D;    
00057         float Do;   
00058         float Db;   
00059     };
00060 
00063     struct VolumeScaling
00064     {
00065         float W;    
00066         float H;    
00067         float D;    
00068     };
00069 
00070     struct VolumeInfo
00071     {
00072         GLuint                  volume;     
00073         GLuint                  preint;     
00074         VolumeScaling           volScaling; 
00075         VolumeScaling           voxelSize;  
00076         DataInTextureDimensions TD; 
00077         bool                    hasDerivatives; 
00078     };
00079 
00081     class RawVolumeModel
00082     {
00083     public:
00084         RawVolumeModel( const std::string& filename );
00085 
00086         bool loadHeader( const float brightness, const float alpha );
00087 
00088         bool getVolumeInfo( VolumeInfo& info, const eq::Range& range );
00089 
00090         void releaseVolumeInfo( const eq::Range& range );
00091 
00092         const std::string&   getFileName()      const { return _filename;    };
00093               uint32_t       getResolution()    const { return _resolution;  };
00094         const VolumeScaling& getVolumeScaling() const { return _volScaling;  };
00095 
00096         void glewSetContext( const GLEWContext* context )
00097             { _glewContext = context; }
00098 
00099         const GLEWContext* glewGetContext() const { return _glewContext; }
00100 
00101     protected:
00102 
00103         bool _createVolumeTexture(    GLuint&                  volume,
00104                                       DataInTextureDimensions& TD,
00105                                 const eq::Range&               range );
00106 
00107     private:
00108         bool _lFailed( char* msg )
00109             { EQERROR << msg << std::endl; return false; }
00110 
00111         struct VolumePart
00112         {
00113             GLuint                  volume; 
00114             DataInTextureDimensions TD;     
00115         };
00116 
00117         stde::hash_map< int32_t, VolumePart > _volumeHash; 
00118 
00119         bool         _headerLoaded;     
00120         std::string  _filename;         
00121 
00122         GLuint       _preintName;       
00123 
00124         uint32_t     _w;                
00125         uint32_t     _h;                
00126         uint32_t     _d;                
00127         uint32_t     _tW;               
00128         uint32_t     _tH;               
00129         uint32_t     _tD;               
00130         uint32_t     _resolution;       
00131 
00132         VolumeScaling _volScaling;      
00133 
00134         std::vector< uint8_t >  _TF;    
00135 
00136         bool _hasDerivatives;           
00137 
00138         const GLEWContext*   _glewContext;    
00139     };
00140 
00141 }
00142 
00143 #endif // EVOLVE_RAW_VOL_MODEL_H
Generated on Fri Jun 8 2012 15:44:32 for Equalizer 1.2.1 by  doxygen 1.8.0