VTK
dox/Filters/General/vtkSplitField.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkSplitField.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00056 #ifndef __vtkSplitField_h
00057 #define __vtkSplitField_h
00058 
00059 #include "vtkFiltersGeneralModule.h" // For export macro
00060 #include "vtkDataSetAlgorithm.h"
00061 
00062 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
00063 
00064 class vtkFieldData;
00065 
00066 class VTKFILTERSGENERAL_EXPORT vtkSplitField : public vtkDataSetAlgorithm
00067 {
00068 public:
00069   vtkTypeMacro(vtkSplitField,vtkDataSetAlgorithm);
00070   void PrintSelf(ostream& os, vtkIndent indent);
00071 
00073   static vtkSplitField *New();
00074 
00077   void SetInputField(int attributeType, int fieldLoc);
00078 
00081   void SetInputField(const char* name, int fieldLoc);
00082 
00085   void SetInputField(const char* name, const char* fieldLoc);
00086 
00088   void Split(int component, const char* arrayName);
00089 
00090 //BTX
00091   enum FieldLocations
00092   {
00093     DATA_OBJECT=0,
00094     POINT_DATA=1,
00095     CELL_DATA=2
00096   };
00097 //ETX
00098 
00099 //BTX
00100   struct Component
00101   {
00102     int Index;
00103     char* FieldName;
00104     Component* Next;   // linked list
00105     void SetName(const char* name)
00106       {
00107         delete[] this->FieldName;
00108         this->FieldName = 0;
00109         if (name)
00110           {
00111           this->FieldName = new char[strlen(name)+1];
00112           strcpy(this->FieldName, name);
00113           }
00114       }
00115     Component() { FieldName = 0; }
00116     ~Component() { delete[] FieldName; }
00117   };
00118 //ETX
00119 
00120 protected:
00121 
00122 //BTX
00123   enum FieldTypes
00124   {
00125     NAME,
00126     ATTRIBUTE
00127   };
00128 //ETX
00129 
00130   vtkSplitField();
00131   virtual ~vtkSplitField();
00132 
00133   int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00134 
00135   char* FieldName;
00136   int FieldType;
00137   int AttributeType;
00138   int FieldLocation;
00139 
00140   static char FieldLocationNames[3][12];
00141   static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
00142 
00143   vtkDataArray* SplitArray(vtkDataArray* da, int component);
00144 
00145 
00146   // Components are stored as a linked list.
00147   Component* Head;
00148   Component* Tail;
00149 
00150   // Methods to browse/modify the linked list.
00151   Component* GetNextComponent(Component* op)
00152     { return op->Next; }
00153   Component* GetFirst()
00154     { return this->Head; }
00155   void AddComponent(Component* op);
00156   Component* FindComponent(int index);
00157   void DeleteAllComponents();
00158 
00159   void PrintComponent(Component* op, ostream& os, vtkIndent indent);
00160   void PrintAllComponents(ostream& os, vtkIndent indent);
00161 private:
00162   vtkSplitField(const vtkSplitField&);  // Not implemented.
00163   void operator=(const vtkSplitField&);  // Not implemented.
00164 };
00165 
00166 #endif
00167 
00168