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 "vtkDataSetAlgorithm.h"
67 
68 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
69 
70 class vtkFieldData;
71 
73 {
74 public:
76  void PrintSelf(ostream& os, vtkIndent indent);
77 
79  static vtkRearrangeFields *New();
80 
81 //BTX
83  {
84  COPY=0,
85  MOVE=1
86  };
88  {
89  DATA_OBJECT=0,
90  POINT_DATA=1,
91  CELL_DATA=2
92  };
93 //ETX
94 
96 
99  int AddOperation(int operationType, int attributeType, int fromFieldLoc,
100  int toFieldLoc);
102 
103 
106  int AddOperation(int operationType, const char* name, int fromFieldLoc,
107  int toFieldLoc);
109 
110 
113  int AddOperation(const char* operationType, const char* attributeType,
114  const char* fromFieldLoc, const char* toFieldLoc);
116 
118  int RemoveOperation(int operationId);
120 
122  int RemoveOperation(int operationType, int attributeType, int fromFieldLoc,
123  int toFieldLoc);
125 
126 
128  int RemoveOperation(int operationType, const char* name, int fromFieldLoc,
129  int toFieldLoc);
131 
132 
134  int RemoveOperation(const char* operationType, const char* attributeType,
135  const char* fromFieldLoc, const char* toFieldLoc);
137 
139 
140  void RemoveAllOperations()
141  {
142  this->Modified();
143  this->LastId = 0;
144  this->DeleteAllOperations();
145  }
147 
148 //BTX
150  {
152  ATTRIBUTE
153  };
154 
155  struct Operation
156  {
157  int OperationType; // COPY or MOVE
158  int FieldType; // NAME or ATTRIBUTE
159  char* FieldName;
161  int FromFieldLoc; // fd, pd or do
162  int ToFieldLoc; // fd, pd or do
163  int Id; // assigned during creation
164  Operation* Next; // linked list
165  Operation() { FieldName = 0; }
166  ~Operation() { delete[] FieldName; }
167  };
168 //ETX
169 
170 protected:
171 
173  virtual ~vtkRearrangeFields();
174 
176 
177 
178  // Operations are stored as a linked list.
181  // This is incremented whenever a new operation is created.
182  // It is not decremented when an operation is deleted.
183  int LastId;
184 
185  // Methods to browse/modify the linked list.
186  Operation* GetNextOperation(Operation* op)
187  { return op->Next; }
188  Operation* GetFirst()
189  { return this->Head; }
190  void AddOperation(Operation* op);
191  void DeleteOperation(Operation* op, Operation* before);
192  Operation* FindOperation(int id, Operation*& before);
193  Operation* FindOperation(const char* name, Operation*& before);
194  Operation* FindOperation(int operationType, const char* name,
195  int fromFieldLoc, int toFieldLoc,
196  Operation*& before);
197  Operation* FindOperation(int operationType, int attributeType,
198  int fromFieldLoc, int toFieldLoc,
199  Operation*& before);
200  // Used when finding/deleting an operation given a signature.
201  int CompareOperationsByType(const Operation* op1, const Operation* op2);
202  int CompareOperationsByName(const Operation* op1, const Operation* op2);
203 
204  void DeleteAllOperations();
205  void ApplyOperation(Operation* op, vtkDataSet* input, vtkDataSet* output);
206  // Given location (DATA_OBJECT, CELL_DATA, POINT_DATA) return the
207  // pointer to the corresponding field data.
208  vtkFieldData* GetFieldDataFromLocation(vtkDataSet* ds, int fieldLoc);
209 
210  // Used by AddOperation() and RemoveOperation() designed to be used
211  // from other language bindings.
212  static char OperationTypeNames[2][5];
213  static char FieldLocationNames[3][12];
214  static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
215 
216  void PrintAllOperations(ostream& os, vtkIndent indent);
217  void PrintOperation(Operation* op, ostream& os, vtkIndent indent);
218 private:
219  vtkRearrangeFields(const vtkRearrangeFields&); // Not implemented.
220  void operator=(const vtkRearrangeFields&); // Not implemented.
221 };
222 
223 #endif
224 
225