00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkPiecewiseFunction.h,v $ 00005 Language: C++ 00006 00007 00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 00009 All rights reserved. 00010 00011 Redistribution and use in source and binary forms, with or without 00012 modification, are permitted provided that the following conditions are met: 00013 00014 * Redistributions of source code must retain the above copyright notice, 00015 this list of conditions and the following disclaimer. 00016 00017 * Redistributions in binary form must reproduce the above copyright notice, 00018 this list of conditions and the following disclaimer in the documentation 00019 and/or other materials provided with the distribution. 00020 00021 * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names 00022 of any contributors may be used to endorse or promote products derived 00023 from this software without specific prior written permission. 00024 00025 * Modified source versions must be plainly marked as such, and must not be 00026 misrepresented as being the original software. 00027 00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' 00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR 00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00038 00039 =========================================================================*/ 00040 00058 #ifndef __vtkPiecewiseFunction_h 00059 #define __vtkPiecewiseFunction_h 00060 00061 #include "vtkDataObject.h" 00062 00063 class VTK_FILTERING_EXPORT vtkPiecewiseFunction : public vtkDataObject 00064 { 00065 public: 00066 static vtkPiecewiseFunction *New(); 00067 vtkTypeMacro(vtkPiecewiseFunction,vtkDataObject); 00068 void PrintSelf(ostream& os, vtkIndent indent); 00069 00070 vtkDataObject *MakeObject(); 00071 void Initialize(); 00072 void DeepCopy( vtkDataObject *f ); 00073 void ShallowCopy( vtkDataObject *f ); 00074 00076 int GetDataObjectType() {return VTK_PIECEWISE_FUNCTION;}; 00077 00079 int GetSize(); 00080 00082 00084 void AddPoint( float x, float val ); 00085 void RemovePoint( float x ); 00087 00089 void RemoveAllPoints(); 00090 00093 void AddSegment( float x1, float val1, float x2, float val2 ); 00094 00098 float GetValue( float x ); 00099 00101 float *GetDataPointer() {return this->Function;}; 00102 00104 float *GetRange(); 00105 00110 void GetTable( float x1, float x2, int size, float *table, int stride=1 ); 00111 00113 00118 void BuildFunctionFromTable( float x1, float x2, int size, 00119 float *table, int stride=1 ); 00121 00123 00129 vtkSetMacro( Clamping, int ); 00130 vtkGetMacro( Clamping, int ); 00131 vtkBooleanMacro( Clamping, int ); 00133 00139 const char *GetType(); 00140 00143 unsigned long GetMTime(); 00144 00147 float GetFirstNonZeroValue(); 00148 00149 protected: 00150 vtkPiecewiseFunction(); 00151 ~vtkPiecewiseFunction(); 00152 00153 // Size of the array used to store function points 00154 int ArraySize; 00155 00156 // Determines the function value outside of defined points 00157 // Zero = always return 0.0 outside of defined points 00158 // One = clamp to the lowest value below defined points and 00159 // highest value above defined points 00160 int Clamping; 00161 00162 // Array of points ((X,Y) pairs) 00163 float *Function; 00164 00165 // Number of points used to specify function 00166 int FunctionSize; 00167 00168 // Min and max range of function point locations 00169 float FunctionRange[2]; 00170 00171 // Increases size of the function array. The array grows by a factor of 2 00172 // when the array limit has been reached. 00173 void IncreaseArraySize(); 00174 00175 // Private function to add a point to the function. Returns the array 00176 // index of the inserted point. 00177 int InsertPoint( float x, float val ); 00178 00179 // Move points one index down or up in the array. This is useful for 00180 // inserting and deleting points into the array. 00181 void MovePoints( int index, int down ); 00182 private: 00183 vtkPiecewiseFunction(const vtkPiecewiseFunction&); // Not implemented. 00184 void operator=(const vtkPiecewiseFunction&); // Not implemented. 00185 }; 00186 00187 #endif 00188