00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00059 #ifndef __vtkUnstructuredGridBunykRayCastFunction_h
00060 #define __vtkUnstructuredGridBunykRayCastFunction_h
00061 
00062 #include "vtkUnstructuredGridVolumeRayCastFunction.h"
00063 
00064 class vtkRenderer;
00065 class vtkVolume;
00066 class vtkUnstructuredGridVolumeRayCastMapper;
00067 class vtkMatrix4x4;
00068 class vtkPiecewiseFunction;
00069 class vtkColorTransferFunction;
00070 class vtkUnstructuredGrid;
00071 class vtkIdList;
00072 class vtkDoubleArray;
00073 class vtkDataArray;
00074 
00075 
00076 
00077 
00078 #define VTK_BUNYKRCF_MAX_ARRAYS 10000
00079 #define VTK_BUNYKRCF_ARRAY_SIZE 10000
00080 
00081 class VTK_VOLUMERENDERING_EXPORT vtkUnstructuredGridBunykRayCastFunction : public vtkUnstructuredGridVolumeRayCastFunction
00082 { 
00083 public:
00084   static vtkUnstructuredGridBunykRayCastFunction *New();
00085   vtkTypeMacro(vtkUnstructuredGridBunykRayCastFunction,vtkUnstructuredGridVolumeRayCastFunction);
00086   virtual void PrintSelf(ostream& os, vtkIndent indent);
00087 
00088 
00090   virtual void Initialize( vtkRenderer *ren, vtkVolume   *vol );
00091   
00093   virtual void Finalize();
00094 
00095   virtual vtkUnstructuredGridVolumeRayCastIterator *NewIterator();
00096 
00097   
00098   
00099   class Triangle {
00100   public:
00101     vtkIdType PointIndex[3];
00102     vtkIdType ReferredByTetra[2];
00103     double    P1X, P1Y;
00104     double    P2X, P2Y;
00105     double    Denominator;
00106     double    A, B, C, D;
00107     Triangle *Next; 
00108   };
00109   
00110   
00111   
00112   class Intersection {
00113   public:
00114     Triangle     *TriPtr;
00115     double        Z;
00116     Intersection *Next;
00117   };
00118   
00120 
00122   int  InTriangle( double x, double y,
00123                    Triangle *triPtr );
00125   
00126 
00128   double *GetPoints() {return this->Points;}
00129   
00131 
00132   vtkGetObjectMacro( ViewToWorldMatrix, vtkMatrix4x4 );
00134   
00136 
00137   vtkGetVectorMacro( ImageOrigin, int, 2 );
00139 
00141 
00142   vtkGetVectorMacro( ImageViewportSize, int, 2 );
00144 
00146   Triangle **GetTetraTriangles () {return this->TetraTriangles;}
00147   
00149   Intersection *GetIntersectionList( int x, int y ) { return this->Image[y*this->ImageSize[0] + x]; }
00150 
00151 
00152   
00153 protected:
00154   vtkUnstructuredGridBunykRayCastFunction();
00155   ~vtkUnstructuredGridBunykRayCastFunction();
00156 
00157   
00158   
00159   vtkRenderer                             *Renderer;
00160   vtkVolume                               *Volume;
00161   vtkUnstructuredGridVolumeRayCastMapper  *Mapper;
00162   
00163   
00164   
00165   
00166   int                                      Valid;
00167 
00168   
00169   int      NumberOfPoints;
00170   double  *Points;
00171 
00172   
00173   
00174   vtkMatrix4x4 *ViewToWorldMatrix;
00175 
00176 
00177   
00178   Intersection    **Image;
00179   
00180   
00181   
00182   int               ImageSize[2];
00183   
00184   
00185   
00186   
00187   
00188   
00189   int               ImageOrigin[2];
00190   
00191   
00192   int               ImageViewportSize[2];
00193 
00194   
00195   
00196   vtkUnstructuredGrid       *SavedTriangleListInput;
00197   vtkTimeStamp               SavedTriangleListMTime;
00198  
00199 
00200   
00201   
00202   
00203   
00204   
00205   
00206   Triangle **TetraTriangles;
00207   vtkIdType TetraTrianglesSize;
00208   
00209   Triangle  *TriangleList;
00210 
00211   
00212   
00213   
00214   
00215   int  IsTriangleFrontFacing( Triangle *triPtr, vtkIdType tetraIndex );
00216   
00217   
00218   
00219   
00220   void ClearImage();
00221   
00222   
00223   
00224   
00225   Intersection *IntersectionBuffer[VTK_BUNYKRCF_MAX_ARRAYS];
00226   int           IntersectionBufferCount[VTK_BUNYKRCF_MAX_ARRAYS];
00227   
00228   
00229   
00230   
00231   void         *NewIntersection();  
00232 
00233   
00234   
00235   
00236   
00237   int          CheckValidity(vtkRenderer *ren,
00238                              vtkVolume   *vol);
00239   
00240   
00241   
00242   void          TransformPoints();
00243 
00244   
00245   
00246   void          UpdateTriangleList();
00247   
00248   
00249   
00250   void          ComputeViewDependentInfo();
00251   
00252   
00253   
00254   
00255   void          ComputePixelIntersections();
00256   
00257 
00258   
00259 private:
00260   vtkUnstructuredGridBunykRayCastFunction(const vtkUnstructuredGridBunykRayCastFunction&);  
00261   void operator=(const vtkUnstructuredGridBunykRayCastFunction&);  
00262 };
00263 
00264 #endif
00265 
00266 
00267 
00268 
00269 
00270 
00271