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
00091 #ifndef __vtkRearrangeFields_h
00092 #define __vtkRearrangeFields_h
00093
00094 #include "vtkDataSetToDataSetFilter.h"
00095
00096 class vtkFieldData;
00097
00098 class VTK_GRAPHICS_EXPORT vtkRearrangeFields : public vtkDataSetToDataSetFilter
00099 {
00100 public:
00101 vtkTypeMacro(vtkRearrangeFields,vtkDataSetToDataSetFilter);
00102 void PrintSelf(ostream& os, vtkIndent indent);
00103
00105 static vtkRearrangeFields *New();
00106
00107
00108 enum OperationType
00109 {
00110 COPY=0,
00111 MOVE=1
00112 };
00113 enum FieldLocation
00114 {
00115 DATA_OBJECT=0,
00116 POINT_DATA=1,
00117 CELL_DATA=2
00118 };
00119
00120
00122
00125 int AddOperation(int operationType, int attributeType, int fromFieldLoc,
00126 int toFieldLoc);
00127
00128
00129
00130
00131 int AddOperation(int operationType, const char* name, int fromFieldLoc,
00132 int toFieldLoc);
00133
00134
00135
00136
00137 int AddOperation(const char* operationType, const char* attributeType,
00138 const char* fromFieldLoc, const char* toFieldLoc);
00140
00142
00143 int RemoveOperation(int operationId);
00144
00145
00146
00147 int RemoveOperation(int operationType, int attributeType, int fromFieldLoc,
00148 int toFieldLoc);
00149
00150
00151
00152 int RemoveOperation(int operationType, const char* name, int fromFieldLoc,
00153 int toFieldLoc);
00154
00155
00156
00157 int RemoveOperation(const char* operationType, const char* attributeType,
00158 const char* fromFieldLoc, const char* toFieldLoc);
00160
00162
00163 void RemoveAllOperations()
00164 {
00165 this->Modified();
00166 this->LastId = 0;
00167 this->DeleteAllOperations();
00168 }
00170
00171
00172 enum FieldType
00173 {
00174 NAME,
00175 ATTRIBUTE
00176 };
00177
00178 struct Operation
00179 {
00180 int OperationType;
00181 int FieldType;
00182 char* FieldName;
00183 int AttributeType;
00184 int FromFieldLoc;
00185 int ToFieldLoc;
00186 int Id;
00187 Operation* Next;
00188 Operation() { FieldName = 0; }
00189 ~Operation() { delete[] FieldName; }
00190 };
00191
00192
00193 protected:
00194
00195 vtkRearrangeFields();
00196 virtual ~vtkRearrangeFields();
00197
00198 void Execute();
00199
00200
00201
00202 Operation* Head;
00203 Operation* Tail;
00204
00205
00206 int LastId;
00207
00208
00209 Operation* GetNextOperation(Operation* op)
00210 { return op->Next; }
00211 Operation* GetFirst()
00212 { return this->Head; }
00213 void AddOperation(Operation* op);
00214 void DeleteOperation(Operation* op, Operation* before);
00215 Operation* FindOperation(int id, Operation*& before);
00216 Operation* FindOperation(const char* name, Operation*& before);
00217 Operation* FindOperation(int operationType, const char* name,
00218 int fromFieldLoc, int toFieldLoc,
00219 Operation*& before);
00220 Operation* FindOperation(int operationType, int attributeType,
00221 int fromFieldLoc, int toFieldLoc,
00222 Operation*& before);
00223
00224 int CompareOperationsByType(const Operation* op1, const Operation* op2);
00225 int CompareOperationsByName(const Operation* op1, const Operation* op2);
00226
00227 void DeleteAllOperations();
00228 void ApplyOperation(Operation* op, vtkDataSet* input, vtkDataSet* output);
00229
00230
00231 vtkFieldData* GetFieldDataFromLocation(vtkDataSet* ds, int fieldLoc);
00232
00233
00234
00235 static char OperationTypeNames[2][5];
00236 static char FieldLocationNames[3][12];
00237 static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
00238
00239 void PrintAllOperations(ostream& os, vtkIndent indent)
00240 {
00241 Operation* cur = this->GetFirst();
00242 if (!cur) { return; }
00243 Operation* before;
00244 do
00245 {
00246 before = cur;
00247 cur = cur->Next;
00248 os << endl;
00249 this->PrintOperation(before, os, indent);
00250 }
00251 while (cur);
00252 }
00253
00254 void PrintOperation(Operation* op, ostream& os, vtkIndent indent)
00255 {
00256 os << indent << "Id: " << op->Id << endl;
00257 os << indent << "Type: " << op->OperationType << endl;
00258 os << indent << "Field type: " << op->FieldType << endl;
00259 if ( op->FieldName)
00260 {
00261 os << indent << "Field name: " << op->FieldName << endl;
00262 }
00263 else
00264 {
00265 os << indent << "Field name: (none)" << endl;
00266 }
00267 os << indent << "Attribute type: " << op->AttributeType << endl;
00268 os << indent << "Source field location: " << op->FromFieldLoc << endl;
00269 os << indent << "Target field location: " << op->ToFieldLoc << endl;
00270 os << indent << "Next operation: " << op->Next << endl;
00271 os << endl;
00272 }
00273 private:
00274 vtkRearrangeFields(const vtkRearrangeFields&);
00275 void operator=(const vtkRearrangeFields&);
00276 };
00277
00278 #endif
00279
00280