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 =========================================================================*/
54 #ifndef vtkSplitField_h
55 #define vtkSplitField_h
56 
57 #include "vtkFiltersGeneralModule.h" // For export macro
58 #include "vtkDataSetAlgorithm.h"
59 
60 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
61 
62 class vtkFieldData;
63 
64 class VTKFILTERSGENERAL_EXPORT vtkSplitField : public vtkDataSetAlgorithm
65 {
66 public:
68  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
69 
73  static vtkSplitField *New();
74 
79  void SetInputField(int attributeType, int fieldLoc);
80 
85  void SetInputField(const char* name, int fieldLoc);
86 
91  void SetInputField(const char* name, const char* fieldLoc);
92 
96  void Split(int component, const char* arrayName);
97 
99  {
100  DATA_OBJECT=0,
101  POINT_DATA=1,
102  CELL_DATA=2
103  };
104 
105  struct Component
106  {
107  int Index;
108  char* FieldName;
109  Component* Next; // linked list
110  void SetName(const char* name)
111  {
112  delete[] this->FieldName;
113  this->FieldName = 0;
114  if (name)
115  {
116  size_t len = strlen(name)+1;
117  this->FieldName = new char[len];
118  strncpy(this->FieldName, name, len);
119  }
120  }
121  Component() { FieldName = 0; }
122  ~Component() { delete[] FieldName; }
123  };
124 
125 protected:
126 
128  {
130  ATTRIBUTE
131  };
132 
133  vtkSplitField();
134  ~vtkSplitField() VTK_OVERRIDE;
135 
136  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE;
137 
138  char* FieldName;
139  int FieldType;
140  int AttributeType;
141  int FieldLocation;
142 
143  static char FieldLocationNames[3][12];
144  static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
145 
146  vtkDataArray* SplitArray(vtkDataArray* da, int component);
147 
148 
149  // Components are stored as a linked list.
150  Component* Head;
151  Component* Tail;
152 
153  // Methods to browse/modify the linked list.
154  Component* GetNextComponent(Component* op)
155  { return op->Next; }
157  { return this->Head; }
158  void AddComponent(Component* op);
159  Component* FindComponent(int index);
160  void DeleteAllComponents();
161 
162  void PrintComponent(Component* op, ostream& os, vtkIndent indent);
163  void PrintAllComponents(ostream& os, vtkIndent indent);
164 private:
165  vtkSplitField(const vtkSplitField&) VTK_DELETE_FUNCTION;
166  void operator=(const vtkSplitField&) VTK_DELETE_FUNCTION;
167 };
168 
169 #endif
170 
171 
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:33
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
Split a field into single component fields
Definition: vtkSplitField.h:64
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:53