VTK  9.4.20241217
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
51#include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
52
53VTK_ABI_NAMESPACE_BEGIN
54class vtkFieldData;
55
56class VTKFILTERSCORE_EXPORT vtkRearrangeFields : public vtkDataSetAlgorithm
57{
58public:
60 void PrintSelf(ostream& os, vtkIndent indent) override;
61
66
68 {
69 COPY = 0,
70 MOVE = 1
71 };
73 {
74 DATA_OBJECT = 0,
75 POINT_DATA = 1,
76 CELL_DATA = 2
77 };
78
84 int AddOperation(int operationType, int attributeType, int fromFieldLoc, int toFieldLoc);
90 int AddOperation(int operationType, const char* name, int fromFieldLoc, int toFieldLoc);
96 int AddOperation(const char* operationType, const char* attributeType, const char* fromFieldLoc,
97 const char* toFieldLoc);
98
102 int RemoveOperation(int operationId);
107 int RemoveOperation(int operationType, int attributeType, int fromFieldLoc, int toFieldLoc);
112 int RemoveOperation(int operationType, const char* name, int fromFieldLoc, int toFieldLoc);
117 int RemoveOperation(const char* operationType, const char* attributeType,
118 const char* fromFieldLoc, const char* toFieldLoc);
119
121
125 {
126 this->Modified();
127 this->LastId = 0;
128 this->DeleteAllOperations();
129 }
131
133 {
135 ATTRIBUTE
136 };
137
139 {
140 int OperationType; // COPY or MOVE
141 int FieldType; // NAME or ATTRIBUTE
144 int FromFieldLoc; // fd, pd or do
145 int ToFieldLoc; // fd, pd or do
146 int Id; // assigned during creation
147 Operation* Next; // linked list
148 Operation() { FieldName = nullptr; }
149 ~Operation() { delete[] FieldName; }
150 };
151
152protected:
155
157
158 // Operations are stored as a linked list.
161 // This is incremented whenever a new operation is created.
162 // It is not decremented when an operation is deleted.
164
165 // Methods to browse/modify the linked list.
167 Operation* GetFirst() { return this->Head; }
171 Operation* FindOperation(const char* name, Operation*& before);
173 int operationType, const char* name, int fromFieldLoc, int toFieldLoc, Operation*& before);
175 int operationType, int attributeType, int fromFieldLoc, int toFieldLoc, Operation*& before);
176 // Used when finding/deleting an operation given a signature.
177 int CompareOperationsByType(const Operation* op1, const Operation* op2);
178 int CompareOperationsByName(const Operation* op1, const Operation* op2);
179
181 void ApplyOperation(Operation* op, vtkDataSet* input, vtkDataSet* output);
182 // Given location (DATA_OBJECT, CELL_DATA, POINT_DATA) return the
183 // pointer to the corresponding field data.
185
186 // Used by AddOperation() and RemoveOperation() designed to be used
187 // from other language bindings.
188 static char OperationTypeNames[2][5];
189 static char FieldLocationNames[3][12];
190 static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
191
192 void PrintAllOperations(ostream& os, vtkIndent indent);
193 void PrintOperation(Operation* op, ostream& os, vtkIndent indent);
194
195private:
196 vtkRearrangeFields(const vtkRearrangeFields&) = delete;
197 void operator=(const vtkRearrangeFields&) = delete;
198};
199
200VTK_ABI_NAMESPACE_END
201#endif
Superclass for algorithms that produce output of the same type as input.
abstract class to specify dataset behavior
Definition vtkDataSet.h:165
represent and manipulate fields of data
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()