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 =========================================================================*/
60 #ifndef vtkRearrangeFields_h
61 #define vtkRearrangeFields_h
62 
63 #include "vtkFiltersCoreModule.h" // For export macro
64 #include "vtkDataSetAlgorithm.h"
65 
66 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
67 
68 class vtkFieldData;
69 
70 class VTKFILTERSCORE_EXPORT vtkRearrangeFields : public vtkDataSetAlgorithm
71 {
72 public:
74  void PrintSelf(ostream& os, vtkIndent indent) override;
75 
79  static vtkRearrangeFields *New();
80 
82  {
83  COPY=0,
84  MOVE=1
85  };
87  {
88  DATA_OBJECT=0,
89  POINT_DATA=1,
90  CELL_DATA=2
91  };
92 
98  int AddOperation(int operationType, int attributeType, int fromFieldLoc,
99  int toFieldLoc);
105  int AddOperation(int operationType, const char* name, int fromFieldLoc,
106  int toFieldLoc);
112  int AddOperation(const char* operationType, const char* attributeType,
113  const char* fromFieldLoc, const char* toFieldLoc);
114 
118  int RemoveOperation(int operationId);
123  int RemoveOperation(int operationType, int attributeType, int fromFieldLoc,
124  int toFieldLoc);
129  int RemoveOperation(int operationType, const char* name, int fromFieldLoc,
130  int toFieldLoc);
135  int RemoveOperation(const char* operationType, const char* attributeType,
136  const char* fromFieldLoc, const char* toFieldLoc);
137 
139 
143  {
144  this->Modified();
145  this->LastId = 0;
146  this->DeleteAllOperations();
147  }
149 
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 = nullptr; }
167  ~Operation() { delete[] FieldName; }
168  };
169 
170 protected:
171 
173  ~vtkRearrangeFields() override;
174 
175  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override;
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.
187  { return op->Next; }
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&) = delete;
220  void operator=(const vtkRearrangeFields&) = delete;
221 };
222 
223 #endif
224 
225 
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()
Operation * GetNextOperation(Operation *op)
represent and manipulate fields of data
Definition: vtkFieldData.h:56