00001 #include "StandardFVR.h"
00002 #include "General/vuCamera/vuParallelCamera.h"
00003
00004 using namespace std;
00005
00006 #define MAX_FILTER_WIDTH 6
00007
00008 template <int SIZE>
00009 vu1712_1<SIZE>::vu1712_1()
00010 {
00011 m_Camera = new vuParallelCamera();
00012 m_Camera->setPosition(m_Camera->getLookAtVector() * -1);
00013 m_Camera->init();
00014 }
00015
00016
00017
00018
00019
00020 template <int SIZE>
00021 vu1712_1<SIZE>::~vu1712_1()
00022 {
00023 CHECKNDELETE(m_Camera);
00024 }
00025
00026 template <int SIZE>
00027 bool vu1712_1<SIZE>::read(void)
00028 {
00029 if (m_FileName.isEmpty()) return setError("No file name specified.");
00030
00031 FILE *file = fopen(m_FileName,"rb");
00032 if (file != NULL)
00033 {
00034 bool success = readHeader(file);
00035
00036 if (!success) {
00037 fclose(file);
00038 return false;
00039 }
00040
00041 setWrap(MAX_FILTER_WIDTH/2);
00042
00043 m_XSize = m_Dim1Size + m_Wrap * 2;
00044 m_YSize = m_Dim2Size + m_Wrap * 2;
00045 m_ZSize = m_Dim3Size + m_Wrap * 2;
00046
00047 m_Volume = new float[m_XSize * m_YSize * m_ZSize * 2 * SIZE];
00048
00049 success = readData(file, m_Volume,
00050 m_XSize, m_YSize, m_ZSize,
00051 m_Dim1Size, m_Dim2Size, m_Dim3Size);
00052 wrapAndInitialize(1.0);
00053
00054 fclose(file);
00055 return success;
00056 }
00057 else
00058 return setError("Could not open the specified file.");
00059 }
00060
00061
00062
00063
00064
00065 template <int SIZE>
00066 bool vu1712_1<SIZE>::write(void)
00067 {
00068 if (m_FileName.isEmpty()) return setError("No file name specified.");
00069
00070 FILE *file = fopen(m_FileName,"wb");
00071 if (file != NULL)
00072 {
00073 bool success = writeHeader(file);
00074
00075 if (success) {
00076 writeData(file, m_Volume,
00077 m_XSize, m_YSize, m_ZSize,
00078 m_Dim1Size, m_Dim2Size, m_Dim3Size);
00079 }
00080
00081 fclose(file);
00082 return success;
00083 }
00084 else
00085 return setError("Could not open the specified file.");
00086 }
00087
00088 template <int SIZE>
00089 void vu1712_1<SIZE>::render()
00090 {
00091 vuFourierVolume<SIZE>::setCamera(m_Camera);
00092 vuFourierVolume<SIZE>::render();
00093 }
00094
00095 template <int SIZE>
00096 void vu1712_1<SIZE>::setViewVectors(const vuVector& lookAt,
00097 const vuVector& up,
00098 const vuVector& right)
00099 {
00100 vuFourierVolume<SIZE>::setViewVectors(lookAt, up, right);
00101 }
00102
00103
00104 template <int SIZE>
00105 void vu1712_1<SIZE>::glResize(dword width, dword height)
00106 {
00107 vuFourierVolume<SIZE>::glResize(width, height);
00108 if (m_Camera != NULL) {
00109 m_Camera->setWidth(width);
00110 m_Camera->setHeight(height);
00111 m_Camera->init();
00112 }
00113 }
00114
00115 template <int SIZE>
00116 void vu1712_1<SIZE>::setIsReRendering(bool flag)
00117 {
00118 vuFourierVolume<SIZE>::setIsReRendering(flag);
00119 }
00120
00121 template <int SIZE>
00122 bool vu1712_1<SIZE>::getIsReRendering()
00123 {
00124 return vuFourierVolume<SIZE>::getIsReRendering();
00125 }