rawVolModel.h

00001 /* Copyright (c) 2007       Maxim Makhinya
00002  *
00003  * This library is free software; you can redistribute it and/or modify it under
00004  * the terms of the GNU Lesser General Public License version 2.1 as published
00005  * by the Free Software Foundation.
00006  *  
00007  * This library is distributed in the hope that it will be useful, but WITHOUT
00008  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00009  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00010  * details.
00011  * 
00012  * You should have received a copy of the GNU Lesser General Public License
00013  * along with this library; if not, write to the Free Software Foundation, Inc.,
00014  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00015  */
00016 
00017 #ifndef EVOLVE_RAW_VOL_MODEL_H
00018 #define EVOLVE_RAW_VOL_MODEL_H
00019 
00020 #include <eq/eq.h>
00021 
00022 namespace eVolve
00023 {
00024 
00040     struct DataInTextureDimensions
00041     {
00042         float W;    
00043         float H;    
00044         float D;    
00045         float Do;   
00046         float Db;   
00047     };
00048 
00051     struct VolumeScaling
00052     {
00053         float W;    
00054         float H;    
00055         float D;    
00056     };
00057 
00058     struct VolumeInfo
00059     {
00060         GLuint                  volume;     
00061         GLuint                  preint;     
00062         VolumeScaling           volScaling; 
00063         DataInTextureDimensions TD; 
00064     };
00065 
00067     class RawVolumeModel
00068     {
00069     public:
00070         RawVolumeModel( const std::string& filename );
00071 
00072         bool loadHeader( const float brightness, const float alpha );
00073 
00074         bool getVolumeInfo( VolumeInfo& info, const eq::Range& range );
00075 
00076         void releaseVolumeInfo( const eq::Range& range );
00077 
00078         const std::string&   getFileName()      const { return _filename;    };
00079               uint32_t       getResolution()    const { return _resolution;  };
00080         const VolumeScaling& getVolumeScaling() const { return _volScaling;  };
00081 
00082         void glewSetContext( GLEWContext* context ) { _glewContext = context; }
00083 
00084         GLEWContext* glewGetContext() { return _glewContext; }
00085 
00086     protected:
00087 
00088         bool _createVolumeTexture(
00089                                       GLuint&                  volume,
00090                                       DataInTextureDimensions& TD,
00091                                 const eq::Range&               range );
00092 
00093     private:
00094         bool _lFailed( char* msg )
00095             { EQERROR << msg << std::endl; return false; }
00096 
00097         struct VolumePart
00098         {
00099             GLuint                  volume; 
00100             DataInTextureDimensions TD;     
00101         };
00102 
00103         stde::hash_map< int32_t, VolumePart > _volumeHash; 
00104 
00105         bool         _headerLoaded;     
00106         std::string  _filename;         
00107 
00108         GLuint       _preintName;       
00109 
00110         uint32_t     _w;                
00111         uint32_t     _h;                
00112         uint32_t     _d;                
00113         uint32_t     _resolution;       
00114 
00115         VolumeScaling _volScaling;      
00116 
00117         std::vector< uint8_t >  _TF;    
00118 
00119         GLEWContext*   _glewContext;    
00120     };
00121 
00122 }
00123 
00124 #endif // EVOLVE_RAW_VOL_MODEL_H
Generated on Mon Aug 10 18:58:41 2009 for Equalizer 0.9 by  doxygen 1.5.8