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

Graphics/vtkSplitField.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkSplitField.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 =========================================================================*/
00084 #ifndef __vtkSplitField_h
00085 #define __vtkSplitField_h
00086 
00087 #include "vtkDataSetToDataSetFilter.h"
00088 
00089 class vtkFieldData;
00090 
00091 class VTK_GRAPHICS_EXPORT vtkSplitField : public vtkDataSetToDataSetFilter
00092 {
00093 public:
00094   vtkTypeMacro(vtkSplitField,vtkDataSetToDataSetFilter);
00095   void PrintSelf(ostream& os, vtkIndent indent);
00096 
00098   static vtkSplitField *New();
00099 
00102   void SetInputField(int attributeType, int fieldLoc);
00103 
00106   void SetInputField(const char* name, int fieldLoc);
00107 
00110   void SetInputField(const char* name, const char* fieldLoc);
00111 
00113   void Split(int component, const char* arrayName);
00114 
00115 //BTX
00116   enum FieldLocations
00117   {
00118     DATA_OBJECT=0,
00119     POINT_DATA=1,
00120     CELL_DATA=2
00121   };
00122 //ETX
00123 
00124 //BTX
00125   struct Component
00126   {
00127     int Index;
00128     char* FieldName;   
00129     Component* Next;   // linked list
00130     void SetName(const char* name)
00131       {
00132         delete[] this->FieldName;
00133         this->FieldName = 0;
00134         if (name)
00135           {
00136           this->FieldName = new char[strlen(name)+1];
00137           strcpy(this->FieldName, name);
00138           }
00139       }
00140     Component() { FieldName = 0; }
00141     ~Component() { delete[] FieldName; }
00142   };
00143 //ETX
00144 
00145 protected:
00146 
00147 //BTX
00148   enum FieldTypes
00149   {
00150     NAME,
00151     ATTRIBUTE
00152   };
00153 //ETX
00154 
00155   vtkSplitField();
00156   virtual ~vtkSplitField();
00157 
00158   void Execute();
00159 
00160   char* FieldName;
00161   int FieldType;
00162   int AttributeType;
00163   int FieldLocation;
00164 
00165   static char FieldLocationNames[3][12];
00166   static char AttributeNames[vtkDataSetAttributes::NUM_ATTRIBUTES][10];
00167 
00168   vtkDataArray* SplitArray(vtkDataArray* da, int component);
00169 
00170 
00171   // Components are stored as a linked list.
00172   Component* Head;
00173   Component* Tail;
00174 
00175   // Methods to browse/modify the linked list.
00176   Component* GetNextComponent(Component* op)
00177     { return op->Next; }
00178   Component* GetFirst()
00179     { return this->Head; }
00180   void AddComponent(Component* op);
00181   Component* FindComponent(int index);
00182   void DeleteAllComponents();
00183 
00184   void PrintComponent(Component* op, ostream& os, vtkIndent indent)
00185     {
00186       os << indent << "Field name: " << op->FieldName << endl;
00187       os << indent << "Component index: " << op->Index << endl;
00188     }
00189 
00190   void PrintAllComponents(ostream& os, vtkIndent indent)
00191     {
00192       Component* cur = this->GetFirst();
00193       if (!cur) { return; }
00194       Component* before;
00195       do
00196         {
00197         before = cur;
00198         cur = cur->Next;
00199         os << endl;
00200         this->PrintComponent(before, os, indent);
00201         } 
00202       while (cur);
00203     }
00204 private:
00205   vtkSplitField(const vtkSplitField&);  // Not implemented.
00206   void operator=(const vtkSplitField&);  // Not implemented.
00207 };
00208 
00209 #endif
00210 
00211 

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