VTK  9.3.20240329
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 
121  ~vtkSplitField() override;
122 
124 
125  char* FieldName;
129 
130  static char FieldLocationNames[3][12];
131  static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
132 
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; }
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
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:155
Superclass for algorithms that produce output of the same type as input.
represent and manipulate fields of data
Definition: vtkFieldData.h:162
a simple class to control print indentation
Definition: vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Split a field into single component fields.
Definition: vtkSplitField.h:49
void DeleteAllComponents()
void SetInputField(int attributeType, int fieldLoc)
Use the given attribute in the field data given by fieldLoc as input.
void SetInputField(const char *name, const char *fieldLoc)
Helper method used by other language bindings.
Component * FindComponent(int index)
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called within ProcessRequest when a request asks the algorithm to do its work.
void Split(int component, const char *arrayName)
Create a new array with the given component.
void PrintComponent(Component *op, ostream &os, vtkIndent indent)
static vtkSplitField * New()
Create a new vtkSplitField.
void PrintAllComponents(ostream &os, vtkIndent indent)
Component * Head
void SetInputField(const char *name, int fieldLoc)
Use the array with given name in the field data given by fieldLoc as input.
Component * GetNextComponent(Component *op)
Component * Tail
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void AddComponent(Component *op)
~vtkSplitField() override
vtkDataArray * SplitArray(vtkDataArray *da, int component)
Component * GetFirst()
@ component
Definition: vtkX3D.h:175
@ name
Definition: vtkX3D.h:219
@ index
Definition: vtkX3D.h:246
void SetName(const char *name)
Definition: vtkSplitField.h:94