VTK
dox/Common/DataModel/vtkPiecewiseFunction.h
Go to the documentation of this file.
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 "vtkCommonDataModelModule.h" // For export macro
00046 #include "vtkDataObject.h"
00047 
00048 class vtkPiecewiseFunctionInternals;
00049 
00050 class VTKCOMMONDATAMODEL_EXPORT vtkPiecewiseFunction : public vtkDataObject
00051 {
00052 public:
00053   static vtkPiecewiseFunction *New();
00054   vtkTypeMacro(vtkPiecewiseFunction,vtkDataObject);
00055   void PrintSelf(ostream& os, vtkIndent indent);
00056 
00057   void DeepCopy( vtkDataObject *f );
00058   void ShallowCopy( vtkDataObject *f );
00059 
00061   int GetDataObjectType() {return VTK_PIECEWISE_FUNCTION;};
00062 
00064   int  GetSize();
00065 
00067 
00070   int AddPoint( double x, double y );
00071   int AddPoint( double x, double y, double midpoint, double sharpness );
00072   int RemovePoint( double x );
00074 
00076   void RemoveAllPoints();
00077 
00082   void AddSegment( double x1, double y1, double x2, double y2 );
00083 
00086   double GetValue( double x );
00087 
00089 
00091   int GetNodeValue( int index, double val[4] );
00092   int SetNodeValue( int index, double val[4] );
00094 
00096 
00101   double *GetDataPointer();
00102   void FillFromDataPointer(int, double*);
00104 
00106 
00107   vtkGetVector2Macro( Range, double );
00109 
00112   int AdjustRange(double range[2]);
00113 
00115 
00117   void GetTable( double x1, double x2, int size, float *table, int stride=1 );
00118   void GetTable( double x1, double x2, int size, double *table, int stride=1 );
00120 
00122 
00126   void BuildFunctionFromTable( double x1, double x2, int size,
00127                                double *table, int stride=1 );
00129 
00131 
00137   vtkSetMacro( Clamping, int );
00138   vtkGetMacro( Clamping, int );
00139   vtkBooleanMacro( Clamping, int );
00141 
00147   const char  *GetType();
00148 
00151   double GetFirstNonZeroValue();
00152 
00156   void Initialize();
00157 
00158   //BTX
00160 
00161   static vtkPiecewiseFunction* GetData(vtkInformation* info);
00162   static vtkPiecewiseFunction* GetData(vtkInformationVector* v, int i=0);
00163   //ETX
00165 
00167 
00169   vtkSetMacro(AllowDuplicateScalars, int);
00170   vtkGetMacro(AllowDuplicateScalars, int);
00171   vtkBooleanMacro(AllowDuplicateScalars, int);
00173 
00174 protected:
00175   vtkPiecewiseFunction();
00176   ~vtkPiecewiseFunction();
00177 
00178   // The internal STL structures
00179   vtkPiecewiseFunctionInternals *Internal;
00180 
00181   // Determines the function value outside of defined points
00182   // Zero = always return 0.0 outside of defined points
00183   // One  = clamp to the lowest value below defined points and
00184   //        highest value above defined points
00185   int   Clamping;
00186 
00187   // Array of points ((X,Y) pairs)
00188   double *Function;
00189 
00190   // Min and max range of function point locations
00191   double Range[2];
00192 
00193   // Internal method to sort the vector and update the
00194   // Range whenever a node is added, edited or removed.
00195   // It always calls Modified().
00196   void SortAndUpdateRange();
00197   // Returns true if the range has been updated and Modified() has been called
00198   bool UpdateRange();
00199 
00200   int AllowDuplicateScalars;
00201 
00202 private:
00203   vtkPiecewiseFunction(const vtkPiecewiseFunction&);  // Not implemented.
00204   void operator=(const vtkPiecewiseFunction&);  // Not implemented.
00205 };
00206 
00207 #endif
00208 
00209