VTK  9.1.0
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 
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; }
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
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
Superclass for algorithms that produce output of the same type as input.
represent and manipulate fields of data
Definition: vtkFieldData.h:55
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Merge multiple fields into one.
Component * FindComponent(int index)
Component * Tail
void DeleteAllComponents()
static vtkMergeFields * New()
Create a new vtkMergeFields.
int MergeArray(vtkDataArray *in, vtkDataArray *out, int inComp, int outComp)
void PrintComponent(Component *op, ostream &os, vtkIndent indent)
Component * GetFirst()
Component * GetNextComponent(Component *op)
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.
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)
@ component
Definition: vtkX3D.h:181
@ name
Definition: vtkX3D.h:225
@ index
Definition: vtkX3D.h:252
void SetName(const char *name)