VTK  9.2.6
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=========================================================================*/
57#ifndef vtkRearrangeFields_h
58#define vtkRearrangeFields_h
59
60#include "vtkDataSetAlgorithm.h"
61#include "vtkFiltersCoreModule.h" // For export macro
62
63#include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
64
65class vtkFieldData;
66
67class VTKFILTERSCORE_EXPORT vtkRearrangeFields : public vtkDataSetAlgorithm
68{
69public:
71 void PrintSelf(ostream& os, vtkIndent indent) override;
72
77
79 {
80 COPY = 0,
81 MOVE = 1
82 };
84 {
85 DATA_OBJECT = 0,
86 POINT_DATA = 1,
87 CELL_DATA = 2
88 };
89
95 int AddOperation(int operationType, int attributeType, int fromFieldLoc, int toFieldLoc);
101 int AddOperation(int operationType, const char* name, int fromFieldLoc, int toFieldLoc);
107 int AddOperation(const char* operationType, const char* attributeType, const char* fromFieldLoc,
108 const char* toFieldLoc);
109
113 int RemoveOperation(int operationId);
118 int RemoveOperation(int operationType, int attributeType, int fromFieldLoc, int toFieldLoc);
123 int RemoveOperation(int operationType, const char* name, int fromFieldLoc, int toFieldLoc);
128 int RemoveOperation(const char* operationType, const char* attributeType,
129 const char* fromFieldLoc, const char* toFieldLoc);
130
132
136 {
137 this->Modified();
138 this->LastId = 0;
139 this->DeleteAllOperations();
140 }
142
144 {
146 ATTRIBUTE
147 };
148
150 {
151 int OperationType; // COPY or MOVE
152 int FieldType; // NAME or ATTRIBUTE
155 int FromFieldLoc; // fd, pd or do
156 int ToFieldLoc; // fd, pd or do
157 int Id; // assigned during creation
158 Operation* Next; // linked list
159 Operation() { FieldName = nullptr; }
160 ~Operation() { delete[] FieldName; }
161 };
162
163protected:
166
168
169 // Operations are stored as a linked list.
172 // This is incremented whenever a new operation is created.
173 // It is not decremented when an operation is deleted.
175
176 // Methods to browse/modify the linked list.
178 Operation* GetFirst() { return this->Head; }
182 Operation* FindOperation(const char* name, Operation*& before);
184 int operationType, const char* name, int fromFieldLoc, int toFieldLoc, Operation*& before);
186 int operationType, int attributeType, int fromFieldLoc, int toFieldLoc, Operation*& before);
187 // Used when finding/deleting an operation given a signature.
188 int CompareOperationsByType(const Operation* op1, const Operation* op2);
189 int CompareOperationsByName(const Operation* op1, const Operation* op2);
190
192 void ApplyOperation(Operation* op, vtkDataSet* input, vtkDataSet* output);
193 // Given location (DATA_OBJECT, CELL_DATA, POINT_DATA) return the
194 // pointer to the corresponding field data.
196
197 // Used by AddOperation() and RemoveOperation() designed to be used
198 // from other language bindings.
199 static char OperationTypeNames[2][5];
200 static char FieldLocationNames[3][12];
201 static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
202
203 void PrintAllOperations(ostream& os, vtkIndent indent);
204 void PrintOperation(Operation* op, ostream& os, vtkIndent indent);
205
206private:
207 vtkRearrangeFields(const vtkRearrangeFields&) = delete;
208 void operator=(const vtkRearrangeFields&) = delete;
209};
210
211#endif
Superclass for algorithms that produce output of the same type as input.
abstract class to specify dataset behavior
Definition vtkDataSet.h:63
represent and manipulate fields of data
a simple class to control print indentation
Definition vtkIndent.h:40
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()