00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00078 #ifndef __vtkRearrangeFields_h
00079 #define __vtkRearrangeFields_h
00080
00081 #include "vtkDataSetToDataSetFilter.h"
00082
00083 #include "vtkDataSetAttributes.h"
00084
00085 class vtkFieldData;
00086
00087 class VTK_GRAPHICS_EXPORT vtkRearrangeFields : public vtkDataSetToDataSetFilter
00088 {
00089 public:
00090 vtkTypeRevisionMacro(vtkRearrangeFields,vtkDataSetToDataSetFilter);
00091 void PrintSelf(ostream& os, vtkIndent indent);
00092
00094 static vtkRearrangeFields *New();
00095
00096
00097 enum OperationType
00098 {
00099 COPY=0,
00100 MOVE=1
00101 };
00102 enum FieldLocation
00103 {
00104 DATA_OBJECT=0,
00105 POINT_DATA=1,
00106 CELL_DATA=2
00107 };
00108
00109
00111
00114 int AddOperation(int operationType, int attributeType, int fromFieldLoc,
00115 int toFieldLoc);
00116
00117
00118
00119
00120 int AddOperation(int operationType, const char* name, int fromFieldLoc,
00121 int toFieldLoc);
00122
00123
00124
00125
00126 int AddOperation(const char* operationType, const char* attributeType,
00127 const char* fromFieldLoc, const char* toFieldLoc);
00129
00131
00132 int RemoveOperation(int operationId);
00133
00134
00135
00136 int RemoveOperation(int operationType, int attributeType, int fromFieldLoc,
00137 int toFieldLoc);
00138
00139
00140
00141 int RemoveOperation(int operationType, const char* name, int fromFieldLoc,
00142 int toFieldLoc);
00143
00144
00145
00146 int RemoveOperation(const char* operationType, const char* attributeType,
00147 const char* fromFieldLoc, const char* toFieldLoc);
00149
00151
00152 void RemoveAllOperations()
00153 {
00154 this->Modified();
00155 this->LastId = 0;
00156 this->DeleteAllOperations();
00157 }
00159
00160
00161 enum FieldType
00162 {
00163 NAME,
00164 ATTRIBUTE
00165 };
00166
00167 struct Operation
00168 {
00169 int OperationType;
00170 int FieldType;
00171 char* FieldName;
00172 int AttributeType;
00173 int FromFieldLoc;
00174 int ToFieldLoc;
00175 int Id;
00176 Operation* Next;
00177 Operation() { FieldName = 0; }
00178 ~Operation() { delete[] FieldName; }
00179 };
00180
00181
00182 protected:
00183
00184 vtkRearrangeFields();
00185 virtual ~vtkRearrangeFields();
00186
00187 void Execute();
00188
00189
00190
00191 Operation* Head;
00192 Operation* Tail;
00193
00194
00195 int LastId;
00196
00197
00198 Operation* GetNextOperation(Operation* op)
00199 { return op->Next; }
00200 Operation* GetFirst()
00201 { return this->Head; }
00202 void AddOperation(Operation* op);
00203 void DeleteOperation(Operation* op, Operation* before);
00204 Operation* FindOperation(int id, Operation*& before);
00205 Operation* FindOperation(const char* name, Operation*& before);
00206 Operation* FindOperation(int operationType, const char* name,
00207 int fromFieldLoc, int toFieldLoc,
00208 Operation*& before);
00209 Operation* FindOperation(int operationType, int attributeType,
00210 int fromFieldLoc, int toFieldLoc,
00211 Operation*& before);
00212
00213 int CompareOperationsByType(const Operation* op1, const Operation* op2);
00214 int CompareOperationsByName(const Operation* op1, const Operation* op2);
00215
00216 void DeleteAllOperations();
00217 void ApplyOperation(Operation* op, vtkDataSet* input, vtkDataSet* output);
00218
00219
00220 vtkFieldData* GetFieldDataFromLocation(vtkDataSet* ds, int fieldLoc);
00221
00222
00223
00224 static char OperationTypeNames[2][5];
00225 static char FieldLocationNames[3][12];
00226 static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
00227
00228 void PrintAllOperations(ostream& os, vtkIndent indent);
00229 void PrintOperation(Operation* op, ostream& os, vtkIndent indent);
00230 private:
00231 vtkRearrangeFields(const vtkRearrangeFields&);
00232 void operator=(const vtkRearrangeFields&);
00233 };
00234
00235 #endif
00236
00237