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

vtkMergeFields.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkMergeFields.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 =========================================================================*/
00058 #ifndef __vtkMergeFields_h
00059 #define __vtkMergeFields_h
00060 
00061 #include "vtkDataSetToDataSetFilter.h"
00062 
00063 class vtkDataArray;
00064 class vtkFieldData;
00065 
00066 class VTK_GRAPHICS_EXPORT vtkMergeFields : public vtkDataSetToDataSetFilter
00067 {
00068 public:
00069   vtkTypeRevisionMacro(vtkMergeFields,vtkDataSetToDataSetFilter);
00070   void PrintSelf(ostream& os, vtkIndent indent);
00071 
00073   static vtkMergeFields *New();
00074 
00077   void SetOutputField(const char* name, int fieldLoc);
00078 
00082   void SetOutputField(const char* name, const char* fieldLoc);
00083 
00085   void Merge(int component, const char* arrayName, int sourceComp);
00086 
00088 
00090   vtkSetMacro(NumberOfComponents, int);
00092 
00093 //BTX
00094   enum FieldLocations
00095   {
00096     DATA_OBJECT=0,
00097     POINT_DATA=1,
00098     CELL_DATA=2
00099   };
00100 //ETX
00101 
00102 //BTX
00103   struct Component
00104   {
00105     int Index;
00106     int SourceIndex;
00107     char* FieldName;   
00108     Component* Next;   // linked list
00109     void SetName(const char* name)
00110       {
00111         delete[] this->FieldName;
00112         this->FieldName = 0;
00113         if (name)
00114           {
00115           this->FieldName = new char[strlen(name)+1];
00116           strcpy(this->FieldName, name);
00117           }
00118       }
00119     Component() { FieldName = 0; }
00120     ~Component() { delete[] FieldName; }
00121   };
00122 //ETX
00123 
00124 protected:
00125 
00126 //BTX
00127   enum FieldType
00128   {
00129     NAME,
00130     ATTRIBUTE
00131   };
00132 //ETX
00133 
00134   vtkMergeFields();
00135   virtual ~vtkMergeFields();
00136 
00137   void Execute();
00138 
00139   char* FieldName;
00140   int FieldLocation;
00141   int NumberOfComponents;
00142   int OutputDataType;
00143 
00144   static char FieldLocationNames[3][12];
00145 
00146 
00147   int MergeArray(vtkDataArray* in, vtkDataArray* out, int inComp, int outComp);
00148 
00149   // Components are stored as a linked list.
00150   Component* Head;
00151   Component* Tail;
00152 
00153   // Methods to browse/modify the linked list.
00154   Component* GetNextComponent(Component* op)
00155     { return op->Next; }
00156   Component* GetFirst()
00157     { return this->Head; }
00158   void AddComponent(Component* op);
00159   Component* FindComponent(int index);
00160   void DeleteAllComponents();
00161 
00162   void PrintComponent(Component* op, ostream& os, vtkIndent indent);
00163   void PrintAllComponents(ostream& os, vtkIndent indent);
00164 private:
00165   vtkMergeFields(const vtkMergeFields&);  // Not implemented.
00166   void operator=(const vtkMergeFields&);  // Not implemented.
00167 };
00168 
00169 #endif
00170 
00171