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 
44 #ifndef vtkUnstructuredGridPreIntegration_h
45 #define vtkUnstructuredGridPreIntegration_h
46 
47 #include "vtkRenderingVolumeModule.h" // For export macro
49 
50 class vtkVolumeProperty;
51 
53 {
54 public:
58  void PrintSelf(ostream &os, vtkIndent indent) override;
59 
60  void Initialize(vtkVolume *volume, vtkDataArray *scalars) override;
61 
62  void Integrate(vtkDoubleArray *intersectionLengths,
63  vtkDataArray *nearIntersections,
64  vtkDataArray *farIntersections,
65  float color[4]) override;
66 
68 
72  vtkGetObjectMacro(Integrator, vtkUnstructuredGridVolumeRayIntegrator);
73  virtual void SetIntegrator(vtkUnstructuredGridVolumeRayIntegrator *);
75 
77 
80  vtkSetMacro(IntegrationTableScalarResolution, int);
81  vtkGetMacro(IntegrationTableScalarResolution, int);
82  vtkSetMacro(IntegrationTableLengthResolution, int);
83  vtkGetMacro(IntegrationTableLengthResolution, int);
85 
87 
90  virtual double GetIntegrationTableScalarShift(int component = 0);
91  virtual double GetIntegrationTableScalarScale(int component = 0);
92  virtual double GetIntegrationTableLengthScale();
94 
96 
102  vtkGetMacro(IncrementalPreIntegration, vtkTypeBool);
103  vtkSetMacro(IncrementalPreIntegration, vtkTypeBool);
104  vtkBooleanMacro(IncrementalPreIntegration, vtkTypeBool);
106 
118  virtual float *GetPreIntegrationTable(int component = 0);
119 
124  float *GetTableEntry(double scalar_front, double scalar_back, double length,
125  int component = 0);
126 
132  float *GetIndexedTableEntry(int scalar_front_index, int scalar_back_index,
133  int length_index, int component = 0);
134 
135 protected:
138 
140 
143  double MaxLength;
144 
151 
154 
156 
157  virtual void BuildPreIntegrationTables(vtkDataArray *scalars);
158 
159 private:
161  void operator=(const vtkUnstructuredGridPreIntegration&) = delete;
162 };
163 
165  int scalar_front_index,
166  int scalar_back_index,
167  int length_index,
168  int component)
169 {
170  // Snap entries to bounds. I don't really want to spend cycles doing
171  // this, but I've had the ray caster give me values that are noticeably
172  // out of bounds.
173  if (scalar_front_index < 0) scalar_front_index = 0;
174  if (scalar_front_index >= this->IntegrationTableScalarResolution)
175  scalar_front_index = this->IntegrationTableScalarResolution - 1;
176  if (scalar_back_index < 0) scalar_back_index = 0;
177  if (scalar_back_index >= this->IntegrationTableScalarResolution)
178  scalar_back_index = this->IntegrationTableScalarResolution - 1;
179  if (length_index < 0) length_index = 0;
180  if (length_index >= this->IntegrationTableLengthResolution)
181  length_index = this->IntegrationTableLengthResolution - 1;
182 
183  return ( this->IntegrationTable[component]
184  + 4*( ( ( length_index*this->IntegrationTableScalarResolution
185  + scalar_back_index)
186  * this->IntegrationTableScalarResolution)
187  + scalar_front_index));
188 }
189 
191  double scalar_front, double scalar_back, double length, int component)
192 {
193  int sfi = static_cast<int>( scalar_front
194  *this->IntegrationTableScalarScale[component]
195  + this->IntegrationTableScalarShift[component] + 0.5);
196  int sbi = static_cast<int>( scalar_back*this->IntegrationTableScalarScale[component]
197  + this->IntegrationTableScalarShift[component] + 0.5);
198  int li = static_cast<int>(length*this->IntegrationTableLengthScale + 0.5);
199  return this->GetIndexedTableEntry(sfi, sbi, li, component);
200 }
201 
202 #endif //vtkUnstructuredGridPreIntegration_h
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:50
float * GetIndexedTableEntry(int scalar_front_index, int scalar_back_index, int length_index, int component=0)
Like GetTableEntry, except the inputs are scaled indices into the table rather than than the actual s...
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
int vtkTypeBool
Definition: vtkABI.h:69
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.
float * GetTableEntry(double scalar_front, double scalar_back, double length, int component=0)
Get an entry (RGBA) in one of the pre-integration tables.
represents the common properties for rendering a volume.
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 piecewise integration of the ...