VTK
vtkRearrangeFields.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkRearrangeFields.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
63 #ifndef vtkRearrangeFields_h
64 #define vtkRearrangeFields_h
65 
66 #include "vtkFiltersCoreModule.h" // For export macro
67 #include "vtkDataSetAlgorithm.h"
68 
69 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
70 
71 class vtkFieldData;
72 
74 {
75 public:
77  void PrintSelf(ostream& os, vtkIndent indent);
78 
80  static vtkRearrangeFields *New();
81 
82 //BTX
84  {
85  COPY=0,
86  MOVE=1
87  };
89  {
90  DATA_OBJECT=0,
91  POINT_DATA=1,
92  CELL_DATA=2
93  };
94 //ETX
95 
97 
100  int AddOperation(int operationType, int attributeType, int fromFieldLoc,
101  int toFieldLoc);
103 
104 
107  int AddOperation(int operationType, const char* name, int fromFieldLoc,
108  int toFieldLoc);
110 
111 
114  int AddOperation(const char* operationType, const char* attributeType,
115  const char* fromFieldLoc, const char* toFieldLoc);
117 
119  int RemoveOperation(int operationId);
121 
123  int RemoveOperation(int operationType, int attributeType, int fromFieldLoc,
124  int toFieldLoc);
126 
127 
129  int RemoveOperation(int operationType, const char* name, int fromFieldLoc,
130  int toFieldLoc);
132 
133 
135  int RemoveOperation(const char* operationType, const char* attributeType,
136  const char* fromFieldLoc, const char* toFieldLoc);
138 
140 
142  {
143  this->Modified();
144  this->LastId = 0;
145  this->DeleteAllOperations();
146  }
148 
149 //BTX
151  {
153  ATTRIBUTE
154  };
155 
156  struct Operation
157  {
158  int OperationType; // COPY or MOVE
159  int FieldType; // NAME or ATTRIBUTE
160  char* FieldName;
162  int FromFieldLoc; // fd, pd or do
163  int ToFieldLoc; // fd, pd or do
164  int Id; // assigned during creation
165  Operation* Next; // linked list
166  Operation() { FieldName = 0; }
167  ~Operation() { delete[] FieldName; }
168  };
169 //ETX
170 
171 protected:
172 
174  virtual ~vtkRearrangeFields();
175 
177 
178 
179  // Operations are stored as a linked list.
182  // This is incremented whenever a new operation is created.
183  // It is not decremented when an operation is deleted.
184  int LastId;
185 
186  // Methods to browse/modify the linked list.
188  { return op->Next; }
190  { return this->Head; }
191  void AddOperation(Operation* op);
192  void DeleteOperation(Operation* op, Operation* before);
193  Operation* FindOperation(int id, Operation*& before);
194  Operation* FindOperation(const char* name, Operation*& before);
195  Operation* FindOperation(int operationType, const char* name,
196  int fromFieldLoc, int toFieldLoc,
197  Operation*& before);
198  Operation* FindOperation(int operationType, int attributeType,
199  int fromFieldLoc, int toFieldLoc,
200  Operation*& before);
201  // Used when finding/deleting an operation given a signature.
202  int CompareOperationsByType(const Operation* op1, const Operation* op2);
203  int CompareOperationsByName(const Operation* op1, const Operation* op2);
204 
205  void DeleteAllOperations();
206  void ApplyOperation(Operation* op, vtkDataSet* input, vtkDataSet* output);
207  // Given location (DATA_OBJECT, CELL_DATA, POINT_DATA) return the
208  // pointer to the corresponding field data.
209  vtkFieldData* GetFieldDataFromLocation(vtkDataSet* ds, int fieldLoc);
210 
211  // Used by AddOperation() and RemoveOperation() designed to be used
212  // from other language bindings.
213  static char OperationTypeNames[2][5];
214  static char FieldLocationNames[3][12];
215  static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
216 
217  void PrintAllOperations(ostream& os, vtkIndent indent);
218  void PrintOperation(Operation* op, ostream& os, vtkIndent indent);
219 private:
220  vtkRearrangeFields(const vtkRearrangeFields&); // Not implemented.
221  void operator=(const vtkRearrangeFields&); // Not implemented.
222 };
223 
224 #endif
225 
226 
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:61
#define VTKFILTERSCORE_EXPORT
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
virtual void Modified()
Store zero or more vtkInformation instances.
Move/copy fields between field data, point data and cell data.
void PrintSelf(ostream &os, vtkIndent indent)
Superclass for algorithms that produce output of the same type as input.
static vtkDataSetAlgorithm * New()
Operation * GetNextOperation(Operation *op)
represent and manipulate fields of data
Definition: vtkFieldData.h:55