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