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 =========================================================================*/
64 #ifndef vtkRearrangeFields_h
65 #define vtkRearrangeFields_h
66 
67 #include "vtkFiltersCoreModule.h" // For export macro
68 #include "vtkDataSetAlgorithm.h"
69 
70 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
71 
72 class vtkFieldData;
73 
74 class VTKFILTERSCORE_EXPORT vtkRearrangeFields : public vtkDataSetAlgorithm
75 {
76 public:
78  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
79 
83  static vtkRearrangeFields *New();
84 
86  {
87  COPY=0,
88  MOVE=1
89  };
91  {
92  DATA_OBJECT=0,
93  POINT_DATA=1,
94  CELL_DATA=2
95  };
96 
102  int AddOperation(int operationType, int attributeType, int fromFieldLoc,
103  int toFieldLoc);
109  int AddOperation(int operationType, const char* name, int fromFieldLoc,
110  int toFieldLoc);
116  int AddOperation(const char* operationType, const char* attributeType,
117  const char* fromFieldLoc, const char* toFieldLoc);
118 
122  int RemoveOperation(int operationId);
127  int RemoveOperation(int operationType, int attributeType, int fromFieldLoc,
128  int toFieldLoc);
133  int RemoveOperation(int operationType, const char* name, int fromFieldLoc,
134  int toFieldLoc);
139  int RemoveOperation(const char* operationType, const char* attributeType,
140  const char* fromFieldLoc, const char* toFieldLoc);
141 
143 
147  {
148  this->Modified();
149  this->LastId = 0;
150  this->DeleteAllOperations();
151  }
153 
155  {
157  ATTRIBUTE
158  };
159 
160  struct Operation
161  {
162  int OperationType; // COPY or MOVE
163  int FieldType; // NAME or ATTRIBUTE
164  char* FieldName;
166  int FromFieldLoc; // fd, pd or do
167  int ToFieldLoc; // fd, pd or do
168  int Id; // assigned during creation
169  Operation* Next; // linked list
170  Operation() { FieldName = 0; }
171  ~Operation() { delete[] FieldName; }
172  };
173 
174 protected:
175 
177  ~vtkRearrangeFields() VTK_OVERRIDE;
178 
179  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE;
180 
181 
182  // Operations are stored as a linked list.
183  Operation* Head;
184  Operation* Tail;
185  // This is incremented whenever a new operation is created.
186  // It is not decremented when an operation is deleted.
187  int LastId;
188 
189  // Methods to browse/modify the linked list.
190  Operation* GetNextOperation(Operation* op)
191  { return op->Next; }
193  { return this->Head; }
194  void AddOperation(Operation* op);
195  void DeleteOperation(Operation* op, Operation* before);
196  Operation* FindOperation(int id, Operation*& before);
197  Operation* FindOperation(const char* name, Operation*& before);
198  Operation* FindOperation(int operationType, const char* name,
199  int fromFieldLoc, int toFieldLoc,
200  Operation*& before);
201  Operation* FindOperation(int operationType, int attributeType,
202  int fromFieldLoc, int toFieldLoc,
203  Operation*& before);
204  // Used when finding/deleting an operation given a signature.
205  int CompareOperationsByType(const Operation* op1, const Operation* op2);
206  int CompareOperationsByName(const Operation* op1, const Operation* op2);
207 
208  void DeleteAllOperations();
209  void ApplyOperation(Operation* op, vtkDataSet* input, vtkDataSet* output);
210  // Given location (DATA_OBJECT, CELL_DATA, POINT_DATA) return the
211  // pointer to the corresponding field data.
212  vtkFieldData* GetFieldDataFromLocation(vtkDataSet* ds, int fieldLoc);
213 
214  // Used by AddOperation() and RemoveOperation() designed to be used
215  // from other language bindings.
216  static char OperationTypeNames[2][5];
217  static char FieldLocationNames[3][12];
218  static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
219 
220  void PrintAllOperations(ostream& os, vtkIndent indent);
221  void PrintOperation(Operation* op, ostream& os, vtkIndent indent);
222 private:
223  vtkRearrangeFields(const vtkRearrangeFields&) VTK_DELETE_FUNCTION;
224  void operator=(const vtkRearrangeFields&) VTK_DELETE_FUNCTION;
225 };
226 
227 #endif
228 
229 
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void Modified()
Update the modification time for this object.
void RemoveAllOperations()
Remove all operations.
Store zero or more vtkInformation instances.
Move/copy fields between field data, point data and cell data.
Superclass for algorithms that produce output of the same type as input.
static vtkDataSetAlgorithm * New()
represent and manipulate fields of data
Definition: vtkFieldData.h:56