VTK  9.5.20250904
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
35VTK_ABI_NAMESPACE_BEGIN
36class vtkDataArray;
37class vtkFieldData;
38
39class VTKFILTERSCORE_EXPORT VTK_MARSHALAUTO vtkMergeFields : public vtkDataSetAlgorithm
40{
41public:
43 void PrintSelf(ostream& os, vtkIndent indent) override;
44
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
109protected:
111 {
113 ATTRIBUTE
114 };
115
117 ~vtkMergeFields() override;
118
120
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.
136 Component* GetFirst() { return this->Head; }
140
141 void PrintComponent(Component* op, ostream& os, vtkIndent indent);
142 void PrintAllComponents(ostream& os, vtkIndent indent);
143
144private:
145 vtkMergeFields(const vtkMergeFields&) = delete;
146 void operator=(const vtkMergeFields&) = delete;
147};
148
149VTK_ABI_NAMESPACE_END
150#endif
abstract superclass for arrays of numeric data
Superclass for algorithms that produce output of the same type as input.
Represents and manipulates a collection of data arrays.
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)
#define VTK_MARSHALAUTO