VTK
vtkSplitField.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSplitField.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 =========================================================================*/
49 #ifndef vtkSplitField_h
50 #define vtkSplitField_h
51 
52 #include "vtkFiltersGeneralModule.h" // For export macro
53 #include "vtkDataSetAlgorithm.h"
54 
55 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
56 
57 class vtkFieldData;
58 
59 class VTKFILTERSGENERAL_EXPORT vtkSplitField : public vtkDataSetAlgorithm
60 {
61 public:
63  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
68  static vtkSplitField *New();
69 
74  void SetInputField(int attributeType, int fieldLoc);
75 
80  void SetInputField(const char* name, int fieldLoc);
81 
86  void SetInputField(const char* name, const char* fieldLoc);
87 
91  void Split(int component, const char* arrayName);
92 
94  {
95  DATA_OBJECT=0,
96  POINT_DATA=1,
97  CELL_DATA=2
98  };
99 
100  struct Component
101  {
102  int Index;
103  char* FieldName;
104  Component* Next; // linked list
105  void SetName(const char* name)
106  {
107  delete[] this->FieldName;
108  this->FieldName = nullptr;
109  if (name)
110  {
111  size_t len = strlen(name)+1;
112  this->FieldName = new char[len];
113 #ifdef _MSC_VER
114  strncpy_s(this->FieldName, len, name, len - 1);
115 #else
116  strncpy(this->FieldName, name, len);
117 #endif
118  }
119  }
120  Component() { FieldName = nullptr; }
121  ~Component() { delete[] FieldName; }
122  };
123 
124 protected:
125 
127  {
129  ATTRIBUTE
130  };
131 
132  vtkSplitField();
133  ~vtkSplitField() override;
134 
135  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override;
136 
137  char* FieldName;
141 
142  static char FieldLocationNames[3][12];
143  static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
144 
145  vtkDataArray* SplitArray(vtkDataArray* da, int component);
146 
147 
148  // Components are stored as a linked list.
151 
152  // Methods to browse/modify the linked list.
154  { return op->Next; }
156  { return this->Head; }
157  void AddComponent(Component* op);
158  Component* FindComponent(int index);
159  void DeleteAllComponents();
160 
161  void PrintComponent(Component* op, ostream& os, vtkIndent indent);
162  void PrintAllComponents(ostream& os, vtkIndent indent);
163 private:
164  vtkSplitField(const vtkSplitField&) = delete;
165  void operator=(const vtkSplitField&) = delete;
166 };
167 
168 #endif
169 
170 
Component * GetNextComponent(Component *op)
Store vtkAlgorithm input/output information.
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
Split a field into single component fields.
Definition: vtkSplitField.h:59
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:56
Component * Tail