00001
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00019
00020
00021 #include <vpgraphicobj.h>
00022 #include <vptable.h>
00023 #include <vpview.h>
00024 #include <vpraysegment.h>
00025
00026
00027
00028 #ifndef __VPRAYCASTING_H
00029 #define __VPRAYCASTING_H
00030
00031
00032 #include <vpscene.h>
00033
00034
00035 #define NOTIO 0
00036 #define PIN 1
00037 #define POUT 2
00038 #define PFRONT 0
00039 #define PBACK 1
00040 #define PTOP 2
00041 #define PBOTTOM 3
00042 #define PLEFT 4
00043 #define PRIGHT 5
00044
00045 #define NOCUTTINGTOOL 10
00046 #define CVP 11
00047 #define OBLIQUESLICE 12
00048 #define ONECUTPLANE 13
00049 #define TWOCUTPLANES 14
00050 #define CUBEBYINCLUSION 15
00051 #define CUBEBYEXCLUSION 16
00052 #define SPHEREBYINCLUSION 17
00053 #define SPHEREBYEXCLUSION 18
00054 #define TWOCUTPLANESINCLUSIONOPAC 19
00055
00056 #define LINEAROPACITY 50
00057 #define LEVOYSURFACEOPACITY 51
00058
00059 #define EPSILON 0.0001
00060
00061
00062
00063
00064
00065
00066
00067
00068
00070
00071
00072
00074
00075 class VPRayCasting {
00076 private:
00077 VPRaySegment raySegment;
00078 int virtualYDimension;
00079
00080 int endOfSBand;
00081 int endOfTBand;
00082 float dFront,
00083 dTop,
00084 dLeft,
00085 dBack,
00086 dBottom,
00087 dRight;
00088 float sampleStep;
00089 float ambientLight;
00090 float diffuseLight;
00091 int shadingMethod;
00092 int specularExponent;
00093 bool specular;
00094 VPLight *light;
00095 VPPoint3D volumeScale;
00096 bool lightVolumeComputation;
00097 int negativeLightContribution;
00098 int integrationType;
00099 int firstSlice, lastSlice;
00100 int valueCVP;
00101
00102
00103 float attenuate;
00104 float luminance;
00105 float alpha;
00106 float lum,a,at;
00107 float gm;
00108 int ivalue;
00109 float levWidth, levThreshold;
00110 unsigned char alphaTable[65536];
00111 unsigned char luminanceTable[65536];
00112 unsigned char RGBtable[3*65536];
00113
00114
00115 int typeOfCuttingTool;
00116 int typeOfOpacityFunction;
00117 int backCuttingPlane;
00118 int distanceObliquePlane;
00119 int initialValueForLinearOpacity;
00120 VPPoint3D P1,P2,P3;
00121 VPPoint3D backP1,backP2,backP3;
00122 VPPoint3D cameraLocation;
00123 VPPoint3D p1Parallelepiped, p2Parallelepiped;
00124
00125
00126 public:
00127 VPRayCasting();
00128 void vpMakeRegistration();
00129 void vpSetDefaultParameters (VPGraphicObj *volume, VPCamera *camera);
00130 void vpRenderMonoGray(VPScene *s, VPCamera *c, int visualizationType, int opacityComputation, unsigned int **image);
00131 void vpRenderLivroMonoGray(VPScene *s, VPCamera *c, int visualizationType, int opacityComputation, unsigned int **image);
00132 void vpRenderMultiModal(VPScene *s, VPCamera *c, int opacityComputation, unsigned int ***image);
00133 void vpRenderLivroMultiModal(VPScene *s, VPCamera *c, int opacityComputation, unsigned int ***image);
00134 void vpRenderMonoColor(VPScene *s, VPCamera *c, int opacityComputation, unsigned int ***image);
00135 void vpRenderLivroMonoColor(VPScene *s, VPCamera *c, int opacityComputation, unsigned int ***image);
00136 void vpRenderNoLightMonoGray(VPScene *s, VPCamera *c, unsigned int **image);
00137 void vpRenderLivroMultiInnerStructures(VPScene *s, VPCamera *c, int opacityComputation, unsigned int ***image);
00138 void vpRenderLivroInnerStructures(VPScene *s, VPCamera *c, int opacityComputation, unsigned int **image);
00139 void vpRenderLivroMonoColorInnerStructures(VPScene *s, VPCamera *c, int opacityComputation, unsigned int ***image);
00140 void vpRenderLivro3VolMultiModal(VPScene *s, VPCamera *c, int opacityComputation, unsigned int ***image);
00141 void vpRenderMIP(VPScene *s, VPCamera *c, unsigned int **image);
00142 void vpRenderLivroMIP(VPScene *s, VPCamera *c, unsigned int **image);
00143 void vpRenderSubVolume();
00144 void vpRenderMultiModal();
00145 void vpRenderSideBySide();
00146 void vpSetVariables(VPCamera *camera, VPVector3D &projectionDirection,
00147 VPPoint3D &minPlaneProjection, VPPoint3D &volumeDimension,
00148 short int planes[], int &finalLineValue, int &finalColumnValue,
00149 VPVector3D &deltaX, VPVector3D &deltaY, VPVector3D &deltaZ,
00150 VPGraphicObj *volume);
00151 void vpSetCameraDefault(VPCamera *camera, VPGraphicObj *volume);
00152 void vpSetLightDefault(VPLight *light, VPCamera *camera);
00153 void vpFindIntersectionCandidatePlanes(short int planes[], VPVector3D dir);
00154 bool vpFindIntersectionPoints(short int planes[], VPPoint3D maxB, VPPoint3D origin,
00155 VPVector3D dir, VPPoint3D &in, VPPoint3D &out,
00156 float &tIn, float &tOut);
00157 bool vpFindSphereIntersectionPoints(VPPoint3D origin, VPPoint3D center, float ray,
00158 VPVector3D dir, VPPoint3D &point);
00159 void vpBAKA(VPVector3D &gradient, int i, int j, int k);
00160 float vpTrilinearInterpolation(int i, int j, int k,
00161 VPGraphicObj *volume, VPPoint3D p);
00162 void vpTriLinearGouraudInterpolation(int i, int j, int k,
00163 VPGraphicObj *volume, VPPoint3D p,
00164 float &color, float &light, bool &interpolate);
00165 void vpTriLinearInterpolationAndGradientComputation(int i, int j, int k,
00166 VPGraphicObj *volume, VPPoint3D p,
00167 float &color, VPVector3D &g, bool &interpolate);
00168 void vpOtherSampleColorAndShading(int i, int j, int k,
00169 VPGraphicObj *volume,
00170 VPPoint3D p, float previousIlight,
00171 VPLight *l, float &color, float &Ilight);
00172 void vpGradientComputation(int i, int j, int k, VPGraphicObj *volume,
00173 VPPoint3D p, VPVector3D &g, bool &interpolate);
00174 void vpGradient(int i, int j, int k, VPGraphicObj *volume,
00175 VPVector3D &g);
00176
00177 float vpProcessILight(VPVector3D g, VPLight *l);
00178 float vpProcessSpecularILight(VPVector3D g, VPLight *l, VPVector3D o);
00179 void vpSetEndSBand(VPPoint3D sb, VPGraphicObj *volume, int vt);
00180 int vpGetEndSBand();
00181 void vpSetEndTBand(VPPoint3D tb, VPGraphicObj *volume, int vt);
00182 int vpGetEndTBand();
00183 void vpSetSampleStep(float s);
00184 float vpGetSampleStep();
00185 void vpSetAmbientLight(float a);
00186 float vpGetAmbientLight();
00187 void vpSetDiffuseLight(float d);
00188 float vpGetDiffuseLight();
00189 void vpSetSpecularExponent(int s);
00190 int vpGetSpecularExponent();
00191 void vpSetSpecular(bool s);
00192 bool vpGetSpecular();
00193 void vpSetShadingMethod(int sm);
00194 int vpGetShadingMethod();
00195 void vpSetLightDirection(VPVector3D ld);
00196 VPVector3D vpGetLightDirection();
00197 void vpSetTypeOfCuttingTool(int t);
00198 int vpGetTypeOfCuttingTool();
00199
00200
00201 void vpDefineA(VPPoint3D &pIn, VPPoint3D pOut, VPPoint3D p1, VPVector3D deltaZ, float yCorrection, VPVector3D plane1Normal, VPGraphicObj *volume, VPPoint3D volumeDimension, float d);
00202 void vpDefineB(int i, int j, int k, float &alpha, VPGraphicObj *volume, VPPoint3D &pIn, int depth, int &ivalue);
00203
00204
00205 void Classify (float *intensity, float *gm, float *luminance, float *alpha);
00206 void ClassifyColor (float *intensity, float *gm, float *r, float *g, float *b, float *alpha);
00207 void SetClassificationTable (void);
00208 void SetClassificationTable2 (void);
00209 void SetClassificationTable3 (void);
00210 float Shade (VPVector3D gradient);
00211 float ShadeSpecular (VPVector3D gradient, VPVector3D obsPoint);
00212 void Gradient (int i, int j, int k, VPVector3D &gradient, float *gm, VPGraphicObj *volume);
00213 void GradientSobel (int i, int j, int k, VPVector3D &gradient, float *gm, VPGraphicObj *volume);
00214 void GradientBaka (int i, int j, int k, VPVector3D &gradient, float *gm, VPGraphicObj *volume);
00215 };
00216
00217
00218 #endif // __VPRAYCASTING_H