VTK  9.2.6
vtkMergeFields.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkMergeFields.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=========================================================================*/
40#ifndef vtkMergeFields_h
41#define vtkMergeFields_h
42
43#include "vtkDataSetAlgorithm.h"
44#include "vtkFiltersCoreModule.h" // For export macro
45
46class vtkDataArray;
47class vtkFieldData;
48
49class VTKFILTERSCORE_EXPORT vtkMergeFields : public vtkDataSetAlgorithm
50{
51public:
53 void PrintSelf(ostream& os, vtkIndent indent) override;
54
59
64 void SetOutputField(const char* name, int fieldLoc);
65
71 void SetOutputField(const char* name, const char* fieldLoc);
72
76 void Merge(int component, const char* arrayName, int sourceComp);
77
79
83 vtkSetMacro(NumberOfComponents, int);
84 vtkGetMacro(NumberOfComponents, int);
86
88 {
89 DATA_OBJECT = 0,
90 POINT_DATA = 1,
91 CELL_DATA = 2
92 };
93
94 struct Component
95 {
96 int Index;
98 char* FieldName;
99 Component* Next; // linked list
100 void SetName(const char* name)
101 {
102 delete[] this->FieldName;
103 this->FieldName = nullptr;
104 if (name)
105 {
106 size_t len = strlen(name) + 1;
107 this->FieldName = new char[len];
108#ifdef _MSC_VER
109 strncpy_s(this->FieldName, len, name, len - 1);
110#else
111 strncpy(this->FieldName, name, len);
112#endif
113 }
114 }
115 Component() { FieldName = nullptr; }
116 ~Component() { delete[] FieldName; }
117 };
118
119protected:
121 {
123 ATTRIBUTE
124 };
125
127 ~vtkMergeFields() override;
128
130
135
136 static char FieldLocationNames[3][12];
137
138 int MergeArray(vtkDataArray* in, vtkDataArray* out, int inComp, int outComp);
139
140 // Components are stored as a linked list.
143
144 // Methods to browse/modify the linked list.
146 Component* GetFirst() { return this->Head; }
150
151 void PrintComponent(Component* op, ostream& os, vtkIndent indent);
152 void PrintAllComponents(ostream& os, vtkIndent indent);
153
154private:
155 vtkMergeFields(const vtkMergeFields&) = delete;
156 void operator=(const vtkMergeFields&) = delete;
157};
158
159#endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:56
Superclass for algorithms that produce output of the same type as input.
represent and manipulate fields of data
Definition: vtkFieldData.h:63
a simple class to control print indentation
Definition: vtkIndent.h:40
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)