VTK  9.0.1
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 =========================================================================*/
37 #ifndef vtkMergeFields_h
38 #define vtkMergeFields_h
39 
40 #include "vtkDataSetAlgorithm.h"
41 #include "vtkFiltersCoreModule.h" // For export macro
42 
43 class vtkDataArray;
44 class vtkFieldData;
45 
46 class VTKFILTERSCORE_EXPORT vtkMergeFields : public vtkDataSetAlgorithm
47 {
48 public:
50  void PrintSelf(ostream& os, vtkIndent indent) override;
51 
55  static vtkMergeFields* New();
56 
61  void SetOutputField(const char* name, int fieldLoc);
62 
68  void SetOutputField(const char* name, const char* fieldLoc);
69 
73  void Merge(int component, const char* arrayName, int sourceComp);
74 
76 
80  vtkSetMacro(NumberOfComponents, int);
81  vtkGetMacro(NumberOfComponents, int);
83 
85  {
86  DATA_OBJECT = 0,
87  POINT_DATA = 1,
88  CELL_DATA = 2
89  };
90 
91  struct Component
92  {
93  int Index;
95  char* FieldName;
96  Component* Next; // linked list
97  void SetName(const char* name)
98  {
99  delete[] this->FieldName;
100  this->FieldName = nullptr;
101  if (name)
102  {
103  size_t len = strlen(name) + 1;
104  this->FieldName = new char[len];
105 #ifdef _MSC_VER
106  strncpy_s(this->FieldName, len, name, len - 1);
107 #else
108  strncpy(this->FieldName, name, len);
109 #endif
110  }
111  }
112  Component() { FieldName = nullptr; }
113  ~Component() { delete[] FieldName; }
114  };
115 
116 protected:
118  {
120  ATTRIBUTE
121  };
122 
123  vtkMergeFields();
124  ~vtkMergeFields() override;
125 
127 
128  char* FieldName;
132 
133  static char FieldLocationNames[3][12];
134 
135  int MergeArray(vtkDataArray* in, vtkDataArray* out, int inComp, int outComp);
136 
137  // Components are stored as a linked list.
140 
141  // Methods to browse/modify the linked list.
142  Component* GetNextComponent(Component* op) { return op->Next; }
143  Component* GetFirst() { return this->Head; }
144  void AddComponent(Component* op);
145  Component* FindComponent(int index);
146  void DeleteAllComponents();
147 
148  void PrintComponent(Component* op, ostream& os, vtkIndent indent);
149  void PrintAllComponents(ostream& os, vtkIndent indent);
150 
151 private:
152  vtkMergeFields(const vtkMergeFields&) = delete;
153  void operator=(const vtkMergeFields&) = delete;
154 };
155 
156 #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:33
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
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:53