Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MarchingCubes.cpp

Go to the documentation of this file.
00001 #include "MarchingCubes.h"
00002 #include <fstream.h>
00003 #include <math.h>
00004 
00005 // Actual Mode: 3
00006 #define DEBUG_MODE 99
00007 #include "General/vuMarchingCubes/debug.h"
00008 
00009 //----------------------------------------------------------------------------
00010 //------------------------- Static texture variables -------------------------
00011 //----------------------------------------------------------------------------
00012 /*
00013 static float texcoord0[2] = {0.0f, 0.0f};
00014 static float texcoord1[2] = {0.0f, 1.0f};
00015 static float texcoord2[2] = {1.0f, 1.0f};
00016 static float texcoord3[2] = {1.0f, 0.0f};
00017 */
00018 
00019 //----------------------------------------------------------------------------
00020 //------------------------- The default constructor --------------------------
00021 //----------------------------------------------------------------------------
00022 
00023 vu1112211::vu1112211() // {{{
00024 {
00025         DEBUG0("vu1112211::vu1112211()\n");
00026 } // }}}
00027 
00028 //----------------------------------------------------------------------------
00029 //------------------------- The copy constructor -----------------------------
00030 //----------------------------------------------------------------------------
00031 
00032 vu1112211::vu1112211(const vu1112211& inst) : vu111221(inst) // {{{
00033 {
00034         DEBUG0("vu1112211::vu1112211(const vu1112211& inst)\n");
00035 } // }}}
00036 
00037 //----------------------------------------------------------------------------
00038 //------------------------- The destructor -----------------------------------
00039 //----------------------------------------------------------------------------
00040 
00041 vu1112211::~vu1112211() // {{{
00042 {
00043         DEBUG0("vu1112211::~vu1112211()\n");
00044 } // }}}
00045 
00046 //----------------------------------------------------------------------------
00047 //------------------------- The assignment operator --------------------------
00048 //----------------------------------------------------------------------------
00049 
00050 vu1112211& vu1112211::operator=(const vu1112211& rhs)
00051 {
00052         DEBUG0("vu1112211& vu1112211::operator=(const vu1112211& rhs)\n");
00053         if (this != &rhs) {
00054                 vu111221::operator=(rhs);
00055         }
00056         return *this;
00057 }
00058 
00059 //----------------------------------------------------------------------------
00060 //------------------------- public setViewVectors() --------------------------
00061 //----------------------------------------------------------------------------
00062 
00063 /*
00064 void vu1112211::setViewVectors(const vuVector& view,const vuVector& up,const vuVector& right)
00065 {
00066 }
00067 */
00068 
00069 //----------------------------------------------------------------------------
00070 //------------------------- public read() ------------------------------------
00071 //----------------------------------------------------------------------------
00072 
00073 bool vu1112211::read() // {{{
00074 {
00075         DEBUG0("bool vu1112211::read()\n");
00076 
00077         ifstream in;
00078 
00079 #ifdef IS_NOCREATE_NEEDED
00080         in.open(m_FileName, ios::in|ios::binary|ios::nocreate);
00081 #else
00082         // The nocreate is not available on the IRIX boxes that we were compiling
00083         // this code on, so we had to remove this part from
00084         in.open(m_FileName, ios::in|ios::binary);
00085 #endif
00086         DEBUG2("in.is_open() = "<<in.is_open()<<"\n");
00087         if (!in.is_open()) return false;
00088 
00089 #if DEBUG_MODE <= 2
00090 
00091         in.seekg(0, ios::end);
00092         long len_is = in.tellg();
00093         in.seekg(0, ios::beg);
00094 #endif
00095 
00097         char size_buf[6];
00098         in.read(size_buf, 6);
00099         if (in.fail()) return false;
00100         unsigned short* sizes = (unsigned short*)size_buf;
00101         Size(sizes[0], sizes[1], sizes[2]);
00102         DEBUG2("sizes = ("<<sizes[0]<<", "<<sizes[1]<<", "<<sizes[2]<<")\n");
00103 
00105         long page_size = sizes[0]*sizes[1];
00106         long data_size = page_size*sizes[2];
00107 #if DEBUG_MODE <= 2
00108         int len_shld = data_size*2+6; // 6 is the header size.
00109 #endif
00110         DEBUG2("len_shld vs. len_is: " << len_shld << " == " << len_is << "?\n");
00111 
00112         unsigned short buffer[page_size];
00113         long counter = 0;       // countes the number of values, written to _data
00114         StartProgress();
00115         SetProgressText("Reading data:");
00116         do {
00117                 in.read((char*)buffer, page_size*2);
00118                 if (in.fail()) return false;
00119                 for(int i=0; i<page_size; ++i) _data[counter++] = buffer[i];
00120                 DEBUG2("progress: " << (float)counter/(float)data_size*100.0 << "\n");
00121                 UpdateProgress((int)((float)counter/(float)data_size*100.0));
00122         } while (counter < data_size && !in.fail());
00123         EndProgress();
00124 
00125         DEBUG2("data_size vs. counter: " << data_size << " == " << counter << "?\n");
00126 
00127         in.close();
00128 
00129         return true;
00130 } // }}}
00131 
00132 
00133 //----------------------------------------------------------------------------
00134 //------------------------- public render() ----------------------------------
00135 //----------------------------------------------------------------------------
00136 void vu1112211::render(void) // {{{
00137 {
00138         DEBUG0("void vu1112211::render(void)\n");
00139         glRender();
00140 } // }}}
00141 
00142 
00143 // vim:fdm=marker:fdc=3

Generated on Wed Dec 15 21:20:29 2004 for vuVolume by  doxygen 1.3.9.1