VTK  9.5.20250903
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
54VTK_ABI_NAMESPACE_BEGIN
55class vtkFieldData;
56
57class VTKFILTERSCORE_EXPORT VTK_MARSHALAUTO vtkRearrangeFields : public vtkDataSetAlgorithm
58{
59public:
61 void PrintSelf(ostream& os, vtkIndent indent) override;
62
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
140 {
141 int OperationType; // COPY or MOVE
142 int FieldType; // NAME or ATTRIBUTE
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
153protected:
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.
165
166 // Methods to browse/modify the linked list.
168 Operation* GetFirst() { return this->Head; }
172 Operation* FindOperation(const char* name, Operation*& before);
174 int operationType, const char* name, int fromFieldLoc, int toFieldLoc, Operation*& before);
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
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.
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
196private:
197 vtkRearrangeFields(const vtkRearrangeFields&) = delete;
198 void operator=(const vtkRearrangeFields&) = delete;
199};
200
201VTK_ABI_NAMESPACE_END
202#endif
Superclass for algorithms that produce output of the same type as input.
abstract class to specify dataset behavior
Definition vtkDataSet.h:165
Represents and manipulates a collection of data arrays.
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
virtual void Modified()
Update the modification time for this object.
Move/copy fields between field data, point data and cell data.
int CompareOperationsByType(const Operation *op1, const Operation *op2)
Operation * FindOperation(int operationType, int attributeType, int fromFieldLoc, int toFieldLoc, Operation *&before)
void AddOperation(Operation *op)
int RemoveOperation(int operationId)
Remove an operation with the given id.
void DeleteOperation(Operation *op, Operation *before)
~vtkRearrangeFields() override
void RemoveAllOperations()
Remove all operations.
static vtkRearrangeFields * New()
Create a new vtkRearrangeFields with an empty operation list.
Operation * FindOperation(const char *name, Operation *&before)
Operation * GetNextOperation(Operation *op)
void PrintOperation(Operation *op, ostream &os, vtkIndent indent)
int AddOperation(const char *operationType, const char *attributeType, const char *fromFieldLoc, const char *toFieldLoc)
Helper method used by other language bindings.
int CompareOperationsByName(const Operation *op1, const Operation *op2)
void PrintAllOperations(ostream &os, vtkIndent indent)
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called within ProcessRequest when a request asks the algorithm to do its work.
void ApplyOperation(Operation *op, vtkDataSet *input, vtkDataSet *output)
int AddOperation(int operationType, const char *name, int fromFieldLoc, int toFieldLoc)
Add an operation which copies a field (data array) from one field data to another.
int RemoveOperation(const char *operationType, const char *attributeType, const char *fromFieldLoc, const char *toFieldLoc)
Remove an operation with the given signature.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Operation * FindOperation(int operationType, const char *name, int fromFieldLoc, int toFieldLoc, Operation *&before)
int AddOperation(int operationType, int attributeType, int fromFieldLoc, int toFieldLoc)
Add an operation which copies an attribute's field (data array) from one field data to another.
vtkFieldData * GetFieldDataFromLocation(vtkDataSet *ds, int fieldLoc)
int RemoveOperation(int operationType, const char *name, int fromFieldLoc, int toFieldLoc)
Remove an operation with the given signature.
Operation * FindOperation(int id, Operation *&before)
int RemoveOperation(int operationType, int attributeType, int fromFieldLoc, int toFieldLoc)
Remove an operation with the given signature.
void DeleteAllOperations()
#define VTK_MARSHALAUTO