VTK  9.0.20210224
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 =========================================================================*/
46 #ifndef vtkSplitField_h
47 #define vtkSplitField_h
48 
49 #include "vtkDataSetAlgorithm.h"
50 #include "vtkFiltersGeneralModule.h" // For export macro
51 
52 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
53 
54 class vtkFieldData;
55 
56 class VTKFILTERSGENERAL_EXPORT vtkSplitField : public vtkDataSetAlgorithm
57 {
58 public:
60  void PrintSelf(ostream& os, vtkIndent indent) override;
61 
65  static vtkSplitField* New();
66 
71  void SetInputField(int attributeType, int fieldLoc);
72 
77  void SetInputField(const char* name, int fieldLoc);
78 
83  void SetInputField(const char* name, const char* fieldLoc);
84 
88  void Split(int component, const char* arrayName);
89 
91  {
92  DATA_OBJECT = 0,
93  POINT_DATA = 1,
94  CELL_DATA = 2
95  };
96 
97  struct Component
98  {
99  int Index;
100  char* FieldName;
101  Component* Next; // linked list
102  void SetName(const char* name)
103  {
104  delete[] this->FieldName;
105  this->FieldName = nullptr;
106  if (name)
107  {
108  size_t len = strlen(name) + 1;
109  this->FieldName = new char[len];
110 #ifdef _MSC_VER
111  strncpy_s(this->FieldName, len, name, len - 1);
112 #else
113  strncpy(this->FieldName, name, len);
114 #endif
115  }
116  }
117  Component() { FieldName = nullptr; }
118  ~Component() { delete[] FieldName; }
119  };
120 
121 protected:
123  {
125  ATTRIBUTE
126  };
127 
128  vtkSplitField();
129  ~vtkSplitField() override;
130 
132 
133  char* FieldName;
137 
138  static char FieldLocationNames[3][12];
139  static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
140 
141  vtkDataArray* SplitArray(vtkDataArray* da, int component);
142 
143  // Components are stored as a linked list.
146 
147  // Methods to browse/modify the linked list.
148  Component* GetNextComponent(Component* op) { return op->Next; }
149  Component* GetFirst() { return this->Head; }
150  void AddComponent(Component* op);
151  Component* FindComponent(int index);
152  void DeleteAllComponents();
153 
154  void PrintComponent(Component* op, ostream& os, vtkIndent indent);
155  void PrintAllComponents(ostream& os, vtkIndent indent);
156 
157 private:
158  vtkSplitField(const vtkSplitField&) = delete;
159  void operator=(const vtkSplitField&) = delete;
160 };
161 
162 #endif
vtkSplitField::Component
Definition: vtkSplitField.h:97
vtkSplitField::Component::SetName
void SetName(const char *name)
Definition: vtkSplitField.h:102
vtkX3D::component
Definition: vtkX3D.h:181
vtkSplitField::Component::FieldName
char * FieldName
Definition: vtkSplitField.h:100
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkSplitField::FieldName
char * FieldName
Definition: vtkSplitField.h:133
vtkDataSetAlgorithm::RequestData
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called within ProcessRequest when a request asks the algorithm to do its work.
Definition: vtkDataSetAlgorithm.h:174
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkSplitField::NAME
Definition: vtkSplitField.h:124
vtkFieldData
represent and manipulate fields of data
Definition: vtkFieldData.h:53
vtkSplitField::GetFirst
Component * GetFirst()
Definition: vtkSplitField.h:149
vtkDataSetAlgorithm
Superclass for algorithms that produce output of the same type as input.
Definition: vtkDataSetAlgorithm.h:48
vtkSplitField::FieldType
int FieldType
Definition: vtkSplitField.h:134
vtkSplitField::Component::Next
Component * Next
Definition: vtkSplitField.h:101
vtkSplitField
Split a field into single component fields.
Definition: vtkSplitField.h:56
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkDataSetAlgorithm::New
static vtkDataSetAlgorithm * New()
vtkSplitField::Component::Component
Component()
Definition: vtkSplitField.h:117
vtkSplitField::FieldLocation
int FieldLocation
Definition: vtkSplitField.h:136
vtkX3D::name
Definition: vtkX3D.h:225
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:73
vtkSplitField::Tail
Component * Tail
Definition: vtkSplitField.h:145
vtkSplitField::AttributeType
int AttributeType
Definition: vtkSplitField.h:135
vtkDataSetAlgorithm.h
vtkDataSetAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSplitField::GetNextComponent
Component * GetNextComponent(Component *op)
Definition: vtkSplitField.h:148
vtkSplitField::FieldLocations
FieldLocations
Definition: vtkSplitField.h:90
vtkX3D::index
Definition: vtkX3D.h:252
vtkSplitField::FieldTypes
FieldTypes
Definition: vtkSplitField.h:122
vtkSplitField::Component::~Component
~Component()
Definition: vtkSplitField.h:118
vtkDataSetAttributes.h
vtkDataSetAttributes::NUM_ATTRIBUTES
Definition: vtkDataSetAttributes.h:115
vtkSplitField::Component::Index
int Index
Definition: vtkSplitField.h:99
vtkSplitField::Head
Component * Head
Definition: vtkSplitField.h:144