VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkPiecewiseFunction.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 =========================================================================*/ 00015 00042 #ifndef __vtkPiecewiseFunction_h 00043 #define __vtkPiecewiseFunction_h 00044 00045 #include "vtkDataObject.h" 00046 00047 class vtkPiecewiseFunctionInternals; 00048 00049 class VTK_FILTERING_EXPORT vtkPiecewiseFunction : public vtkDataObject 00050 { 00051 public: 00052 static vtkPiecewiseFunction *New(); 00053 vtkTypeMacro(vtkPiecewiseFunction,vtkDataObject); 00054 void PrintSelf(ostream& os, vtkIndent indent); 00055 00056 void DeepCopy( vtkDataObject *f ); 00057 void ShallowCopy( vtkDataObject *f ); 00058 00060 int GetDataObjectType() {return VTK_PIECEWISE_FUNCTION;}; 00061 00063 int GetSize(); 00064 00066 00069 int AddPoint( double x, double y ); 00070 int AddPoint( double x, double y, double midpoint, double sharpness ); 00071 int RemovePoint( double x ); 00073 00075 void RemoveAllPoints(); 00076 00081 void AddSegment( double x1, double y1, double x2, double y2 ); 00082 00085 double GetValue( double x ); 00086 00088 00090 int GetNodeValue( int index, double val[4] ); 00091 int SetNodeValue( int index, double val[4] ); 00093 00095 00100 double *GetDataPointer(); 00101 void FillFromDataPointer(int, double*); 00103 00105 00106 vtkGetVector2Macro( Range, double ); 00108 00111 int AdjustRange(double range[2]); 00112 00114 00116 void GetTable( double x1, double x2, int size, float *table, int stride=1 ); 00117 void GetTable( double x1, double x2, int size, double *table, int stride=1 ); 00119 00121 00125 void BuildFunctionFromTable( double x1, double x2, int size, 00126 double *table, int stride=1 ); 00128 00130 00136 vtkSetMacro( Clamping, int ); 00137 vtkGetMacro( Clamping, int ); 00138 vtkBooleanMacro( Clamping, int ); 00140 00146 const char *GetType(); 00147 00150 double GetFirstNonZeroValue(); 00151 00155 void Initialize(); 00156 00157 //BTX 00159 00160 static vtkPiecewiseFunction* GetData(vtkInformation* info); 00161 static vtkPiecewiseFunction* GetData(vtkInformationVector* v, int i=0); 00162 //ETX 00164 00166 00168 vtkSetMacro(AllowDuplicateScalars, int); 00169 vtkGetMacro(AllowDuplicateScalars, int); 00170 vtkBooleanMacro(AllowDuplicateScalars, int); 00172 00173 protected: 00174 vtkPiecewiseFunction(); 00175 ~vtkPiecewiseFunction(); 00176 00177 // The internal STL structures 00178 vtkPiecewiseFunctionInternals *Internal; 00179 00180 // Determines the function value outside of defined points 00181 // Zero = always return 0.0 outside of defined points 00182 // One = clamp to the lowest value below defined points and 00183 // highest value above defined points 00184 int Clamping; 00185 00186 // Array of points ((X,Y) pairs) 00187 double *Function; 00188 00189 // Min and max range of function point locations 00190 double Range[2]; 00191 00192 // Internal method to sort the vector and update the 00193 // Range whenever a node is added, edited or removed. 00194 // It always calls Modified(). 00195 void SortAndUpdateRange(); 00196 // Returns true if the range has been updated and Modified() has been called 00197 bool UpdateRange(); 00198 00199 int AllowDuplicateScalars; 00200 00201 private: 00202 vtkPiecewiseFunction(const vtkPiecewiseFunction&); // Not implemented. 00203 void operator=(const vtkPiecewiseFunction&); // Not implemented. 00204 }; 00205 00206 #endif 00207 00208