VTK
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 =========================================================================*/
58 #ifndef vtkRearrangeFields_h
59 #define vtkRearrangeFields_h
60 
61 #include "vtkFiltersCoreModule.h" // For export macro
62 #include "vtkDataSetAlgorithm.h"
63 
64 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
65 
66 class vtkFieldData;
67 
68 class VTKFILTERSCORE_EXPORT vtkRearrangeFields : public vtkDataSetAlgorithm
69 {
70 public:
72  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
73 
77  static vtkRearrangeFields *New();
78 
80  {
81  COPY=0,
82  MOVE=1
83  };
85  {
86  DATA_OBJECT=0,
87  POINT_DATA=1,
88  CELL_DATA=2
89  };
90 
96  int AddOperation(int operationType, int attributeType, int fromFieldLoc,
97  int toFieldLoc);
103  int AddOperation(int operationType, const char* name, int fromFieldLoc,
104  int toFieldLoc);
110  int AddOperation(const char* operationType, const char* attributeType,
111  const char* fromFieldLoc, const char* toFieldLoc);
112 
116  int RemoveOperation(int operationId);
121  int RemoveOperation(int operationType, int attributeType, int fromFieldLoc,
122  int toFieldLoc);
127  int RemoveOperation(int operationType, const char* name, int fromFieldLoc,
128  int toFieldLoc);
133  int RemoveOperation(const char* operationType, const char* attributeType,
134  const char* fromFieldLoc, const char* toFieldLoc);
135 
137 
141  {
142  this->Modified();
143  this->LastId = 0;
144  this->DeleteAllOperations();
145  }
147 
149  {
151  ATTRIBUTE
152  };
153 
154  struct Operation
155  {
156  int OperationType; // COPY or MOVE
157  int FieldType; // NAME or ATTRIBUTE
158  char* FieldName;
160  int FromFieldLoc; // fd, pd or do
161  int ToFieldLoc; // fd, pd or do
162  int Id; // assigned during creation
163  Operation* Next; // linked list
164  Operation() { FieldName = 0; }
165  ~Operation() { delete[] FieldName; }
166  };
167 
168 protected:
169 
171  ~vtkRearrangeFields() VTK_OVERRIDE;
172 
173  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE;
174 
175 
176  // Operations are stored as a linked list.
179  // This is incremented whenever a new operation is created.
180  // It is not decremented when an operation is deleted.
181  int LastId;
182 
183  // Methods to browse/modify the linked list.
185  { return op->Next; }
187  { return this->Head; }
188  void AddOperation(Operation* op);
189  void DeleteOperation(Operation* op, Operation* before);
190  Operation* FindOperation(int id, Operation*& before);
191  Operation* FindOperation(const char* name, Operation*& before);
192  Operation* FindOperation(int operationType, const char* name,
193  int fromFieldLoc, int toFieldLoc,
194  Operation*& before);
195  Operation* FindOperation(int operationType, int attributeType,
196  int fromFieldLoc, int toFieldLoc,
197  Operation*& before);
198  // Used when finding/deleting an operation given a signature.
199  int CompareOperationsByType(const Operation* op1, const Operation* op2);
200  int CompareOperationsByName(const Operation* op1, const Operation* op2);
201 
202  void DeleteAllOperations();
203  void ApplyOperation(Operation* op, vtkDataSet* input, vtkDataSet* output);
204  // Given location (DATA_OBJECT, CELL_DATA, POINT_DATA) return the
205  // pointer to the corresponding field data.
206  vtkFieldData* GetFieldDataFromLocation(vtkDataSet* ds, int fieldLoc);
207 
208  // Used by AddOperation() and RemoveOperation() designed to be used
209  // from other language bindings.
210  static char OperationTypeNames[2][5];
211  static char FieldLocationNames[3][12];
212  static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
213 
214  void PrintAllOperations(ostream& os, vtkIndent indent);
215  void PrintOperation(Operation* op, ostream& os, vtkIndent indent);
216 private:
217  vtkRearrangeFields(const vtkRearrangeFields&) VTK_DELETE_FUNCTION;
218  void operator=(const vtkRearrangeFields&) VTK_DELETE_FUNCTION;
219 };
220 
221 #endif
222 
223 
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
Definition: vtkIndent.h:33
virtual void Modified()
Update the modification time for this object.
void RemoveAllOperations()
Remove all operations.
Store zero or more vtkInformation instances.
Move/copy fields between field data, point data and cell data.
Superclass for algorithms that produce output of the same type as input.
static vtkDataSetAlgorithm * New()
Operation * GetNextOperation(Operation *op)
represent and manipulate fields of data
Definition: vtkFieldData.h:53