VTK
dox/Filters/Core/vtkMergeFields.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkMergeFields.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 =========================================================================*/
00047 #ifndef __vtkMergeFields_h
00048 #define __vtkMergeFields_h
00049 
00050 #include "vtkFiltersCoreModule.h" // For export macro
00051 #include "vtkDataSetAlgorithm.h"
00052 
00053 class vtkDataArray;
00054 class vtkFieldData;
00055 
00056 class VTKFILTERSCORE_EXPORT vtkMergeFields : public vtkDataSetAlgorithm
00057 {
00058 public:
00059   vtkTypeMacro(vtkMergeFields,vtkDataSetAlgorithm);
00060   void PrintSelf(ostream& os, vtkIndent indent);
00061 
00063   static vtkMergeFields *New();
00064 
00067   void SetOutputField(const char* name, int fieldLoc);
00068 
00072   void SetOutputField(const char* name, const char* fieldLoc);
00073 
00075   void Merge(int component, const char* arrayName, int sourceComp);
00076 
00078 
00080   vtkSetMacro(NumberOfComponents, int);
00081   vtkGetMacro(NumberOfComponents, int);
00083 
00084 //BTX
00085   enum FieldLocations
00086   {
00087     DATA_OBJECT=0,
00088     POINT_DATA=1,
00089     CELL_DATA=2
00090   };
00091 //ETX
00092 
00093 //BTX
00094   struct Component
00095   {
00096     int Index;
00097     int SourceIndex;
00098     char* FieldName;
00099     Component* Next;   // linked list
00100     void SetName(const char* name)
00101       {
00102         delete[] this->FieldName;
00103         this->FieldName = 0;
00104         if (name)
00105           {
00106           this->FieldName = new char[strlen(name)+1];
00107           strcpy(this->FieldName, name);
00108           }
00109       }
00110     Component() { FieldName = 0; }
00111     ~Component() { delete[] FieldName; }
00112   };
00113 //ETX
00114 
00115 protected:
00116 
00117 //BTX
00118   enum FieldType
00119   {
00120     NAME,
00121     ATTRIBUTE
00122   };
00123 //ETX
00124 
00125   vtkMergeFields();
00126   virtual ~vtkMergeFields();
00127 
00128   int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00129 
00130   char* FieldName;
00131   int FieldLocation;
00132   int NumberOfComponents;
00133   int OutputDataType;
00134 
00135   static char FieldLocationNames[3][12];
00136 
00137 
00138   int MergeArray(vtkDataArray* in, vtkDataArray* out, int inComp, int outComp);
00139 
00140   // Components are stored as a linked list.
00141   Component* Head;
00142   Component* Tail;
00143 
00144   // Methods to browse/modify the linked list.
00145   Component* GetNextComponent(Component* op)
00146     { return op->Next; }
00147   Component* GetFirst()
00148     { return this->Head; }
00149   void AddComponent(Component* op);
00150   Component* FindComponent(int index);
00151   void DeleteAllComponents();
00152 
00153   void PrintComponent(Component* op, ostream& os, vtkIndent indent);
00154   void PrintAllComponents(ostream& os, vtkIndent indent);
00155 private:
00156   vtkMergeFields(const vtkMergeFields&);  // Not implemented.
00157   void operator=(const vtkMergeFields&);  // Not implemented.
00158 };
00159 
00160 #endif
00161 
00162