VTK
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 "vtkFiltersCoreModule.h" // For export macro
44 #include "vtkDataSetAlgorithm.h"
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:
120 
122  {
124  ATTRIBUTE
125  };
126 
127  vtkMergeFields();
128  ~vtkMergeFields() override;
129 
130  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override;
131 
132  char* FieldName;
136 
137  static char FieldLocationNames[3][12];
138 
139 
140  int MergeArray(vtkDataArray* in, vtkDataArray* out, int inComp, int outComp);
141 
142  // Components are stored as a linked list.
145 
146  // Methods to browse/modify the linked list.
148  { return op->Next; }
150  { return this->Head; }
151  void AddComponent(Component* op);
152  Component* FindComponent(int index);
153  void DeleteAllComponents();
154 
155  void PrintComponent(Component* op, ostream& os, vtkIndent indent);
156  void PrintAllComponents(ostream& os, vtkIndent indent);
157 private:
158  vtkMergeFields(const vtkMergeFields&) = delete;
159  void operator=(const vtkMergeFields&) = delete;
160 };
161 
162 #endif
163 
164 
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:54
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:56