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