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