VTK  9.4.20241217
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
34VTK_ABI_NAMESPACE_BEGIN
35class vtkDataArray;
36class vtkFieldData;
37
38class VTKFILTERSCORE_EXPORT vtkMergeFields : public vtkDataSetAlgorithm
39{
40public:
42 void PrintSelf(ostream& os, vtkIndent indent) override;
43
48
53 void SetOutputField(const char* name, int fieldLoc);
54
60 void SetOutputField(const char* name, const char* fieldLoc);
61
65 void Merge(int component, const char* arrayName, int sourceComp);
66
68
72 vtkSetMacro(NumberOfComponents, int);
73 vtkGetMacro(NumberOfComponents, int);
75
77 {
78 DATA_OBJECT = 0,
79 POINT_DATA = 1,
80 CELL_DATA = 2
81 };
82
83 struct Component
84 {
85 int Index;
87 char* FieldName;
88 Component* Next; // linked list
89 void SetName(const char* name)
90 {
91 delete[] this->FieldName;
92 this->FieldName = nullptr;
93 if (name)
94 {
95 size_t len = strlen(name) + 1;
96 this->FieldName = new char[len];
97#ifdef _MSC_VER
98 strncpy_s(this->FieldName, len, name, len - 1);
99#else
100 strncpy(this->FieldName, name, len);
101#endif
102 }
103 }
104 Component() { FieldName = nullptr; }
105 ~Component() { delete[] FieldName; }
106 };
107
108protected:
110 {
112 ATTRIBUTE
113 };
114
116 ~vtkMergeFields() override;
117
119
124
125 static char FieldLocationNames[3][12];
126
127 int MergeArray(vtkDataArray* in, vtkDataArray* out, int inComp, int outComp);
128
129 // Components are stored as a linked list.
132
133 // Methods to browse/modify the linked list.
135 Component* GetFirst() { return this->Head; }
139
140 void PrintComponent(Component* op, ostream& os, vtkIndent indent);
141 void PrintAllComponents(ostream& os, vtkIndent indent);
142
143private:
144 vtkMergeFields(const vtkMergeFields&) = delete;
145 void operator=(const vtkMergeFields&) = delete;
146};
147
148VTK_ABI_NAMESPACE_END
149#endif
abstract superclass for arrays of numeric data
Superclass for algorithms that produce output of the same type as input.
represent and manipulate fields of data
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Merge multiple fields into one.
Component * Tail
static vtkMergeFields * New()
Create a new vtkMergeFields.
void DeleteAllComponents()
int MergeArray(vtkDataArray *in, vtkDataArray *out, int inComp, int outComp)
void PrintComponent(Component *op, ostream &os, vtkIndent indent)
Component * GetFirst()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
~vtkMergeFields() override
void Merge(int component, const char *arrayName, int sourceComp)
Add a component (arrayName,sourceComp) to the output field.
Component * Head
void SetOutputField(const char *name, const char *fieldLoc)
Helper method used by the other language bindings.
void PrintAllComponents(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.
Component * FindComponent(int index)
Component * GetNextComponent(Component *op)
void SetOutputField(const char *name, int fieldLoc)
The output field will have the given name and it will be in fieldLoc (the input fields also have to b...
void AddComponent(Component *op)
void SetName(const char *name)