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 =========================================================================*/
54 #ifndef vtkRearrangeFields_h
55 #define vtkRearrangeFields_h
56 
57 #include "vtkFiltersCoreModule.h" // For export macro
58 #include "vtkDataSetAlgorithm.h"
59 
60 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
61 
62 class vtkFieldData;
63 
64 class VTKFILTERSCORE_EXPORT vtkRearrangeFields : public vtkDataSetAlgorithm
65 {
66 public:
68  void PrintSelf(ostream& os, vtkIndent indent) override;
69 
73  static vtkRearrangeFields *New();
74 
76  {
77  COPY=0,
78  MOVE=1
79  };
81  {
82  DATA_OBJECT=0,
83  POINT_DATA=1,
84  CELL_DATA=2
85  };
86 
92  int AddOperation(int operationType, int attributeType, int fromFieldLoc,
93  int toFieldLoc);
99  int AddOperation(int operationType, const char* name, int fromFieldLoc,
100  int toFieldLoc);
106  int AddOperation(const char* operationType, const char* attributeType,
107  const char* fromFieldLoc, const char* toFieldLoc);
108 
112  int RemoveOperation(int operationId);
117  int RemoveOperation(int operationType, int attributeType, int fromFieldLoc,
118  int toFieldLoc);
123  int RemoveOperation(int operationType, const char* name, int fromFieldLoc,
124  int toFieldLoc);
129  int RemoveOperation(const char* operationType, const char* attributeType,
130  const char* fromFieldLoc, const char* toFieldLoc);
131 
133 
137  {
138  this->Modified();
139  this->LastId = 0;
140  this->DeleteAllOperations();
141  }
143 
145  {
147  ATTRIBUTE
148  };
149 
150  struct Operation
151  {
152  int OperationType; // COPY or MOVE
153  int FieldType; // NAME or ATTRIBUTE
154  char* FieldName;
156  int FromFieldLoc; // fd, pd or do
157  int ToFieldLoc; // fd, pd or do
158  int Id; // assigned during creation
159  Operation* Next; // linked list
160  Operation() { FieldName = nullptr; }
161  ~Operation() { delete[] FieldName; }
162  };
163 
164 protected:
165 
167  ~vtkRearrangeFields() override;
168 
170 
171 
172  // Operations are stored as a linked list.
175  // This is incremented whenever a new operation is created.
176  // It is not decremented when an operation is deleted.
177  int LastId;
178 
179  // Methods to browse/modify the linked list.
181  { return op->Next; }
183  { return this->Head; }
184  void AddOperation(Operation* op);
185  void DeleteOperation(Operation* op, Operation* before);
186  Operation* FindOperation(int id, Operation*& before);
187  Operation* FindOperation(const char* name, Operation*& before);
188  Operation* FindOperation(int operationType, const char* name,
189  int fromFieldLoc, int toFieldLoc,
190  Operation*& before);
191  Operation* FindOperation(int operationType, int attributeType,
192  int fromFieldLoc, int toFieldLoc,
193  Operation*& before);
194  // Used when finding/deleting an operation given a signature.
195  int CompareOperationsByType(const Operation* op1, const Operation* op2);
196  int CompareOperationsByName(const Operation* op1, const Operation* op2);
197 
198  void DeleteAllOperations();
199  void ApplyOperation(Operation* op, vtkDataSet* input, vtkDataSet* output);
200  // Given location (DATA_OBJECT, CELL_DATA, POINT_DATA) return the
201  // pointer to the corresponding field data.
202  vtkFieldData* GetFieldDataFromLocation(vtkDataSet* ds, int fieldLoc);
203 
204  // Used by AddOperation() and RemoveOperation() designed to be used
205  // from other language bindings.
206  static char OperationTypeNames[2][5];
207  static char FieldLocationNames[3][12];
208  static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
209 
210  void PrintAllOperations(ostream& os, vtkIndent indent);
211  void PrintOperation(Operation* op, ostream& os, vtkIndent indent);
212 private:
213  vtkRearrangeFields(const vtkRearrangeFields&) = delete;
214  void operator=(const vtkRearrangeFields&) = delete;
215 };
216 
217 #endif
218 
219 
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
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:33
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called within ProcessRequest when a request asks the algorithm to do its work.
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:53