VTK  9.7.1
vtkMergeFields.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
28 #ifndef vtkMergeFields_h
29 #define vtkMergeFields_h
30 
31 #include "vtkDataSetAlgorithm.h"
32 #include "vtkFiltersCoreModule.h" // For export macro
33 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
34 
35 VTK_ABI_NAMESPACE_BEGIN
36 class vtkDataArray;
37 class vtkFieldData;
38 
39 class VTKFILTERSCORE_EXPORT VTK_MARSHALAUTO vtkMergeFields : public vtkDataSetAlgorithm
40 {
41 public:
43  void PrintSelf(ostream& os, vtkIndent indent) override;
44 
48  static vtkMergeFields* New();
49 
54  void SetOutputField(const char* name, int fieldLoc);
55 
61  void SetOutputField(const char* name, const char* fieldLoc);
62 
66  void Merge(int component, const char* arrayName, int sourceComp);
67 
69 
73  vtkSetMacro(NumberOfComponents, int);
74  vtkGetMacro(NumberOfComponents, int);
76 
78  {
79  DATA_OBJECT = 0,
80  POINT_DATA = 1,
81  CELL_DATA = 2
82  };
83 
84  struct Component
85  {
86  int Index;
88  char* FieldName;
89  Component* Next; // linked list
90  void SetName(const char* name)
91  {
92  delete[] this->FieldName;
93  this->FieldName = nullptr;
94  if (name)
95  {
96  size_t len = strlen(name) + 1;
97  this->FieldName = new char[len];
98 #ifdef _MSC_VER
99  strncpy_s(this->FieldName, len, name, len - 1);
100 #else
101  strncpy(this->FieldName, name, len);
102 #endif
103  }
104  }
105  Component() { FieldName = nullptr; }
106  ~Component() { delete[] FieldName; }
107  };
108 
109 protected:
111  {
113  ATTRIBUTE
114  };
115 
116  vtkMergeFields();
117  ~vtkMergeFields() override;
118 
120 
121  char* FieldName;
125 
126  static char FieldLocationNames[3][12];
127 
128  int MergeArray(vtkDataArray* in, vtkDataArray* out, int inComp, int outComp);
129 
130  // Components are stored as a linked list.
133 
134  // Methods to browse/modify the linked list.
135  Component* GetNextComponent(Component* op) { return op->Next; }
136  Component* GetFirst() { return this->Head; }
137  void AddComponent(Component* op);
138  Component* FindComponent(int index);
139  void DeleteAllComponents();
140 
141  void PrintComponent(Component* op, ostream& os, vtkIndent indent);
142  void PrintAllComponents(ostream& os, vtkIndent indent);
143 
144 private:
145  vtkMergeFields(const vtkMergeFields&) = delete;
146  void operator=(const vtkMergeFields&) = delete;
147 };
148 
149 VTK_ABI_NAMESPACE_END
150 #endif
Store vtkAlgorithm input/output information.
Merge multiple fields into one.
void SetName(const char *name)
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:28
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called within ProcessRequest when a request asks the algorithm to do its work.
Component * Head
Component * Tail
Store zero or more vtkInformation instances.
Component * GetNextComponent(Component *op)
Component * GetFirst()
#define VTK_MARSHALAUTO
Superclass for algorithms that produce output of the same type as input.
static vtkDataSetAlgorithm * New()
Represents and manipulates a collection of data arrays.
Definition: vtkFieldData.h:51