VolHeader.H

Go to the documentation of this file.
00001 // $Revision: 1.11 $  $Author: schwehr $  $Date: 2006/03/01 00:40:48 $
00002 /*
00003     Copyright (C) 2004  Kurt Schwehr
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 */
00020 
00023 
00024 
00025 #ifndef _VOL_HEADER_H_
00026 #define _VOL_HEADER_H_
00027 
00028 #include <vector>
00029 #include <string>
00030 
00032 uint32_t hton_uint32(const uint32_t value);
00034 uint32_t ntoh_uint32(const uint32_t value);
00035 
00037 float hton_float(const float value);
00039 float ntoh_float(const float value);
00040 
00041 
00052 
00053 class  VolHeader {
00054 public:
00056   VolHeader(const size_t width, const size_t height, const size_t depth);
00057   VolHeader(const size_t width, const size_t height, const size_t depth,
00058             const size_t bitsPerVoxel,
00059             const float scaleX, const float scaleY, const float scaleZ,
00060             const float rotX,const float rotY, const float rotZ);
00061 
00065   VolHeader(const std::string filename, bool &ok);
00066 
00069   size_t write(FILE *outFile);
00070 
00071   uint32_t getMagicNumber() const; 
00072   uint32_t getHeaderLength() const; 
00073   uint32_t getWidth() const; 
00074   uint32_t getHeight() const; 
00075   uint32_t getImages() const; 
00076   uint32_t getBitsPerVoxel() const; 
00077   uint32_t getIndexBits() const; 
00078 
00079   float getScaleX() const; 
00080   float getScaleY() const; 
00081   float getScaleZ() const; 
00082 
00083   float getRotX() const; 
00084   float getRotY() const; 
00085   float getRotZ() const; 
00086 
00088   size_t getDataSize() const;
00089 
00090   //
00091   // WARNING: randomly setting these can do bad, bad things.
00092   //
00093 
00094   void setMagicNumber (const size_t v) {magic_number=v;} 
00095   void setHeaderLength(const size_t v) {header_length=v;} 
00096   void setWidth       (const size_t v) {width=v;} 
00097   void setHeight      (const size_t v) {height=v;} 
00098   void setImages      (const size_t v) {images=v;} 
00099   void setBitsPerVoxel(const size_t v) {bits_per_voxel=v;} 
00100   void setIndexBits   (const size_t v) {index_bits=v;} 
00101 
00102   void setScaleX(const float v) {scaleX=v;} 
00103   void setScaleY(const float v) {scaleY=v;} 
00104   void setScaleZ(const float v) {scaleZ=v;} 
00105 
00106   void setRotX(const float v) {rotX=v;} 
00107   void setRotY(const float v) {rotY=v;} 
00108   void setRotZ(const float v) {rotZ=v;} 
00109 
00110 
00111 
00112   // FIX: can we stuff extra stuff after the basic header?
00114   static size_t requiredSize() {/*assert(52==sizeof(VolHeader));*/return(52);}
00115 
00117   static uint32_t hMagicNum() {return(0x0b7e7759);}
00119   static uint32_t nMagicNum() {return(hton_uint32(hMagicNum()));}
00120 
00121 private:
00122   uint32_t magic_number;  
00123   uint32_t header_length; 
00124   uint32_t width;         
00125   uint32_t height;        
00126   uint32_t images;        
00127   uint32_t bits_per_voxel; 
00128 
00129   uint32_t index_bits;    
00130 
00131   float scaleX, scaleY, scaleZ;
00133   float rotX, rotY, rotZ;
00134 };
00135 
00136 #endif // _VOL_HEADER_H_

Generated on Thu Mar 2 17:55:25 2006 for density by  doxygen 1.4.6