VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkRearrangeFields.h 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 =========================================================================*/ 00063 #ifndef __vtkRearrangeFields_h 00064 #define __vtkRearrangeFields_h 00065 00066 #include "vtkDataSetAlgorithm.h" 00067 00068 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES 00069 00070 class vtkFieldData; 00071 00072 class VTK_GRAPHICS_EXPORT vtkRearrangeFields : public vtkDataSetAlgorithm 00073 { 00074 public: 00075 vtkTypeMacro(vtkRearrangeFields,vtkDataSetAlgorithm); 00076 void PrintSelf(ostream& os, vtkIndent indent); 00077 00079 static vtkRearrangeFields *New(); 00080 00081 //BTX 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 //ETX 00094 00096 00099 int AddOperation(int operationType, int attributeType, int fromFieldLoc, 00100 int toFieldLoc); 00102 00103 00106 int AddOperation(int operationType, const char* name, int fromFieldLoc, 00107 int toFieldLoc); 00109 00110 00113 int AddOperation(const char* operationType, const char* attributeType, 00114 const char* fromFieldLoc, const char* toFieldLoc); 00116 00118 int RemoveOperation(int operationId); 00120 00122 int RemoveOperation(int operationType, int attributeType, int fromFieldLoc, 00123 int toFieldLoc); 00125 00126 00128 int RemoveOperation(int operationType, const char* name, int fromFieldLoc, 00129 int toFieldLoc); 00131 00132 00134 int RemoveOperation(const char* operationType, const char* attributeType, 00135 const char* fromFieldLoc, const char* toFieldLoc); 00137 00139 00140 void RemoveAllOperations() 00141 { 00142 this->Modified(); 00143 this->LastId = 0; 00144 this->DeleteAllOperations(); 00145 } 00147 00148 //BTX 00149 enum FieldType 00150 { 00151 NAME, 00152 ATTRIBUTE 00153 }; 00154 00155 struct Operation 00156 { 00157 int OperationType; // COPY or MOVE 00158 int FieldType; // NAME or ATTRIBUTE 00159 char* FieldName; 00160 int AttributeType; 00161 int FromFieldLoc; // fd, pd or do 00162 int ToFieldLoc; // fd, pd or do 00163 int Id; // assigned during creation 00164 Operation* Next; // linked list 00165 Operation() { FieldName = 0; } 00166 ~Operation() { delete[] FieldName; } 00167 }; 00168 //ETX 00169 00170 protected: 00171 00172 vtkRearrangeFields(); 00173 virtual ~vtkRearrangeFields(); 00174 00175 int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00176 00177 00178 // Operations are stored as a linked list. 00179 Operation* Head; 00180 Operation* Tail; 00181 // This is incremented whenever a new operation is created. 00182 // It is not decremented when an operation is deleted. 00183 int LastId; 00184 00185 // Methods to browse/modify the linked list. 00186 Operation* GetNextOperation(Operation* op) 00187 { return op->Next; } 00188 Operation* GetFirst() 00189 { return this->Head; } 00190 void AddOperation(Operation* op); 00191 void DeleteOperation(Operation* op, Operation* before); 00192 Operation* FindOperation(int id, Operation*& before); 00193 Operation* FindOperation(const char* name, Operation*& before); 00194 Operation* FindOperation(int operationType, const char* name, 00195 int fromFieldLoc, int toFieldLoc, 00196 Operation*& before); 00197 Operation* FindOperation(int operationType, int attributeType, 00198 int fromFieldLoc, int toFieldLoc, 00199 Operation*& before); 00200 // Used when finding/deleting an operation given a signature. 00201 int CompareOperationsByType(const Operation* op1, const Operation* op2); 00202 int CompareOperationsByName(const Operation* op1, const Operation* op2); 00203 00204 void DeleteAllOperations(); 00205 void ApplyOperation(Operation* op, vtkDataSet* input, vtkDataSet* output); 00206 // Given location (DATA_OBJECT, CELL_DATA, POINT_DATA) return the 00207 // pointer to the corresponding field data. 00208 vtkFieldData* GetFieldDataFromLocation(vtkDataSet* ds, int fieldLoc); 00209 00210 // Used by AddOperation() and RemoveOperation() designed to be used 00211 // from other language bindings. 00212 static char OperationTypeNames[2][5]; 00213 static char FieldLocationNames[3][12]; 00214 static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10]; 00215 00216 void PrintAllOperations(ostream& os, vtkIndent indent); 00217 void PrintOperation(Operation* op, ostream& os, vtkIndent indent); 00218 private: 00219 vtkRearrangeFields(const vtkRearrangeFields&); // Not implemented. 00220 void operator=(const vtkRearrangeFields&); // Not implemented. 00221 }; 00222 00223 #endif 00224 00225