VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkPiecewiseFunction.h,v $ 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 00039 #ifndef __vtkPiecewiseFunction_h 00040 #define __vtkPiecewiseFunction_h 00041 00042 #include "vtkDataObject.h" 00043 00044 class vtkPiecewiseFunctionInternals; 00045 00046 class VTK_FILTERING_EXPORT vtkPiecewiseFunction : public vtkDataObject 00047 { 00048 public: 00049 static vtkPiecewiseFunction *New(); 00050 vtkTypeRevisionMacro(vtkPiecewiseFunction,vtkDataObject); 00051 void PrintSelf(ostream& os, vtkIndent indent); 00052 00053 void DeepCopy( vtkDataObject *f ); 00054 void ShallowCopy( vtkDataObject *f ); 00055 00057 int GetDataObjectType() {return VTK_PIECEWISE_FUNCTION;}; 00058 00060 int GetSize(); 00061 00063 00066 int AddPoint( double x, double y ); 00067 int AddPoint( double x, double y, double midpoint, double sharpness ); 00068 int RemovePoint( double x ); 00070 00072 void RemoveAllPoints(); 00073 00078 void AddSegment( double x1, double y1, double x2, double y2 ); 00079 00082 double GetValue( double x ); 00083 00085 00087 int GetNodeValue( int index, double val[4] ); 00088 int SetNodeValue( int index, double val[4] ); 00090 00092 00097 double *GetDataPointer(); 00098 void FillFromDataPointer(int, double*); 00100 00102 00103 vtkGetVector2Macro( Range, double ); 00105 00108 int AdjustRange(double range[2]); 00109 00111 00113 void GetTable( double x1, double x2, int size, float *table, int stride=1 ); 00114 void GetTable( double x1, double x2, int size, double *table, int stride=1 ); 00116 00118 00122 void BuildFunctionFromTable( double x1, double x2, int size, 00123 double *table, int stride=1 ); 00125 00127 00133 vtkSetMacro( Clamping, int ); 00134 vtkGetMacro( Clamping, int ); 00135 vtkBooleanMacro( Clamping, int ); 00137 00143 const char *GetType(); 00144 00147 double GetFirstNonZeroValue(); 00148 00152 void Initialize(); 00153 00154 //BTX 00156 00157 static vtkPiecewiseFunction* GetData(vtkInformation* info); 00158 static vtkPiecewiseFunction* GetData(vtkInformationVector* v, int i=0); 00159 //ETX 00161 00163 00165 vtkSetMacro(AllowDuplicateScalars, int); 00166 vtkGetMacro(AllowDuplicateScalars, int); 00167 vtkBooleanMacro(AllowDuplicateScalars, int); 00169 00170 protected: 00171 vtkPiecewiseFunction(); 00172 ~vtkPiecewiseFunction(); 00173 00174 // The internal STL structures 00175 vtkPiecewiseFunctionInternals *Internal; 00176 00177 // Determines the function value outside of defined points 00178 // Zero = always return 0.0 outside of defined points 00179 // One = clamp to the lowest value below defined points and 00180 // highest value above defined points 00181 int Clamping; 00182 00183 // Array of points ((X,Y) pairs) 00184 double *Function; 00185 00186 // Min and max range of function point locations 00187 double Range[2]; 00188 00189 // Internal method to sort the vector and update the 00190 // Range whenever a node is added or removed 00191 void SortAndUpdateRange(); 00192 00193 int AllowDuplicateScalars; 00194 00195 private: 00196 vtkPiecewiseFunction(const vtkPiecewiseFunction&); // Not implemented. 00197 void operator=(const vtkPiecewiseFunction&); // Not implemented. 00198 }; 00199 00200 #endif 00201 00202