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 =========================================================================*/
45 #ifndef vtkMergeFields_h
46 #define vtkMergeFields_h
47 
48 #include "vtkFiltersCoreModule.h" // For export macro
49 #include "vtkDataSetAlgorithm.h"
50 
51 class vtkDataArray;
52 class vtkFieldData;
53 
54 class VTKFILTERSCORE_EXPORT vtkMergeFields : public vtkDataSetAlgorithm
55 {
56 public:
58  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
59 
63  static vtkMergeFields *New();
64 
69  void SetOutputField(const char* name, int fieldLoc);
70 
76  void SetOutputField(const char* name, const char* fieldLoc);
77 
81  void Merge(int component, const char* arrayName, int sourceComp);
82 
84 
88  vtkSetMacro(NumberOfComponents, int);
89  vtkGetMacro(NumberOfComponents, int);
91 
93  {
94  DATA_OBJECT=0,
95  POINT_DATA=1,
96  CELL_DATA=2
97  };
98 
99  struct Component
100  {
101  int Index;
103  char* FieldName;
104  Component* Next; // linked list
105  void SetName(const char* name)
106  {
107  delete[] this->FieldName;
108  this->FieldName = 0;
109  if (name)
110  {
111  size_t len = strlen(name)+1;
112  this->FieldName = new char[len];
113  strncpy(this->FieldName, name, len);
114  }
115  }
116  Component() { FieldName = 0; }
117  ~Component() { delete[] FieldName; }
118  };
119 
120 protected:
121 
123  {
125  ATTRIBUTE
126  };
127 
128  vtkMergeFields();
129  ~vtkMergeFields() VTK_OVERRIDE;
130 
131  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE;
132 
133  char* FieldName;
134  int FieldLocation;
135  int NumberOfComponents;
136  int OutputDataType;
137 
138  static char FieldLocationNames[3][12];
139 
140 
141  int MergeArray(vtkDataArray* in, vtkDataArray* out, int inComp, int outComp);
142 
143  // Components are stored as a linked list.
144  Component* Head;
145  Component* Tail;
146 
147  // Methods to browse/modify the linked list.
148  Component* GetNextComponent(Component* op)
149  { return op->Next; }
151  { return this->Head; }
152  void AddComponent(Component* op);
153  Component* FindComponent(int index);
154  void DeleteAllComponents();
155 
156  void PrintComponent(Component* op, ostream& os, vtkIndent indent);
157  void PrintAllComponents(ostream& os, vtkIndent indent);
158 private:
159  vtkMergeFields(const vtkMergeFields&) VTK_DELETE_FUNCTION;
160  void operator=(const vtkMergeFields&) VTK_DELETE_FUNCTION;
161 };
162 
163 #endif
164 
165 
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:48
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:53