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 =========================================================================*/
48 #ifndef vtkMergeFields_h
49 #define vtkMergeFields_h
50 
51 #include "vtkFiltersCoreModule.h" // For export macro
52 #include "vtkDataSetAlgorithm.h"
53 
54 class vtkDataArray;
55 class vtkFieldData;
56 
57 class VTKFILTERSCORE_EXPORT vtkMergeFields : public vtkDataSetAlgorithm
58 {
59 public:
61  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
62 
66  static vtkMergeFields *New();
67 
72  void SetOutputField(const char* name, int fieldLoc);
73 
79  void SetOutputField(const char* name, const char* fieldLoc);
80 
84  void Merge(int component, const char* arrayName, int sourceComp);
85 
87 
91  vtkSetMacro(NumberOfComponents, int);
92  vtkGetMacro(NumberOfComponents, int);
94 
96  {
97  DATA_OBJECT=0,
98  POINT_DATA=1,
99  CELL_DATA=2
100  };
101 
102  struct Component
103  {
104  int Index;
106  char* FieldName;
107  Component* Next; // linked list
108  void SetName(const char* name)
109  {
110  delete[] this->FieldName;
111  this->FieldName = 0;
112  if (name)
113  {
114  size_t len = strlen(name)+1;
115  this->FieldName = new char[len];
116  strncpy(this->FieldName, name, len);
117  }
118  }
119  Component() { FieldName = 0; }
120  ~Component() { delete[] FieldName; }
121  };
122 
123 protected:
124 
126  {
128  ATTRIBUTE
129  };
130 
131  vtkMergeFields();
132  ~vtkMergeFields() VTK_OVERRIDE;
133 
134  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE;
135 
136  char* FieldName;
137  int FieldLocation;
138  int NumberOfComponents;
139  int OutputDataType;
140 
141  static char FieldLocationNames[3][12];
142 
143 
144  int MergeArray(vtkDataArray* in, vtkDataArray* out, int inComp, int outComp);
145 
146  // Components are stored as a linked list.
147  Component* Head;
148  Component* Tail;
149 
150  // Methods to browse/modify the linked list.
151  Component* GetNextComponent(Component* op)
152  { return op->Next; }
154  { return this->Head; }
155  void AddComponent(Component* op);
156  Component* FindComponent(int index);
157  void DeleteAllComponents();
158 
159  void PrintComponent(Component* op, ostream& os, vtkIndent indent);
160  void PrintAllComponents(ostream& os, vtkIndent indent);
161 private:
162  vtkMergeFields(const vtkMergeFields&) VTK_DELETE_FUNCTION;
163  void operator=(const vtkMergeFields&) VTK_DELETE_FUNCTION;
164 };
165 
166 #endif
167 
168 
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
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
Store zero or more vtkInformation instances.
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