VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkRearrangeFields.h,v $ 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00060 #ifndef __vtkRearrangeFields_h 00061 #define __vtkRearrangeFields_h 00062 00063 #include "vtkDataSetAlgorithm.h" 00064 00065 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES 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 //BTX 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 //ETX 00091 00093 00096 int AddOperation(int operationType, int attributeType, int fromFieldLoc, 00097 int toFieldLoc); 00098 // Description: 00099 // Add an operation which copies a field (data array) from one field 00100 // data to another. Returns an operation id which can later 00101 // be used to remove the operation. 00102 int AddOperation(int operationType, const char* name, int fromFieldLoc, 00103 int toFieldLoc); 00104 // Description: 00105 // Helper method used by other language bindings. Allows the caller to 00106 // specify arguments as strings instead of enums.Returns an operation id 00107 // which can later be used to remove the operation. 00108 int AddOperation(const char* operationType, const char* attributeType, 00109 const char* fromFieldLoc, const char* toFieldLoc); 00111 00113 00114 int RemoveOperation(int operationId); 00115 // Description: 00116 // Remove an operation with the given signature. See AddOperation 00117 // for details. 00118 int RemoveOperation(int operationType, int attributeType, int fromFieldLoc, 00119 int toFieldLoc); 00120 // Description: 00121 // Remove an operation with the given signature. See AddOperation 00122 // for details. 00123 int RemoveOperation(int operationType, const char* name, int fromFieldLoc, 00124 int toFieldLoc); 00125 // Description: 00126 // Remove an operation with the given signature. See AddOperation 00127 // for details. 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 //BTX 00143 enum FieldType 00144 { 00145 NAME, 00146 ATTRIBUTE 00147 }; 00148 00149 struct Operation 00150 { 00151 int OperationType; // COPY or MOVE 00152 int FieldType; // NAME or ATTRIBUTE 00153 char* FieldName; 00154 int AttributeType; 00155 int FromFieldLoc; // fd, pd or do 00156 int ToFieldLoc; // fd, pd or do 00157 int Id; // assigned during creation 00158 Operation* Next; // linked list 00159 Operation() { FieldName = 0; } 00160 ~Operation() { delete[] FieldName; } 00161 }; 00162 //ETX 00163 00164 protected: 00165 00166 vtkRearrangeFields(); 00167 virtual ~vtkRearrangeFields(); 00168 00169 int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00170 00171 00172 // Operations are stored as a linked list. 00173 Operation* Head; 00174 Operation* Tail; 00175 // This is incremented whenever a new operation is created. 00176 // It is not decremented when an operation is deleted. 00177 int LastId; 00178 00179 // Methods to browse/modify the linked list. 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 // Used when finding/deleting an operation given a signature. 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 // Given location (DATA_OBJECT, CELL_DATA, POINT_DATA) return the 00201 // pointer to the corresponding field data. 00202 vtkFieldData* GetFieldDataFromLocation(vtkDataSet* ds, int fieldLoc); 00203 00204 // Used by AddOperation() and RemoveOperation() designed to be used 00205 // from other language bindings. 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&); // Not implemented. 00214 void operator=(const vtkRearrangeFields&); // Not implemented. 00215 }; 00216 00217 #endif 00218 00219