00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00075 #ifndef __vtkMergeFields_h
00076 #define __vtkMergeFields_h
00077
00078 #include "vtkDataSetToDataSetFilter.h"
00079
00080 class vtkFieldData;
00081
00082 class VTK_GRAPHICS_EXPORT vtkMergeFields : public vtkDataSetToDataSetFilter
00083 {
00084 public:
00085 vtkTypeMacro(vtkMergeFields,vtkDataSetToDataSetFilter);
00086 void PrintSelf(ostream& os, vtkIndent indent);
00087
00089 static vtkMergeFields *New();
00090
00093 void SetOutputField(const char* name, int fieldLoc);
00094
00098 void SetOutputField(const char* name, const char* fieldLoc);
00099
00101 void Merge(int component, const char* arrayName, int sourceComp);
00102
00104
00106 vtkSetMacro(NumberOfComponents, int);
00108
00109
00110 enum FieldLocations
00111 {
00112 DATA_OBJECT=0,
00113 POINT_DATA=1,
00114 CELL_DATA=2
00115 };
00116
00117
00118
00119 struct Component
00120 {
00121 int Index;
00122 int SourceIndex;
00123 char* FieldName;
00124 Component* Next;
00125 void SetName(const char* name)
00126 {
00127 delete[] this->FieldName;
00128 this->FieldName = 0;
00129 if (name)
00130 {
00131 this->FieldName = new char[strlen(name)+1];
00132 strcpy(this->FieldName, name);
00133 }
00134 }
00135 Component() { FieldName = 0; }
00136 ~Component() { delete[] FieldName; }
00137 };
00138
00139
00140 protected:
00141
00142
00143 enum FieldType
00144 {
00145 NAME,
00146 ATTRIBUTE
00147 };
00148
00149
00150 vtkMergeFields();
00151 virtual ~vtkMergeFields();
00152
00153 void Execute();
00154
00155 char* FieldName;
00156 int FieldLocation;
00157 int NumberOfComponents;
00158 int OutputDataType;
00159
00160 static char FieldLocationNames[3][12];
00161
00162
00163 int MergeArray(vtkDataArray* in, vtkDataArray* out, int inComp, int outComp);
00164
00165
00166 Component* Head;
00167 Component* Tail;
00168
00169
00170 Component* GetNextComponent(Component* op)
00171 { return op->Next; }
00172 Component* GetFirst()
00173 { return this->Head; }
00174 void AddComponent(Component* op);
00175 Component* FindComponent(int index);
00176 void DeleteAllComponents();
00177
00178 void PrintComponent(Component* op, ostream& os, vtkIndent indent)
00179 {
00180 os << indent << "Field name: " << op->FieldName << endl;
00181 os << indent << "Component index: " << op->Index << endl;
00182 os << indent << "Source component index: " << op->SourceIndex << endl;
00183 }
00184
00185 void PrintAllComponents(ostream& os, vtkIndent indent)
00186 {
00187 Component* cur = this->GetFirst();
00188 if (!cur) { return; }
00189 Component* before;
00190 do
00191 {
00192 before = cur;
00193 cur = cur->Next;
00194 os << endl;
00195 this->PrintComponent(before, os, indent);
00196 }
00197 while (cur);
00198 }
00199 private:
00200 vtkMergeFields(const vtkMergeFields&);
00201 void operator=(const vtkMergeFields&);
00202 };
00203
00204 #endif
00205
00206