00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00069 #ifndef __vtkScalars_h
00070 #define __vtkScalars_h
00071
00072 #include "vtkAttributeData.h"
00073
00074 #define VTK_COLOR_MODE_DEFAULT 0
00075 #define VTK_COLOR_MODE_MAP_SCALARS 1
00076 #define VTK_COLOR_MODE_LUMINANCE 2
00077
00078 class vtkIdList;
00079 class vtkScalars;
00080 class vtkLookupTable;
00081 class vtkUnsignedCharArray;
00082 class vtkScalarsToColors;
00083
00084 class VTK_EXPORT vtkScalars : public vtkAttributeData
00085 {
00086 public:
00087 static vtkScalars *New();
00088 static vtkScalars *New(int dataType, int numComp=1);
00089
00090 vtkTypeMacro(vtkScalars,vtkAttributeData);
00091 void PrintSelf(ostream& os, vtkIndent indent);
00092
00095 void SetData(vtkDataArray *);
00096
00098 vtkAttributeData *MakeObject();
00099
00102 void SetNumberOfScalars(int number) {this->Data->SetNumberOfTuples(number);};
00103
00105 int GetNumberOfScalars() {return this->Data->GetNumberOfTuples();};
00106
00108 float GetScalar(int id);
00109
00113 void SetScalar(int id, float s);
00114
00117 void InsertScalar(int id, float s);
00118
00121 int InsertNextScalar(float s);
00122
00124 void SetNumberOfComponents(int num);
00125 int GetNumberOfComponents() {return this->Data->GetNumberOfComponents();}
00126
00130 vtkSetClampMacro(ActiveComponent,int,0,3);
00131 vtkGetMacro(ActiveComponent,int);
00132
00133
00134
00136 void ComputeRange();
00137
00138
00141 float *GetRange();
00142
00143
00145 void GetRange(float range[2]);
00146
00150 void GetDataTypeRange(double range[2]);
00151 double GetDataTypeMin();
00152 double GetDataTypeMax();
00153
00156 virtual void CreateDefaultLookupTable();
00157
00159 void SetLookupTable(vtkLookupTable *lut);
00160 vtkGetObjectMacro(LookupTable,vtkLookupTable);
00161
00163 void GetScalars(vtkIdList *ptIds, vtkScalars *fv);
00164
00168 void GetScalars(int p1, int p2, vtkScalars *fs);
00169
00176 int InitColorTraversal(float alpha, vtkScalarsToColors *lut,
00177 int colorMode=VTK_COLOR_MODE_DEFAULT);
00178
00182 unsigned char *GetColor(int id) {
00183 return (this->*(this->CurrentColorFunction))(id);};
00184
00185 #ifndef VTK_REMOVE_LEGACY_CODE
00186
00187 void GetScalars(vtkIdList& ptIds, vtkScalars& fv)
00188 {VTK_LEGACY_METHOD(GetScalars,"3.2"); this->GetScalars(&ptIds, &fv);}
00189 void GetScalars(int p1, int p2, vtkScalars& fs)
00190 {VTK_LEGACY_METHOD(GetScalars,"3.2"); this->GetScalars(p1, p2, &fs);}
00191 #endif
00192
00193 protected:
00194 vtkScalars();
00195 ~vtkScalars();
00196 vtkScalars(const vtkScalars&) {};
00197 void operator=(const vtkScalars&) {};
00198
00199 float Range[8];
00200 vtkTimeStamp ComputeTime;
00201 vtkLookupTable *LookupTable;
00202 int ActiveComponent;
00203
00204
00205 float CurrentAlpha;
00206 vtkScalarsToColors *CurrentLookupTable;
00207
00208 unsigned char *(vtkScalars::*CurrentColorFunction)(int id);
00209 unsigned char *PassRGBA(int id);
00210 unsigned char *PassRGB(int id);
00211 unsigned char *PassIA(int id);
00212 unsigned char *PassI(int id);
00213 unsigned char *CompositeRGBA(int id);
00214 unsigned char *CompositeIA(int id);
00215 unsigned char *CompositeMapThroughLookupTable(int id);
00216 unsigned char *MapThroughLookupTable(int id);
00217 unsigned char *Luminance(int id);
00218 vtkUnsignedCharArray *Colors;
00219 unsigned char RGBA[4];
00220
00221 };
00222
00223 inline vtkAttributeData *vtkScalars::MakeObject()
00224 {
00225 return vtkScalars::New(this->GetDataType(),this->GetNumberOfComponents());
00226 }
00227
00228 inline void vtkScalars::SetNumberOfComponents(int num)
00229 {
00230 num = (num < 1 ? 1 : (num > 4 ? 4 : num));
00231 this->Data->SetNumberOfComponents(num);
00232 }
00233
00234 inline float vtkScalars::GetScalar(int id)
00235 {
00236 return this->Data->GetComponent(id,this->ActiveComponent);
00237 }
00238
00239 inline void vtkScalars::SetScalar(int id, float s)
00240 {
00241 this->Data->SetComponent(id,this->ActiveComponent,s);
00242 }
00243
00244 inline void vtkScalars::InsertScalar(int id, float s)
00245 {
00246 this->Data->InsertComponent(id,this->ActiveComponent,s);
00247 }
00248
00249 inline int vtkScalars::InsertNextScalar(float s)
00250 {
00251 int tupleSize = this->Data->GetNumberOfComponents();
00252 int id=(this->Data->GetMaxId() + tupleSize)/tupleSize;
00253 this->Data->InsertComponent(id,this->ActiveComponent,s);
00254 return id;
00255 }
00256
00257
00258
00259 #include "vtkIdList.h"
00260
00261 #endif