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 
00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00009 All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016 
00017  * Redistributions in binary form must reproduce the above copyright notice,
00018    this list of conditions and the following disclaimer in the documentation
00019    and/or other materials provided with the distribution.
00020 
00021  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00022    of any contributors may be used to endorse or promote products derived
00023    from this software without specific prior written permission.
00024 
00025  * Modified source versions must be plainly marked as such, and must not be
00026    misrepresented as being the original software.
00027 
00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 //BTX
00110   enum FieldLocations
00111   {
00112     DATA_OBJECT=0,
00113     POINT_DATA=1,
00114     CELL_DATA=2
00115   };
00116 //ETX
00117 
00118 //BTX
00119   struct Component
00120   {
00121     int Index;
00122     int SourceIndex;
00123     char* FieldName;   
00124     Component* Next;   // linked list
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 //ETX
00139 
00140 protected:
00141 
00142 //BTX
00143   enum FieldType
00144   {
00145     NAME,
00146     ATTRIBUTE
00147   };
00148 //ETX
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   // Components are stored as a linked list.
00166   Component* Head;
00167   Component* Tail;
00168 
00169   // Methods to browse/modify the linked list.
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&);  // Not implemented.
00201   void operator=(const vtkMergeFields&);  // Not implemented.
00202 };
00203 
00204 #endif
00205 
00206 

Generated on Thu Mar 28 14:19:21 2002 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001