Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkSplitField.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkSplitField.h,v $
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 =========================================================================*/
00067 #ifndef __vtkSplitField_h
00068 #define __vtkSplitField_h
00069 
00070 #include "vtkDataSetToDataSetFilter.h"
00071 
00072 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
00073 
00074 class vtkFieldData;
00075 
00076 class VTK_GRAPHICS_EXPORT vtkSplitField : public vtkDataSetToDataSetFilter
00077 {
00078 public:
00079   vtkTypeRevisionMacro(vtkSplitField,vtkDataSetToDataSetFilter);
00080   void PrintSelf(ostream& os, vtkIndent indent);
00081 
00083   static vtkSplitField *New();
00084 
00087   void SetInputField(int attributeType, int fieldLoc);
00088 
00091   void SetInputField(const char* name, int fieldLoc);
00092 
00095   void SetInputField(const char* name, const char* fieldLoc);
00096 
00098   void Split(int component, const char* arrayName);
00099 
00100 //BTX
00101   enum FieldLocations
00102   {
00103     DATA_OBJECT=0,
00104     POINT_DATA=1,
00105     CELL_DATA=2
00106   };
00107 //ETX
00108 
00109 //BTX
00110   struct Component
00111   {
00112     int Index;
00113     char* FieldName;   
00114     Component* Next;   // linked list
00115     void SetName(const char* name)
00116       {
00117         delete[] this->FieldName;
00118         this->FieldName = 0;
00119         if (name)
00120           {
00121           this->FieldName = new char[strlen(name)+1];
00122           strcpy(this->FieldName, name);
00123           }
00124       }
00125     Component() { FieldName = 0; }
00126     ~Component() { delete[] FieldName; }
00127   };
00128 //ETX
00129 
00130 protected:
00131 
00132 //BTX
00133   enum FieldTypes
00134   {
00135     NAME,
00136     ATTRIBUTE
00137   };
00138 //ETX
00139 
00140   vtkSplitField();
00141   virtual ~vtkSplitField();
00142 
00143   void Execute();
00144 
00145   char* FieldName;
00146   int FieldType;
00147   int AttributeType;
00148   int FieldLocation;
00149 
00150   static char FieldLocationNames[3][12];
00151   static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
00152 
00153   vtkDataArray* SplitArray(vtkDataArray* da, int component);
00154 
00155 
00156   // Components are stored as a linked list.
00157   Component* Head;
00158   Component* Tail;
00159 
00160   // Methods to browse/modify the linked list.
00161   Component* GetNextComponent(Component* op)
00162     { return op->Next; }
00163   Component* GetFirst()
00164     { return this->Head; }
00165   void AddComponent(Component* op);
00166   Component* FindComponent(int index);
00167   void DeleteAllComponents();
00168 
00169   void PrintComponent(Component* op, ostream& os, vtkIndent indent);
00170   void PrintAllComponents(ostream& os, vtkIndent indent);
00171 private:
00172   vtkSplitField(const vtkSplitField&);  // Not implemented.
00173   void operator=(const vtkSplitField&);  // Not implemented.
00174 };
00175 
00176 #endif
00177 
00178