Graphics/vtkMergeFields.h Source File

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages

# Graphics/vtkMergeFields.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkMergeFields.h,v $
    00005   Language:  C++
    00006
    00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
    00008   All rights reserved.
    00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00010
    00011      This software is distributed WITHOUT ANY WARRANTY; without even
    00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00013      PURPOSE.  See the above copyright notice for more information.
    00014
    00015 =========================================================================*/
    00062 #ifndef __vtkMergeFields_h
    00063 #define __vtkMergeFields_h
    00064
    00065 #include "vtkDataSetToDataSetFilter.h"
    00066
    00067 class vtkDataArray;
    00068 class vtkFieldData;
    00069
    00070 class VTK_GRAPHICS_EXPORT vtkMergeFields : public vtkDataSetToDataSetFilter
    00071 {
    00072 public:
    00073   vtkTypeRevisionMacro(vtkMergeFields,vtkDataSetToDataSetFilter);
    00074   void PrintSelf(ostream& os, vtkIndent indent);
    00075
    00077   static vtkMergeFields *New();
    00078
    00081   void SetOutputField(const char* name, int fieldLoc);
    00082
    00086   void SetOutputField(const char* name, const char* fieldLoc);
    00087
    00089   void Merge(int component, const char* arrayName, int sourceComp);
    00090
    00092
    00094   vtkSetMacro(NumberOfComponents, int);
    00096
    00097 //BTX
    00098   enum FieldLocations
    00099   {
    00100     DATA_OBJECT=0,
    00101     POINT_DATA=1,
    00102     CELL_DATA=2
    00103   };
    00104 //ETX
    00105
    00106 //BTX
    00107   struct Component
    00108   {
    00109     int Index;
    00110     int SourceIndex;
    00111     char* FieldName;
    00112     Component* Next;   // linked list
    00113     void SetName(const char* name)
    00114       {
    00115         delete[] this->FieldName;
    00116         this->FieldName = 0;
    00117         if (name)
    00118           {
    00119           this->FieldName = new char[strlen(name)+1];
    00120           strcpy(this->FieldName, name);
    00121           }
    00122       }
    00123     Component() { FieldName = 0; }
    00124     ~Component() { delete[] FieldName; }
    00125   };
    00126 //ETX
    00127
    00128 protected:
    00129
    00130 //BTX
    00131   enum FieldType
    00132   {
    00133     NAME,
    00134     ATTRIBUTE
    00135   };
    00136 //ETX
    00137
    00138   vtkMergeFields();
    00139   virtual ~vtkMergeFields();
    00140
    00141   void Execute();
    00142
    00143   char* FieldName;
    00144   int FieldLocation;
    00145   int NumberOfComponents;
    00146   int OutputDataType;
    00147
    00148   static char FieldLocationNames[3][12];
    00149
    00150
    00151   int MergeArray(vtkDataArray* in, vtkDataArray* out, int inComp, int outComp);
    00152
    00153   // Components are stored as a linked list.
    00154   Component* Head;
    00155   Component* Tail;
    00156
    00157   // Methods to browse/modify the linked list.
    00158   Component* GetNextComponent(Component* op)
    00159     { return op->Next; }
    00160   Component* GetFirst()
    00161     { return this->Head; }
    00162   void AddComponent(Component* op);
    00163   Component* FindComponent(int index);
    00164   void DeleteAllComponents();
    00165
    00166   void PrintComponent(Component* op, ostream& os, vtkIndent indent);
    00167   void PrintAllComponents(ostream& os, vtkIndent indent);
    00168 private:
    00169   vtkMergeFields(const vtkMergeFields&);  // Not implemented.
    00170   void operator=(const vtkMergeFields&);  // Not implemented.
    00171 };
    00172
    00173 #endif
    00174
    00175