Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | 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 =========================================================================*/
00056 #ifndef __vtkSplitField_h
00057 #define __vtkSplitField_h
00058 
00059 #include "vtkDataSetAlgorithm.h"
00060 
00061 #include "vtkDataSetAttributes.h" // Needed for NUM_ATTRIBUTES
00062 
00063 class vtkFieldData;
00064 
00065 class VTK_GRAPHICS_EXPORT vtkSplitField : public vtkDataSetAlgorithm
00066 {
00067 public:
00068   vtkTypeRevisionMacro(vtkSplitField,vtkDataSetAlgorithm);
00069   void PrintSelf(ostream& os, vtkIndent indent);
00070 
00072   static vtkSplitField *New();
00073 
00076   void SetInputField(int attributeType, int fieldLoc);
00077 
00080   void SetInputField(const char* name, int fieldLoc);
00081 
00084   void SetInputField(const char* name, const char* fieldLoc);
00085 
00087   void Split(int component, const char* arrayName);
00088 
00089 //BTX
00090   enum FieldLocations
00091   {
00092     DATA_OBJECT=0,
00093     POINT_DATA=1,
00094     CELL_DATA=2
00095   };
00096 //ETX
00097 
00098 //BTX
00099   struct Component
00100   {
00101     int Index;
00102     char* FieldName;   
00103     Component* Next;   // linked list
00104     void SetName(const char* name)
00105       {
00106         delete[] this->FieldName;
00107         this->FieldName = 0;
00108         if (name)
00109           {
00110           this->FieldName = new char[strlen(name)+1];
00111           strcpy(this->FieldName, name);
00112           }
00113       }
00114     Component() { FieldName = 0; }
00115     ~Component() { delete[] FieldName; }
00116   };
00117 //ETX
00118 
00119 protected:
00120 
00121 //BTX
00122   enum FieldTypes
00123   {
00124     NAME,
00125     ATTRIBUTE
00126   };
00127 //ETX
00128 
00129   vtkSplitField();
00130   virtual ~vtkSplitField();
00131 
00132   int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00133 
00134   char* FieldName;
00135   int FieldType;
00136   int AttributeType;
00137   int FieldLocation;
00138 
00139   static char FieldLocationNames[3][12];
00140   static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
00141 
00142   vtkDataArray* SplitArray(vtkDataArray* da, int component);
00143 
00144 
00145   // Components are stored as a linked list.
00146   Component* Head;
00147   Component* Tail;
00148 
00149   // Methods to browse/modify the linked list.
00150   Component* GetNextComponent(Component* op)
00151     { return op->Next; }
00152   Component* GetFirst()
00153     { return this->Head; }
00154   void AddComponent(Component* op);
00155   Component* FindComponent(int index);
00156   void DeleteAllComponents();
00157 
00158   void PrintComponent(Component* op, ostream& os, vtkIndent indent);
00159   void PrintAllComponents(ostream& os, vtkIndent indent);
00160 private:
00161   vtkSplitField(const vtkSplitField&);  // Not implemented.
00162   void operator=(const vtkSplitField&);  // Not implemented.
00163 };
00164 
00165 #endif
00166 
00167 

Generated on Mon Jan 21 23:07:26 2008 for VTK by  doxygen 1.4.3-20050530