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
00084 #ifndef __vtkSplitField_h
00085 #define __vtkSplitField_h
00086
00087 #include "vtkDataSetToDataSetFilter.h"
00088
00089 class vtkFieldData;
00090
00091 class VTK_GRAPHICS_EXPORT vtkSplitField : public vtkDataSetToDataSetFilter
00092 {
00093 public:
00094 vtkTypeMacro(vtkSplitField,vtkDataSetToDataSetFilter);
00095 void PrintSelf(ostream& os, vtkIndent indent);
00096
00098 static vtkSplitField *New();
00099
00102 void SetInputField(int attributeType, int fieldLoc);
00103
00106 void SetInputField(const char* name, int fieldLoc);
00107
00110 void SetInputField(const char* name, const char* fieldLoc);
00111
00113 void Split(int component, const char* arrayName);
00114
00115
00116 enum FieldLocations
00117 {
00118 DATA_OBJECT=0,
00119 POINT_DATA=1,
00120 CELL_DATA=2
00121 };
00122
00123
00124
00125 struct Component
00126 {
00127 int Index;
00128 char* FieldName;
00129 Component* Next;
00130 void SetName(const char* name)
00131 {
00132 delete[] this->FieldName;
00133 this->FieldName = 0;
00134 if (name)
00135 {
00136 this->FieldName = new char[strlen(name)+1];
00137 strcpy(this->FieldName, name);
00138 }
00139 }
00140 Component() { FieldName = 0; }
00141 ~Component() { delete[] FieldName; }
00142 };
00143
00144
00145 protected:
00146
00147
00148 enum FieldTypes
00149 {
00150 NAME,
00151 ATTRIBUTE
00152 };
00153
00154
00155 vtkSplitField();
00156 virtual ~vtkSplitField();
00157
00158 void Execute();
00159
00160 char* FieldName;
00161 int FieldType;
00162 int AttributeType;
00163 int FieldLocation;
00164
00165 static char FieldLocationNames[3][12];
00166 static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
00167
00168 vtkDataArray* SplitArray(vtkDataArray* da, int component);
00169
00170
00171
00172 Component* Head;
00173 Component* Tail;
00174
00175
00176 Component* GetNextComponent(Component* op)
00177 { return op->Next; }
00178 Component* GetFirst()
00179 { return this->Head; }
00180 void AddComponent(Component* op);
00181 Component* FindComponent(int index);
00182 void DeleteAllComponents();
00183
00184 void PrintComponent(Component* op, ostream& os, vtkIndent indent)
00185 {
00186 os << indent << "Field name: " << op->FieldName << endl;
00187 os << indent << "Component index: " << op->Index << endl;
00188 }
00189
00190 void PrintAllComponents(ostream& os, vtkIndent indent)
00191 {
00192 Component* cur = this->GetFirst();
00193 if (!cur) { return; }
00194 Component* before;
00195 do
00196 {
00197 before = cur;
00198 cur = cur->Next;
00199 os << endl;
00200 this->PrintComponent(before, os, indent);
00201 }
00202 while (cur);
00203 }
00204 private:
00205 vtkSplitField(const vtkSplitField&);
00206 void operator=(const vtkSplitField&);
00207 };
00208
00209 #endif
00210
00211