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 =========================================================================*/
56 #ifndef __vtkSplitField_h
57 #define __vtkSplitField_h
58 
59 #include "vtkDataSetAlgorithm.h"
60 
61 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
62 
63 class vtkFieldData;
64 
66 {
67 public:
69  void PrintSelf(ostream& os, vtkIndent indent);
70 
72  static vtkSplitField *New();
73 
76  void SetInputField(int attributeType, int fieldLoc);
77 
80  void SetInputField(const char* name, int fieldLoc);
81 
84  void SetInputField(const char* name, const char* fieldLoc);
85 
87  void Split(int component, const char* arrayName);
88 
89 //BTX
91  {
92  DATA_OBJECT=0,
93  POINT_DATA=1,
94  CELL_DATA=2
95  };
96 //ETX
97 
98 //BTX
99  struct Component
100  {
101  int Index;
102  char* FieldName;
103  Component* Next; // linked list
104  void SetName(const char* name)
105  {
106  delete[] this->FieldName;
107  this->FieldName = 0;
108  if (name)
109  {
110  this->FieldName = new char[strlen(name)+1];
111  strcpy(this->FieldName, name);
112  }
113  }
114  Component() { FieldName = 0; }
115  ~Component() { delete[] FieldName; }
116  };
117 //ETX
118 
119 protected:
120 
121 //BTX
123  {
125  ATTRIBUTE
126  };
127 //ETX
128 
129  vtkSplitField();
130  virtual ~vtkSplitField();
131 
133 
134  char* FieldName;
138 
139  static char FieldLocationNames[3][12];
140  static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
141 
142  vtkDataArray* SplitArray(vtkDataArray* da, int component);
143 
144 
145  // Components are stored as a linked list.
148 
149  // Methods to browse/modify the linked list.
151  { return op->Next; }
153  { return this->Head; }
154  void AddComponent(Component* op);
155  Component* FindComponent(int index);
156  void DeleteAllComponents();
157 
158  void PrintComponent(Component* op, ostream& os, vtkIndent indent);
159  void PrintAllComponents(ostream& os, vtkIndent indent);
160 private:
161  vtkSplitField(const vtkSplitField&); // Not implemented.
162  void operator=(const vtkSplitField&); // Not implemented.
163 };
164 
165 #endif
166 
167