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 =========================================================================*/
37 #ifndef vtkMergeFields_h
38 #define vtkMergeFields_h
39 
40 #include "vtkFiltersCoreModule.h" // For export macro
41 #include "vtkDataSetAlgorithm.h"
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:
117 
119  {
121  ATTRIBUTE
122  };
123 
124  vtkMergeFields();
125  ~vtkMergeFields() override;
126 
128 
129  char* FieldName;
133 
134  static char FieldLocationNames[3][12];
135 
136 
137  int MergeArray(vtkDataArray* in, vtkDataArray* out, int inComp, int outComp);
138 
139  // Components are stored as a linked list.
142 
143  // Methods to browse/modify the linked list.
145  { return op->Next; }
147  { return this->Head; }
148  void AddComponent(Component* op);
149  Component* FindComponent(int index);
150  void DeleteAllComponents();
151 
152  void PrintComponent(Component* op, ostream& os, vtkIndent indent);
153  void PrintAllComponents(ostream& os, vtkIndent indent);
154 private:
155  vtkMergeFields(const vtkMergeFields&) = delete;
156  void operator=(const vtkMergeFields&) = delete;
157 };
158 
159 #endif
160 
161 
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
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