VTK  9.7.1
vtkRearrangeFields.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
45 #ifndef vtkRearrangeFields_h
46 #define vtkRearrangeFields_h
47 
48 #include "vtkDataSetAlgorithm.h"
49 #include "vtkFiltersCoreModule.h" // For export macro
50 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
51 
52 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
53 
54 VTK_ABI_NAMESPACE_BEGIN
55 class vtkFieldData;
56 
57 class VTKFILTERSCORE_EXPORT VTK_MARSHALAUTO vtkRearrangeFields : public vtkDataSetAlgorithm
58 {
59 public:
61  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
66  static vtkRearrangeFields* New();
67 
69  {
70  COPY = 0,
71  MOVE = 1
72  };
74  {
75  DATA_OBJECT = 0,
76  POINT_DATA = 1,
77  CELL_DATA = 2
78  };
79 
85  int AddOperation(int operationType, int attributeType, int fromFieldLoc, int toFieldLoc);
91  int AddOperation(int operationType, const char* name, int fromFieldLoc, int toFieldLoc);
97  int AddOperation(const char* operationType, const char* attributeType, const char* fromFieldLoc,
98  const char* toFieldLoc);
99 
103  int RemoveOperation(int operationId);
108  int RemoveOperation(int operationType, int attributeType, int fromFieldLoc, int toFieldLoc);
113  int RemoveOperation(int operationType, const char* name, int fromFieldLoc, int toFieldLoc);
118  int RemoveOperation(const char* operationType, const char* attributeType,
119  const char* fromFieldLoc, const char* toFieldLoc);
120 
122 
126  {
127  this->Modified();
128  this->LastId = 0;
129  this->DeleteAllOperations();
130  }
132 
134  {
136  ATTRIBUTE
137  };
138 
139  struct Operation
140  {
141  int OperationType; // COPY or MOVE
142  int FieldType; // NAME or ATTRIBUTE
143  char* FieldName;
145  int FromFieldLoc; // fd, pd or do
146  int ToFieldLoc; // fd, pd or do
147  int Id; // assigned during creation
148  Operation* Next; // linked list
149  Operation() { FieldName = nullptr; }
150  ~Operation() { delete[] FieldName; }
151  };
152 
153 protected:
155  ~vtkRearrangeFields() override;
156 
158 
159  // Operations are stored as a linked list.
162  // This is incremented whenever a new operation is created.
163  // It is not decremented when an operation is deleted.
164  int LastId;
165 
166  // Methods to browse/modify the linked list.
167  Operation* GetNextOperation(Operation* op) { return op->Next; }
168  Operation* GetFirst() { return this->Head; }
169  void AddOperation(Operation* op);
170  void DeleteOperation(Operation* op, Operation* before);
171  Operation* FindOperation(int id, Operation*& before);
172  Operation* FindOperation(const char* name, Operation*& before);
173  Operation* FindOperation(
174  int operationType, const char* name, int fromFieldLoc, int toFieldLoc, Operation*& before);
175  Operation* FindOperation(
176  int operationType, int attributeType, int fromFieldLoc, int toFieldLoc, Operation*& before);
177  // Used when finding/deleting an operation given a signature.
178  int CompareOperationsByType(const Operation* op1, const Operation* op2);
179  int CompareOperationsByName(const Operation* op1, const Operation* op2);
180 
181  void DeleteAllOperations();
182  void ApplyOperation(Operation* op, vtkDataSet* input, vtkDataSet* output);
183  // Given location (DATA_OBJECT, CELL_DATA, POINT_DATA) return the
184  // pointer to the corresponding field data.
185  vtkFieldData* GetFieldDataFromLocation(vtkDataSet* ds, int fieldLoc);
186 
187  // Used by AddOperation() and RemoveOperation() designed to be used
188  // from other language bindings.
189  static char OperationTypeNames[2][5];
190  static char FieldLocationNames[3][12];
191  static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
192 
193  void PrintAllOperations(ostream& os, vtkIndent indent);
194  void PrintOperation(Operation* op, ostream& os, vtkIndent indent);
195 
196 private:
197  vtkRearrangeFields(const vtkRearrangeFields&) = delete;
198  void operator=(const vtkRearrangeFields&) = delete;
199 };
200 
201 VTK_ABI_NAMESPACE_END
202 #endif
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:28
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.
#define VTK_MARSHALAUTO
Superclass for algorithms that produce output of the same type as input.
static vtkDataSetAlgorithm * New()
Operation * GetNextOperation(Operation *op)
Represents and manipulates a collection of data arrays.
Definition: vtkFieldData.h:51