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 
46 class vtkDataArray;
47 class vtkFieldData;
48 
49 class VTKFILTERSCORE_EXPORT vtkMergeFields : public vtkDataSetAlgorithm
50 {
51 public:
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
58  static vtkMergeFields* New();
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 
119 protected:
121  {
123  ATTRIBUTE
124  };
125 
126  vtkMergeFields();
127  ~vtkMergeFields() override;
128 
130 
131  char* FieldName;
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.
145  Component* GetNextComponent(Component* op) { return op->Next; }
146  Component* GetFirst() { return this->Head; }
147  void AddComponent(Component* op);
148  Component* FindComponent(int index);
149  void DeleteAllComponents();
150 
151  void PrintComponent(Component* op, ostream& os, vtkIndent indent);
152  void PrintAllComponents(ostream& os, vtkIndent indent);
153 
154 private:
155  vtkMergeFields(const vtkMergeFields&) = delete;
156  void operator=(const vtkMergeFields&) = delete;
157 };
158 
159 #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:39
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
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()
Superclass for algorithms that produce output of the same type as input.
static vtkDataSetAlgorithm * New()
represent and manipulate fields of data
Definition: vtkFieldData.h:62