VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkUnstructuredGridVolumeZSweepMapper.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00037 #ifndef __vtkUnstructuredGridVolumeZSweepMapper_h 00038 #define __vtkUnstructuredGridVolumeZSweepMapper_h 00039 00040 #include "vtkRenderingVolumeModule.h" // For export macro 00041 #include "vtkUnstructuredGridVolumeMapper.h" 00042 00043 class vtkRenderer; 00044 class vtkVolume; 00045 class vtkRayCastImageDisplayHelper; 00046 class vtkCell; 00047 class vtkGenericCell; 00048 class vtkIdList; 00049 class vtkPriorityQueue; 00050 class vtkTransform; 00051 class vtkMatrix4x4; 00052 class vtkVolumeProperty; 00053 class vtkDoubleArray; 00054 class vtkUnstructuredGridVolumeRayIntegrator; 00055 class vtkRenderWindow; 00056 00057 //BTX 00058 // Internal classes 00059 namespace vtkUnstructuredGridVolumeZSweepMapperNamespace 00060 { 00061 class vtkScreenEdge; 00062 class vtkSpan; 00063 class vtkPixelListFrame; 00064 class vtkUseSet; 00065 class vtkVertices; 00066 class vtkSimpleScreenEdge; 00067 class vtkDoubleScreenEdge; 00068 class vtkVertexEntry; 00069 class vtkPixelListEntryMemory; 00070 }; 00071 //ETX 00072 00073 class VTKRENDERINGVOLUME_EXPORT vtkUnstructuredGridVolumeZSweepMapper : public vtkUnstructuredGridVolumeMapper 00074 { 00075 public: 00076 vtkTypeMacro(vtkUnstructuredGridVolumeZSweepMapper,vtkUnstructuredGridVolumeMapper); 00077 void PrintSelf( ostream& os, vtkIndent indent ); 00078 00080 static vtkUnstructuredGridVolumeZSweepMapper *New(); 00081 00083 00086 vtkSetClampMacro( ImageSampleDistance, float, 0.1f, 100.0f ); 00087 vtkGetMacro( ImageSampleDistance, float ); 00089 00091 00093 vtkSetClampMacro( MinimumImageSampleDistance, float, 0.1f, 100.0f ); 00094 vtkGetMacro( MinimumImageSampleDistance, float ); 00096 00098 00100 vtkSetClampMacro( MaximumImageSampleDistance, float, 0.1f, 100.0f ); 00101 vtkGetMacro( MaximumImageSampleDistance, float ); 00103 00105 00108 vtkSetClampMacro( AutoAdjustSampleDistances, int, 0, 1 ); 00109 vtkGetMacro( AutoAdjustSampleDistances, int ); 00110 vtkBooleanMacro( AutoAdjustSampleDistances, int ); 00112 00114 00116 vtkSetClampMacro( IntermixIntersectingGeometry, int, 0, 1 ); 00117 vtkGetMacro( IntermixIntersectingGeometry, int ); 00118 vtkBooleanMacro( IntermixIntersectingGeometry, int ); 00120 00125 int GetMaxPixelListSize(); 00126 00129 void SetMaxPixelListSize(int size); 00130 00132 00134 virtual void SetRayIntegrator(vtkUnstructuredGridVolumeRayIntegrator *ri); 00135 vtkGetObjectMacro(RayIntegrator, vtkUnstructuredGridVolumeRayIntegrator); 00137 00138 //BTX 00140 00142 void Render(vtkRenderer *ren, 00143 vtkVolume *vol); 00145 00146 vtkGetVectorMacro( ImageInUseSize, int, 2 ); 00147 vtkGetVectorMacro( ImageOrigin, int, 2 ); 00148 vtkGetVectorMacro( ImageViewportSize, int , 2 ); 00149 //ETX 00150 00151 protected: 00152 vtkUnstructuredGridVolumeZSweepMapper(); 00153 ~vtkUnstructuredGridVolumeZSweepMapper(); 00154 00156 void BuildUseSets(); 00157 00159 00161 int ReorderTriangle(vtkIdType v[3], 00162 vtkIdType w[3]); 00164 00166 00169 void ProjectAndSortVertices(vtkRenderer *ren, 00170 vtkVolume *vol); 00172 00174 void CreateAndCleanPixelList(); 00175 00178 void MainLoop(vtkRenderWindow *renWin); 00179 00182 void CompositeFunction(double zTarget); 00183 00185 unsigned char ColorComponentRealToByte(float color); 00186 00188 void RasterizeFace(vtkIdType faceIds[3], int externalSide); 00189 00190 //BTX 00192 00194 void RasterizeTriangle( 00195 vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry *ve0, 00196 vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry *ve1, 00197 vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry *ve2, 00198 bool exitFace); 00200 00202 00204 void RasterizeSpan(int y, 00205 vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkScreenEdge *left, 00206 vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkScreenEdge *right, 00207 bool exitFace); 00209 00211 00214 void RasterizeLine( 00215 vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry *v0, 00216 vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry *v1, 00217 bool exitFace); 00218 //ETX 00220 00221 void StoreRenderTime(vtkRenderer *ren, 00222 vtkVolume *vol, 00223 float t); 00224 00225 float RetrieveRenderTime(vtkRenderer *ren, 00226 vtkVolume *vol); 00227 00229 00230 double GetZBufferValue(int x, 00231 int y); 00233 00234 double GetMinimumBoundsDepth(vtkRenderer *ren, 00235 vtkVolume *vol); 00236 00239 void AllocateUseSet(vtkIdType size); 00240 00243 void AllocateVertices(vtkIdType size); 00244 00246 void SavePixelListFrame(); 00247 00248 int MaxPixelListSize; 00249 00250 float ImageSampleDistance; 00251 float MinimumImageSampleDistance; 00252 float MaximumImageSampleDistance; 00253 int AutoAdjustSampleDistances; 00254 00255 vtkRayCastImageDisplayHelper *ImageDisplayHelper; 00256 00257 // This is how big the image would be if it covered the entire viewport 00258 int ImageViewportSize[2]; 00259 00260 // This is how big the allocated memory for image is. This may be bigger 00261 // or smaller than ImageFullSize - it will be bigger if necessary to 00262 // ensure a power of 2, it will be smaller if the volume only covers a 00263 // small region of the viewport 00264 int ImageMemorySize[2]; 00265 00266 // This is the size of subregion in ImageSize image that we are using for 00267 // the current image. Since ImageSize is a power of 2, there is likely 00268 // wasted space in it. This number will be used for things such as clearing 00269 // the image if necessary. 00270 int ImageInUseSize[2]; 00271 00272 // This is the location in ImageFullSize image where our ImageSize image 00273 // is located. 00274 int ImageOrigin[2]; 00275 00276 // This is the allocated image 00277 unsigned char *Image; 00278 00279 // This is the accumulating double RGBA image 00280 float *RealRGBAImage; 00281 00282 float *RenderTimeTable; 00283 vtkVolume **RenderVolumeTable; 00284 vtkRenderer **RenderRendererTable; 00285 int RenderTableSize; 00286 int RenderTableEntries; 00287 00288 int IntermixIntersectingGeometry; 00289 00290 float *ZBuffer; 00291 int ZBufferSize[2]; 00292 int ZBufferOrigin[2]; 00293 00294 vtkDataArray *Scalars; 00295 int CellScalars; 00296 00297 // if use CellScalars, we need to keep track of the 00298 // values on each side of the face and figure out 00299 // if the face is used by two cells (twosided) or one cell. 00300 double FaceScalars[2]; 00301 int FaceSide; 00302 00303 //BTX 00304 vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkSpan *Span; 00305 vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkPixelListFrame *PixelListFrame; 00306 00307 // Used by BuildUseSets(). 00308 vtkGenericCell *Cell; 00309 00310 vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkUseSet *UseSet; 00311 00312 vtkPriorityQueue *EventList; 00313 vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertices *Vertices; 00314 00315 vtkTransform *PerspectiveTransform; 00316 vtkMatrix4x4 *PerspectiveMatrix; 00317 00318 // Used by the main loop 00319 int MaxPixelListSizeReached; 00320 int XBounds[2]; 00321 int YBounds[2]; 00322 00323 vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkSimpleScreenEdge *SimpleEdge; 00324 vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkDoubleScreenEdge *DoubleEdge; 00325 00326 vtkUnstructuredGridVolumeRayIntegrator *RayIntegrator; 00327 vtkUnstructuredGridVolumeRayIntegrator *RealRayIntegrator; 00328 00329 vtkTimeStamp SavedTriangleListMTime; 00330 00331 // Used during compositing 00332 vtkDoubleArray *IntersectionLengths; 00333 vtkDoubleArray *NearIntersections; 00334 vtkDoubleArray *FarIntersections; 00335 00336 // Benchmark 00337 vtkIdType MaxRecordedPixelListSize; 00338 00339 00340 vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkPixelListEntryMemory *MemoryManager; 00341 //ETX 00342 private: 00343 vtkUnstructuredGridVolumeZSweepMapper(const vtkUnstructuredGridVolumeZSweepMapper&); // Not implemented. 00344 void operator=(const vtkUnstructuredGridVolumeZSweepMapper&); // Not implemented. 00345 }; 00346 00347 #endif