VTK
vtkUnstructuredGridPreIntegration.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkUnstructuredGridPreIntegration.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
16 /*
17  * Copyright 2004 Sandia Corporation.
18  * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
19  * license for use of this work by or on behalf of the
20  * U.S. Government. Redistribution and use in source and binary forms, with
21  * or without modification, are permitted provided that this Notice and any
22  * statement of authorship are reproduced on all copies.
23  */
24 
47 #ifndef vtkUnstructuredGridPreIntegration_h
48 #define vtkUnstructuredGridPreIntegration_h
49 
50 #include "vtkRenderingVolumeModule.h" // For export macro
52 
53 class vtkVolumeProperty;
54 
56 {
57 public:
61  virtual void PrintSelf(ostream &os, vtkIndent indent);
62 
63  virtual void Initialize(vtkVolume *volume, vtkDataArray *scalars);
64 
65  virtual void Integrate(vtkDoubleArray *intersectionLengths,
66  vtkDataArray *nearIntersections,
67  vtkDataArray *farIntersections,
68  float color[4]);
69 
71 
75  vtkGetObjectMacro(Integrator, vtkUnstructuredGridVolumeRayIntegrator);
76  virtual void SetIntegrator(vtkUnstructuredGridVolumeRayIntegrator *);
78 
80 
83  vtkSetMacro(IntegrationTableScalarResolution, int);
84  vtkGetMacro(IntegrationTableScalarResolution, int);
85  vtkSetMacro(IntegrationTableLengthResolution, int);
86  vtkGetMacro(IntegrationTableLengthResolution, int);
88 
90 
93  virtual double GetIntegrationTableScalarShift(int component = 0);
94  virtual double GetIntegrationTableScalarScale(int component = 0);
95  virtual double GetIntegrationTableLengthScale();
97 
99 
105  vtkGetMacro(IncrementalPreIntegration, int);
106  vtkSetMacro(IncrementalPreIntegration, int);
107  vtkBooleanMacro(IncrementalPreIntegration, int);
109 
121  virtual float *GetPreIntegrationTable(int component = 0);
122 
127  float *GetTableEntry(double scalar_front, double scalar_back, double lenth,
128  int component = 0);
129 
135  float *GetIndexedTableEntry(int scalar_front_index, int scalar_back_index,
136  int length_index, int component = 0);
137 
138 protected:
141 
143 
146  double MaxLength;
147 
154 
157 
159 
160  virtual void BuildPreIntegrationTables(vtkDataArray *scalars);
161 
162 private:
164  void operator=(const vtkUnstructuredGridPreIntegration&) VTK_DELETE_FUNCTION;
165 };
166 
167 inline float *vtkUnstructuredGridPreIntegration::GetIndexedTableEntry(
168  int scalar_front_index,
169  int scalar_back_index,
170  int length_index,
171  int component)
172 {
173  // Snap entries to bounds. I don't really want to spend cycles doing
174  // this, but I've had the ray caster give me values that are noticeably
175  // out of bounds.
176  if (scalar_front_index < 0) scalar_front_index = 0;
177  if (scalar_front_index >= this->IntegrationTableScalarResolution)
178  scalar_front_index = this->IntegrationTableScalarResolution - 1;
179  if (scalar_back_index < 0) scalar_back_index = 0;
180  if (scalar_back_index >= this->IntegrationTableScalarResolution)
181  scalar_back_index = this->IntegrationTableScalarResolution - 1;
182  if (length_index < 0) length_index = 0;
183  if (length_index >= this->IntegrationTableLengthResolution)
184  length_index = this->IntegrationTableLengthResolution - 1;
185 
186  return ( this->IntegrationTable[component]
187  + 4*( ( ( length_index*this->IntegrationTableScalarResolution
188  + scalar_back_index)
189  * this->IntegrationTableScalarResolution)
190  + scalar_front_index));
191 }
192 
194  double scalar_front, double scalar_back, double length, int component)
195 {
196  int sfi = static_cast<int>( scalar_front
197  *this->IntegrationTableScalarScale[component]
198  + this->IntegrationTableScalarShift[component] + 0.5);
199  int sbi = static_cast<int>( scalar_back*this->IntegrationTableScalarScale[component]
200  + this->IntegrationTableScalarShift[component] + 0.5);
201  int li = static_cast<int>(length*this->IntegrationTableLengthScale + 0.5);
202  return this->GetIndexedTableEntry(sfi, sbi, li, component);
203 }
204 
205 #endif //vtkUnstructuredGridPreIntegration_h
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:50
virtual void Initialize(vtkVolume *volume, vtkDataArray *scalars)=0
Set up the integrator with the given properties and scalars.
vtkUnstructuredGridVolumeRayIntegrator * Integrator
record modification and/or execution time
Definition: vtkTimeStamp.h:35
dynamic, self-adjusting array of double
a superclass for volume ray integration functions
float * GetTableEntry(double scalar_front, double scalar_back, double lenth, int component=0)
Get an entry (RGBA) in one of the pre-integration tables.
a simple class to control print indentation
Definition: vtkIndent.h:39
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
performs ray integration with pre-integration tables.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
represents the common properties for rendering a volume.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual void Integrate(vtkDoubleArray *intersectionLengths, vtkDataArray *nearIntersections, vtkDataArray *farIntersections, float color[4])=0
Given a set of intersections (defined by the three arrays), compute the peicewise integration of the ...