00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00014 #define VIEWING_MODE_ORTHO 0
00015
00017 #define VIEWING_MODE_PERSPECTIVE 1
00018
00020 #define XDIR 0
00021
00022 #define YDIR 1
00023
00024 #define ZDIR 2
00025
00026 #define WDIR 3
00027
00029
00033 #define THRESHOLD_RUNLENGTH 0.05
00034
00037
00042 #define MIN_TRANSPARENCY_MAKING_INTERMEDIATE 0.05
00043
00045 #define OPENGL_PLANE_SIZE 140
00046
00047
00048 #define ZOOM_FACTOR 250
00049
00050 #ifndef _VUVOLUMEREGULARUNIMODAL3D1B1VALSHEARWARP_H_
00051 #define _VUVOLUMEREGULARUNIMODAL3D1B1VALSHEARWARP_H_
00052
00053 #include "octree.h"
00054 #include "../intensity.h"
00055 #include "glos.h"
00056 #include <GL/gl.h>
00057 #include <GL/glu.h>
00058 #include "vuSimpleTypes.h"
00059 #include "vuNormalTable.h"
00060 #include "vuVector.h"
00061 #include "vuMatrix.h"
00062
00064
00069 struct RLEvoxel {
00071 byte value;
00073 float red;
00075 float green;
00077 float blue;
00079 float red_shaded;
00081 float green_shaded;
00083 float blue_shaded;
00085 float opacity;
00087 float opacity_corr;
00089 vuVector normal;
00090 };
00091
00093
00098 struct RLEplane {
00100 float dim1_pos,dim2_pos;
00102 dword size;
00104 float scale;
00106 byte *runlength;
00108 RLEvoxel *voxel;
00109 };
00110
00112
00115 struct intermediatePixel {
00117 float red;
00119 float green;
00121 float blue;
00123 float trans;
00125 dword offset;
00126 };
00127
00129 class vu111211A;
00130 typedef vu111211A vuVolumeRegularUnimodal3d1B1ValShearWarp;
00131
00133
00142 class vu111211A : public vu111211
00143 {
00144 public:
00145
00147
00154 vu111211A();
00155
00157
00161 virtual ~vu111211A();
00162
00164
00171 void setCanvasSize(int width, int height);
00172
00174
00181 void setOrthogonalWarpOpenGL(int useOpenGL);
00182
00184
00190 void runlengthEncode();
00191
00193
00196 void removeRunlengthEncoding();
00197
00199
00203 void initFastClassification();
00204
00206
00212 void setSpecular(int spec);
00213
00215
00222 void setViewing(int mode);
00223
00225
00230 void setFastClassification(int fastClass);
00231
00233
00239 int getFastClassification();
00240
00242
00246 void setViewVectors(const vuVector& view,const vuVector& up,const vuVector& right);
00247
00249 void getDimensions(int &x, int &y, int &z);
00251 int getMaxSize(void);
00252
00254
00257 void zoom(float zoomValue);
00258
00260
00264 void classify();
00265
00267
00270 void initOpenGL(void);
00271
00273
00277 void render(void);
00278
00280 virtual bool read(void);
00281
00283 virtual bool readRaw(void);
00284
00286 float getMinEyeDistance(void);
00287
00289
00292 void setEyeDistance(float distance);
00293
00294 private:
00296 void computeMaxSize(void);
00297
00299 void computeNormals(void);
00300
00302 void computeMainViewingDirection(void);
00303
00305 void computePermutationMatrix(void);
00306
00308 void computeViewMatrix(void);
00309
00311 void computeEyePoint(void);
00312
00314 void computeRunlengthSizes(void);
00315
00317 void computeShearAndWarpFactorsOrtho(void);
00318
00320 void shearOrtho(void);
00321
00323
00326 float computeZNormalizedViewingVectorLength(void);
00327
00329 void resetIntermediateImage(int intermediateSize);
00330
00332 void preClassification(RLEplane current, float viewVectorLength);
00333
00335 void initRunPtr1(RLEplane current, int &volumeIndex, int &voxelPtr1, int &runPtr1, byte &state1);
00336
00338 void skipZeroLengthRuns(RLEplane slice, int &runPtr, byte &count, byte &state);
00339
00341 int skipTransparentVoxels(RLEplane slice,
00342 int runPtr1, byte &count1,
00343 int runPtr2, byte &count2,
00344 int &add,
00345 int intermediateWidth, int &pos);
00346
00348 void interpolatePixel(RLEplane slice,
00349 intermediatePixel &pixel,
00350 float w1, float w2, float w3, float w4, int volumeIndex,
00351 int &voxelPtr1, int runPtr1, int count1, int state1,
00352 int &voxelPtr2, int runPtr2, int count2, int state2);
00353
00355 void skipOpaquePixel(byte state1, int &voxelPtr1, byte state2, int &voxelPtr2);
00356
00358 void volumeNext(RLEplane slice, int &volumeIndex, int &add,
00359 int intermediateWidth, int &pos,
00360 int &runPtr1, byte &count1, byte &state1,
00361 int &runPtr2, byte &count2, byte &state2);
00362
00364 void computeInvWarpOrtho(void);
00365
00367 void warpOrthoInv(float x, float y, float &x_result, float &y_result);
00368
00370 void warpOrtho();
00371
00373 void makeIntermediateImageOrtho(void);
00374
00376 void changeFormatIntermediate(void);
00377
00379 void drawWarpOpenGL(void);
00380
00382 byte getSample(dword x, dword y, dword z);
00383
00385 void makeIntermediateImageOrthoFastClass(void);
00386
00388 void computeShearPerspective(void);
00389
00391 void computeWarpPerspective(void);
00392
00394
00400 void computePlanePositionScale(float &pos_i, float &pos_j, float &scale, int plane);
00401
00403 void shearPerspective(void);
00404
00406
00414 void warpPerspectiveInv(float x, float y, float &x_result, float &y_result);
00415
00417 void warpPerspective(void);
00418
00420 void makeIntermediateImagePerspective(void);
00421
00423 void drawOpenGL(void);
00424
00426 void createGLImage(void);
00427
00428 private:
00430 float* m_Normals;
00431
00433 vuVector m_View;
00434
00436 vuVector m_Up;
00437
00439 vuVector m_Right;
00440
00442
00447 vuMatrix viewMatrix;
00448
00450
00455 vuMatrix permMatrix;
00456
00458
00462 vuMatrix worldMatrix;
00463
00465
00469 vuMatrix shearMatrix;
00470
00472
00476 vuMatrix warpMatrix;
00477
00479
00485 vuMatrix invWarpMatrix;
00486
00489
00492 vuMatrix projMatrix;
00493
00495
00498 vuMatrix invWorldMatrix;
00499
00501 float invWarpOrtho00;
00503 float invWarpOrtho01;
00505 float invWarpOrtho10;
00507 float invWarpOrtho11;
00508
00510 vuVector eye_o;
00512 vuVector eye_s;
00513
00515 int mainViewingDir;
00516
00518
00521 int canvasWidth;
00523
00526 int canvasHeight;
00527
00529 GLuint m_GLShearWarp;
00530
00532 int viewingMode;
00534 int specular;
00536 int fastClassification;
00538 int orthoWarpOpenGL;
00539
00541 RLEplane* dataX;
00543 RLEplane* dataY;
00545 RLEplane* dataZ;
00546
00548
00551 RLEplane* curr;
00552
00554
00558 byte direction;
00559
00561
00563 dword maxSize;
00564
00566
00568 dword volumeDepth;
00570
00572 dword volumeWidth;
00574
00576 dword volumeHeight;
00577
00579
00582 double si;
00584
00587 double sj;
00588
00591 float ti;
00594 float tj;
00595
00597
00599 intermediatePixel* intermediate;
00600
00601
00602 float eye_distance;
00603
00605
00608 float scale_total;
00609
00611 float zoomValue;
00612
00614 GLubyte *glImage;
00615
00617 int glImageWidth;
00619 int glImageHeight;
00620
00622 FastClassification *fastClassificationObj;
00623 };
00624
00625 #endif
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637