VTK  9.0.3
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 =========================================================================*/
54 #ifndef vtkRearrangeFields_h
55 #define vtkRearrangeFields_h
56 
57 #include "vtkDataSetAlgorithm.h"
58 #include "vtkFiltersCoreModule.h" // For export macro
59 
60 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
61 
62 class vtkFieldData;
63 
64 class VTKFILTERSCORE_EXPORT vtkRearrangeFields : public vtkDataSetAlgorithm
65 {
66 public:
68  void PrintSelf(ostream& os, vtkIndent indent) override;
69 
74 
76  {
77  COPY = 0,
78  MOVE = 1
79  };
81  {
82  DATA_OBJECT = 0,
83  POINT_DATA = 1,
84  CELL_DATA = 2
85  };
86 
92  int AddOperation(int operationType, int attributeType, int fromFieldLoc, int toFieldLoc);
98  int AddOperation(int operationType, const char* name, int fromFieldLoc, int toFieldLoc);
104  int AddOperation(const char* operationType, const char* attributeType, const char* fromFieldLoc,
105  const char* toFieldLoc);
106 
110  int RemoveOperation(int operationId);
115  int RemoveOperation(int operationType, int attributeType, int fromFieldLoc, int toFieldLoc);
120  int RemoveOperation(int operationType, const char* name, int fromFieldLoc, int toFieldLoc);
125  int RemoveOperation(const char* operationType, const char* attributeType,
126  const char* fromFieldLoc, const char* toFieldLoc);
127 
129 
133  {
134  this->Modified();
135  this->LastId = 0;
136  this->DeleteAllOperations();
137  }
139 
141  {
143  ATTRIBUTE
144  };
145 
146  struct Operation
147  {
148  int OperationType; // COPY or MOVE
149  int FieldType; // NAME or ATTRIBUTE
150  char* FieldName;
152  int FromFieldLoc; // fd, pd or do
153  int ToFieldLoc; // fd, pd or do
154  int Id; // assigned during creation
155  Operation* Next; // linked list
156  Operation() { FieldName = nullptr; }
157  ~Operation() { delete[] FieldName; }
158  };
159 
160 protected:
163 
165 
166  // Operations are stored as a linked list.
169  // This is incremented whenever a new operation is created.
170  // It is not decremented when an operation is deleted.
171  int LastId;
172 
173  // Methods to browse/modify the linked list.
174  Operation* GetNextOperation(Operation* op) { return op->Next; }
175  Operation* GetFirst() { return this->Head; }
177  void DeleteOperation(Operation* op, Operation* before);
178  Operation* FindOperation(int id, Operation*& before);
179  Operation* FindOperation(const char* name, Operation*& before);
181  int operationType, const char* name, int fromFieldLoc, int toFieldLoc, Operation*& before);
183  int operationType, int attributeType, int fromFieldLoc, int toFieldLoc, Operation*& before);
184  // Used when finding/deleting an operation given a signature.
185  int CompareOperationsByType(const Operation* op1, const Operation* op2);
186  int CompareOperationsByName(const Operation* op1, const Operation* op2);
187 
189  void ApplyOperation(Operation* op, vtkDataSet* input, vtkDataSet* output);
190  // Given location (DATA_OBJECT, CELL_DATA, POINT_DATA) return the
191  // pointer to the corresponding field data.
193 
194  // Used by AddOperation() and RemoveOperation() designed to be used
195  // from other language bindings.
196  static char OperationTypeNames[2][5];
197  static char FieldLocationNames[3][12];
198  static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
199 
200  void PrintAllOperations(ostream& os, vtkIndent indent);
201  void PrintOperation(Operation* op, ostream& os, vtkIndent indent);
202 
203 private:
204  vtkRearrangeFields(const vtkRearrangeFields&) = delete;
205  void operator=(const vtkRearrangeFields&) = delete;
206 };
207 
208 #endif
Superclass for algorithms that produce output of the same type as input.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:57
represent and manipulate fields of data
Definition: vtkFieldData.h:54
a simple class to control print indentation
Definition: vtkIndent.h:34
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)
vtkFieldData * GetFieldDataFromLocation(vtkDataSet *ds, int fieldLoc)
void AddOperation(Operation *op)
Operation * FindOperation(int operationType, int attributeType, int fromFieldLoc, int toFieldLoc, Operation *&before)
int RemoveOperation(int operationId)
Remove an operation with the given id.
void DeleteOperation(Operation *op, Operation *before)
~vtkRearrangeFields() override
void RemoveAllOperations()
Remove all operations.
Operation * FindOperation(int id, Operation *&before)
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)
Operation * FindOperation(int operationType, const char *name, int fromFieldLoc, int toFieldLoc, Operation *&before)
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.
static vtkRearrangeFields * New()
Create a new vtkRearrangeFields with an empty operation list.
Operation * FindOperation(const char *name, 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.
int RemoveOperation(int operationType, const char *name, int fromFieldLoc, int toFieldLoc)
Remove an operation with the given signature.
Operation * GetNextOperation(Operation *op)
int RemoveOperation(int operationType, int attributeType, int fromFieldLoc, int toFieldLoc)
Remove an operation with the given signature.
void DeleteAllOperations()
@ name
Definition: vtkX3D.h:225