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 =========================================================================*/
57 #ifndef vtkSplitField_h
58 #define vtkSplitField_h
59 
60 #include "vtkFiltersGeneralModule.h" // For export macro
61 #include "vtkDataSetAlgorithm.h"
62 
63 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
64 
65 class vtkFieldData;
66 
67 class VTKFILTERSGENERAL_EXPORT vtkSplitField : public vtkDataSetAlgorithm
68 {
69 public:
71  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
72 
76  static vtkSplitField *New();
77 
82  void SetInputField(int attributeType, int fieldLoc);
83 
88  void SetInputField(const char* name, int fieldLoc);
89 
94  void SetInputField(const char* name, const char* fieldLoc);
95 
99  void Split(int component, const char* arrayName);
100 
102  {
103  DATA_OBJECT=0,
104  POINT_DATA=1,
105  CELL_DATA=2
106  };
107 
108  struct Component
109  {
110  int Index;
111  char* FieldName;
112  Component* Next; // linked list
113  void SetName(const char* name)
114  {
115  delete[] this->FieldName;
116  this->FieldName = 0;
117  if (name)
118  {
119  size_t len = strlen(name)+1;
120  this->FieldName = new char[len];
121  strncpy(this->FieldName, name, len);
122  }
123  }
124  Component() { FieldName = 0; }
125  ~Component() { delete[] FieldName; }
126  };
127 
128 protected:
129 
131  {
133  ATTRIBUTE
134  };
135 
136  vtkSplitField();
137  ~vtkSplitField() VTK_OVERRIDE;
138 
139  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE;
140 
141  char* FieldName;
142  int FieldType;
143  int AttributeType;
144  int FieldLocation;
145 
146  static char FieldLocationNames[3][12];
147  static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
148 
149  vtkDataArray* SplitArray(vtkDataArray* da, int component);
150 
151 
152  // Components are stored as a linked list.
153  Component* Head;
154  Component* Tail;
155 
156  // Methods to browse/modify the linked list.
157  Component* GetNextComponent(Component* op)
158  { return op->Next; }
160  { return this->Head; }
161  void AddComponent(Component* op);
162  Component* FindComponent(int index);
163  void DeleteAllComponents();
164 
165  void PrintComponent(Component* op, ostream& os, vtkIndent indent);
166  void PrintAllComponents(ostream& os, vtkIndent indent);
167 private:
168  vtkSplitField(const vtkSplitField&) VTK_DELETE_FUNCTION;
169  void operator=(const vtkSplitField&) VTK_DELETE_FUNCTION;
170 };
171 
172 #endif
173 
174 
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:67
represent and manipulate attribute data in a dataset
Store zero or more vtkInformation instances.
Superclass for algorithms that produce output of the same type as input.
Component * GetFirst()
static vtkDataSetAlgorithm * New()
represent and manipulate fields of data
Definition: vtkFieldData.h:56