VTK  9.3.1
vtkSplitField.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
37 #ifndef vtkSplitField_h
38 #define vtkSplitField_h
39 
40 #include "vtkDataSetAlgorithm.h"
41 #include "vtkFiltersGeneralModule.h" // For export macro
42 
43 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
44 
45 VTK_ABI_NAMESPACE_BEGIN
46 class vtkFieldData;
47 
48 class VTKFILTERSGENERAL_EXPORT vtkSplitField : public vtkDataSetAlgorithm
49 {
50 public:
52  void PrintSelf(ostream& os, vtkIndent indent) override;
53 
57  static vtkSplitField* New();
58 
63  void SetInputField(int attributeType, int fieldLoc);
64 
69  void SetInputField(const char* name, int fieldLoc);
70 
75  void SetInputField(const char* name, const char* fieldLoc);
76 
80  void Split(int component, const char* arrayName);
81 
83  {
84  DATA_OBJECT = 0,
85  POINT_DATA = 1,
86  CELL_DATA = 2
87  };
88 
89  struct Component
90  {
91  int Index;
92  char* FieldName;
93  Component* Next; // linked list
94  void SetName(const char* name)
95  {
96  delete[] this->FieldName;
97  this->FieldName = nullptr;
98  if (name)
99  {
100  size_t len = strlen(name) + 1;
101  this->FieldName = new char[len];
102 #ifdef _MSC_VER
103  strncpy_s(this->FieldName, len, name, len - 1);
104 #else
105  strncpy(this->FieldName, name, len);
106 #endif
107  }
108  }
109  Component() { FieldName = nullptr; }
110  ~Component() { delete[] FieldName; }
111  };
112 
113 protected:
115  {
117  ATTRIBUTE
118  };
119 
120  vtkSplitField();
121  ~vtkSplitField() override;
122 
124 
125  char* FieldName;
129 
130  static char FieldLocationNames[3][12];
131  static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
132 
133  vtkDataArray* SplitArray(vtkDataArray* da, int component);
134 
135  // Components are stored as a linked list.
138 
139  // Methods to browse/modify the linked list.
140  Component* GetNextComponent(Component* op) { return op->Next; }
141  Component* GetFirst() { return this->Head; }
142  void AddComponent(Component* op);
143  Component* FindComponent(int index);
144  void DeleteAllComponents();
145 
146  void PrintComponent(Component* op, ostream& os, vtkIndent indent);
147  void PrintAllComponents(ostream& os, vtkIndent indent);
148 
149 private:
150  vtkSplitField(const vtkSplitField&) = delete;
151  void operator=(const vtkSplitField&) = delete;
152 };
153 
154 VTK_ABI_NAMESPACE_END
155 #endif
Component * GetNextComponent(Component *op)
Store vtkAlgorithm input/output information.
void SetName(const char *name)
Definition: vtkSplitField.h:94
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:28
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called within ProcessRequest when a request asks the algorithm to do its work.
Split a field into single component fields.
Definition: vtkSplitField.h:48
Store zero or more vtkInformation instances.
Superclass for algorithms that produce output of the same type as input.
Component * GetFirst()
static vtkDataSetAlgorithm * New()
Component * Head
represent and manipulate fields of data
Definition: vtkFieldData.h:51
Component * Tail