VTK: Filters/Core/vtkRearrangeFields.h Source File

| VTK 9.3.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
51 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
52
53 VTK_ABI_NAMESPACE_BEGIN
54 class vtkFieldData;
55
56 class VTKFILTERSCORE_EXPORT vtkRearrangeFields : public vtkDataSetAlgorithm
57 {
58 public:
59 vtkTypeMacro(vtkRearrangeFields, vtkDataSetAlgorithm);
60 void PrintSelf(ostream& os, vtkIndent indent) override;
61
65 static vtkRearrangeFields* New();
66
67 enum OperationType
68 {
69 COPY = 0,
70 MOVE = 1
71 };
72 enum FieldLocation
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
124 void RemoveAllOperations()
125 {
126 this->Modified();
127 this->LastId = 0;
128 this->DeleteAllOperations();
129 }
131
132 enum FieldType
133 {
134 NAME,
135 ATTRIBUTE
136 };
137
138 struct Operation
139 {
140 int OperationType; // COPY or MOVE
141 int FieldType; // NAME or ATTRIBUTE
142 char* FieldName;
143 int AttributeType;
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
152 protected:
153 vtkRearrangeFields();
154 ~vtkRearrangeFields() override;
155
156 int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
157
158 // Operations are stored as a linked list.
159 Operation* Head;
160 Operation* Tail;
161 // This is incremented whenever a new operation is created.
162 // It is not decremented when an operation is deleted.
163 int LastId;
164
165 // Methods to browse/modify the linked list.
166 Operation* GetNextOperation(Operation* op) { return op->Next; }
167 Operation* GetFirst() { return this->Head; }
168 void AddOperation(Operation* op);
169 void DeleteOperation(Operation* op, Operation* before);
170 Operation* FindOperation(int id, Operation*& before);
171 Operation* FindOperation(const char* name, Operation*& before);
172 Operation* FindOperation(
173 int operationType, const char* name, int fromFieldLoc, int toFieldLoc, Operation*& before);
174 Operation* FindOperation(
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
180 void DeleteAllOperations();
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.
184 vtkFieldData* GetFieldDataFromLocation(vtkDataSet* ds, int fieldLoc);
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
195 private:
196 vtkRearrangeFields(const vtkRearrangeFields&) = delete;
197 void operator=(const vtkRearrangeFields&) = delete;
198 };
199
200 VTK_ABI_NAMESPACE_END
201 #endif
vtkDataSetAlgorithm
Superclass for algorithms that produce output of the same type as input.
Definition: vtkDataSetAlgorithm.h:38
vtkDataSetAttributes::NUM_ATTRIBUTES
@ NUM_ATTRIBUTES
Definition: vtkDataSetAttributes.h:120
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkFieldData
represent and manipulate fields of data
Definition: vtkFieldData.h:61
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:40
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:72
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkRearrangeFields
Move/copy fields between field data, point data and cell data.
Definition: vtkRearrangeFields.h:57
vtkRearrangeFields::CompareOperationsByType
int CompareOperationsByType(const Operation *op1, const Operation *op2)
vtkRearrangeFields::GetFieldDataFromLocation
vtkFieldData * GetFieldDataFromLocation(vtkDataSet *ds, int fieldLoc)
vtkRearrangeFields::AddOperation
void AddOperation(Operation *op)
vtkRearrangeFields::GetFirst
Operation * GetFirst()
Definition: vtkRearrangeFields.h:167
vtkRearrangeFields::FindOperation
Operation * FindOperation(int operationType, int attributeType, int fromFieldLoc, int toFieldLoc, Operation *&before)
vtkRearrangeFields::RemoveOperation
int RemoveOperation(int operationId)
Remove an operation with the given id.
vtkRearrangeFields::DeleteOperation
void DeleteOperation(Operation *op, Operation *before)
vtkRearrangeFields::FieldType
FieldType
Definition: vtkRearrangeFields.h:133
vtkRearrangeFields::NAME
@ NAME
Definition: vtkRearrangeFields.h:134
vtkRearrangeFields::~vtkRearrangeFields
~vtkRearrangeFields() override
vtkRearrangeFields::RemoveAllOperations
void RemoveAllOperations()
Remove all operations.
Definition: vtkRearrangeFields.h:124
vtkRearrangeFields::OperationType
OperationType
Definition: vtkRearrangeFields.h:68
vtkRearrangeFields::LastId
int LastId
Definition: vtkRearrangeFields.h:163
vtkRearrangeFields::FindOperation
Operation * FindOperation(int id, Operation *&before)
vtkRearrangeFields::Head
Operation * Head
Definition: vtkRearrangeFields.h:159
vtkRearrangeFields::PrintOperation
void PrintOperation(Operation *op, ostream &os, vtkIndent indent)
vtkRearrangeFields::AddOperation
int AddOperation(const char *operationType, const char *attributeType, const char *fromFieldLoc, const char *toFieldLoc)
Helper method used by other language bindings.
vtkRearrangeFields::CompareOperationsByName
int CompareOperationsByName(const Operation *op1, const Operation *op2)
vtkRearrangeFields::PrintAllOperations
void PrintAllOperations(ostream &os, vtkIndent indent)
vtkRearrangeFields::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called within ProcessRequest when a request asks the algorithm to do its work.
vtkRearrangeFields::ApplyOperation
void ApplyOperation(Operation *op, vtkDataSet *input, vtkDataSet *output)
vtkRearrangeFields::FindOperation
Operation * FindOperation(int operationType, const char *name, int fromFieldLoc, int toFieldLoc, Operation *&before)
vtkRearrangeFields::AddOperation
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.
vtkRearrangeFields::RemoveOperation
int RemoveOperation(const char *operationType, const char *attributeType, const char *fromFieldLoc, const char *toFieldLoc)
Remove an operation with the given signature.
vtkRearrangeFields::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkRearrangeFields::FieldLocation
FieldLocation
Definition: vtkRearrangeFields.h:73
vtkRearrangeFields::New
static vtkRearrangeFields * New()
Create a new vtkRearrangeFields with an empty operation list.
vtkRearrangeFields::FindOperation
Operation * FindOperation(const char *name, Operation *&before)
vtkRearrangeFields::AddOperation
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.
vtkRearrangeFields::Tail
Operation * Tail
Definition: vtkRearrangeFields.h:160
vtkRearrangeFields::RemoveOperation
int RemoveOperation(int operationType, const char *name, int fromFieldLoc, int toFieldLoc)
Remove an operation with the given signature.
vtkRearrangeFields::GetNextOperation
Operation * GetNextOperation(Operation *op)
Definition: vtkRearrangeFields.h:166
vtkRearrangeFields::vtkRearrangeFields
vtkRearrangeFields()
vtkRearrangeFields::RemoveOperation
int RemoveOperation(int operationType, int attributeType, int fromFieldLoc, int toFieldLoc)
Remove an operation with the given signature.
vtkRearrangeFields::DeleteAllOperations
void DeleteAllOperations()
vtkX3D::name
@ name
Definition: vtkX3D.h:219
vtkRearrangeFields::Operation
Definition: vtkRearrangeFields.h:139
vtkRearrangeFields::Operation::Next
Operation * Next
Definition: vtkRearrangeFields.h:147
vtkRearrangeFields::Operation::Operation
Operation()
Definition: vtkRearrangeFields.h:148
vtkRearrangeFields::Operation::ToFieldLoc
int ToFieldLoc
Definition: vtkRearrangeFields.h:145
vtkRearrangeFields::Operation::Id
int Id
Definition: vtkRearrangeFields.h:146
vtkRearrangeFields::Operation::OperationType
int OperationType
Definition: vtkRearrangeFields.h:140
vtkRearrangeFields::Operation::FieldType
int FieldType
Definition: vtkRearrangeFields.h:141
vtkRearrangeFields::Operation::~Operation
~Operation()
Definition: vtkRearrangeFields.h:149
vtkRearrangeFields::Operation::FromFieldLoc
int FromFieldLoc
Definition: vtkRearrangeFields.h:144
vtkRearrangeFields::Operation::FieldName
char * FieldName
Definition: vtkRearrangeFields.h:142
vtkRearrangeFields::Operation::AttributeType
int AttributeType
Definition: vtkRearrangeFields.h:143
vtkDataSetAlgorithm.h
vtkDataSetAttributes.h