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

Common/vtkDataSetAttributes.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkDataSetAttributes.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 =========================================================================*/
00049 #ifndef __vtkDataSetAttributes_h
00050 #define __vtkDataSetAttributes_h
00051 
00052 #include "vtkFieldData.h"
00053 
00054 class VTK_COMMON_EXPORT vtkDataSetAttributes : public vtkFieldData
00055 {
00056 public:
00058   static vtkDataSetAttributes *New();
00059   
00060   vtkTypeRevisionMacro(vtkDataSetAttributes,vtkFieldData);
00061   void PrintSelf(ostream& os, vtkIndent indent);
00062 
00065   virtual void Initialize();
00066 
00069   virtual void Update() {}
00070 
00077   virtual void PassData(vtkFieldData* fd);
00078 
00080 
00087   void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0,
00088                     vtkIdType ext=1000);
00090 
00098   void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId);
00099 
00101 
00104   void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0,
00105                            vtkIdType ext=1000);
00107   
00109 
00113   void CopyStructuredData(vtkDataSetAttributes *inDsa,
00114                           const int *inExt, const int *outExt);
00116 
00118 
00120   void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId, 
00121                         vtkIdList *ids, float *weights);
00123   
00125 
00129   void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId,
00130                        vtkIdType p1, vtkIdType p2, float t);
00132 
00134 
00141   void InterpolateTime(vtkDataSetAttributes *from1, 
00142                        vtkDataSetAttributes *from2,
00143                        vtkIdType id, float t);
00145 
00148   virtual void DeepCopy(vtkFieldData *pd);
00149 
00151   virtual void ShallowCopy(vtkFieldData *pd);
00152 
00154 
00155   int SetScalars(vtkDataArray* da);
00156   int SetActiveScalars(const char* name);
00157   vtkDataArray* GetScalars();
00159 
00161 
00162   int SetVectors(vtkDataArray* da);
00163   int SetActiveVectors(const char* name);
00164   vtkDataArray* GetVectors();
00166 
00168 
00169   int SetNormals(vtkDataArray* da);
00170   int SetActiveNormals(const char* name);
00171   vtkDataArray* GetNormals();
00173 
00175 
00176   int SetTCoords(vtkDataArray* da);
00177   int SetActiveTCoords(const char* name);
00178   vtkDataArray* GetTCoords();
00180 
00182 
00183   int SetTensors(vtkDataArray* da);
00184   int SetActiveTensors(const char* name);
00185   vtkDataArray* GetTensors();
00187 
00189 
00192   vtkDataArray* GetScalars(const char* name);
00193   vtkDataArray* GetVectors(const char* name);
00194   vtkDataArray* GetNormals(const char* name);
00195   vtkDataArray* GetTCoords(const char* name);
00196   vtkDataArray* GetTensors(const char* name);
00198 
00205   int SetActiveAttribute(const char* name, int attributeType);
00206 
00208   int SetActiveAttribute(int index, int attributeType);
00209 
00211   void SetCopyAttribute (int index, int value);
00212 
00214 
00220   void SetCopyScalars(int i);
00221   int GetCopyScalars();
00222   vtkBooleanMacro(CopyScalars, int);
00224 
00226 
00232   void SetCopyVectors(int i);
00233   int GetCopyVectors();
00234   vtkBooleanMacro(CopyVectors, int);
00236 
00238 
00244   void SetCopyNormals(int i);
00245   int GetCopyNormals();
00246   vtkBooleanMacro(CopyNormals, int);
00248 
00250 
00256   void SetCopyTCoords(int i);
00257   int GetCopyTCoords();
00258   vtkBooleanMacro(CopyTCoords, int);
00260 
00262 
00268   void SetCopyTensors(int i);
00269   int GetCopyTensors();
00270   vtkBooleanMacro(CopyTensors, int);
00272 
00279   virtual void CopyAllOn();
00280 
00287   virtual void CopyAllOff();
00288 
00290 
00294   void CopyTuple(vtkDataArray *fromData, vtkDataArray *toData, 
00295                  vtkIdType fromId, vtkIdType toId);
00297 
00300   void GetAttributeIndices(int* indexArray);
00301 
00306   int IsArrayAnAttribute(int idx);
00307 
00310   vtkDataArray* GetAttribute(int attributeType);
00311 
00313   virtual void RemoveArray(const char *name);
00314 
00317   static const char* GetAttributeTypeAsString(int attributeType);
00318 
00319 //BTX
00320   // Always keep NUM_ATTRIBUTES as the last entry
00321   enum AttributeTypes 
00322   {
00323     SCALARS=0,
00324     VECTORS=1,
00325     NORMALS=2,
00326     TCOORDS=3,
00327     TENSORS=4,
00328     NUM_ATTRIBUTES
00329   };
00330 
00331   enum AttributeLimitTypes 
00332   {
00333     MAX, 
00334     EXACT, 
00335     NOLIMIT
00336   };
00337 
00338   class FieldList;
00339 
00341 
00343   void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0, 
00344                     vtkIdType ext=1000);
00346 
00348 
00352   void CopyData(vtkDataSetAttributes::FieldList& list, 
00353                 vtkDataSetAttributes* dsa, int idx, vtkIdType fromId,
00354                 vtkIdType toId);
00356 
00357   friend class vtkDataSetAttributes::FieldList;
00358 //ETX
00359 
00360 protected:
00361   vtkDataSetAttributes();
00362   ~vtkDataSetAttributes();
00363 
00364   // special methods to support managing data
00365   void InterpolateTuple(vtkDataArray *fromData, vtkDataArray *toData,
00366                         vtkIdType toId, vtkIdList *ptIds, float *weights);
00367   void InterpolateTuple(vtkDataArray *fromData, vtkDataArray *toData,
00368                         vtkIdType toId, vtkIdType id1, vtkIdType id2, float t);
00369   void InterpolateTuple(vtkDataArray *fromData1, vtkDataArray *fromData2, 
00370                         vtkDataArray *toData, vtkIdType id, float t);
00371 
00373   virtual void InitializeFields();
00374 
00375   int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data
00376   int CopyAttributeFlags[NUM_ATTRIBUTES]; //copy flag for attribute data
00377 
00378 //BTX
00379   vtkFieldData::BasicIterator RequiredArrays;
00380 //ETX
00381 
00382   int* TargetIndices;
00383 
00384   virtual void RemoveArray(int index);
00385 
00386   static const int NumberOfAttributeComponents[NUM_ATTRIBUTES];
00387   static const int AttributeLimits[NUM_ATTRIBUTES];
00388   static const char AttributeNames[NUM_ATTRIBUTES][10];
00389 
00390 private:
00391   int SetAttribute(vtkDataArray* da, int attributeType);
00392   static int CheckNumberOfComponents(vtkDataArray* da, int attributeType);
00393 
00394 //BTX
00395   vtkFieldData::BasicIterator  ComputeRequiredArrays(vtkDataSetAttributes* pd);
00396 
00397 private:
00398   vtkDataSetAttributes(const vtkDataSetAttributes&);  // Not implemented.
00399   void operator=(const vtkDataSetAttributes&);  // Not implemented.
00400 
00401 public:
00402   // This public class is used to perform set operations, other misc. 
00403   // operations on fields. For example, vtkAppendFilter uses it to 
00404   // determine which attributes the input datasets share in common.
00405   class VTK_COMMON_EXPORT FieldList
00406   {
00407   public:
00408     FieldList(int numInputs);
00409     ~FieldList();
00410 
00411     void InitializeFieldList(vtkDataSetAttributes* dsa);
00412     void IntersectFieldList(vtkDataSetAttributes* dsa);
00413 
00414     //Determine whether data is available
00415     int IsAttributePresent(int attrType); //true/false attributes specified
00416     
00417     // Accessor methods.
00418     int GetNumberOfFields() { return this->NumberOfFields; }
00419     int GetFieldIndex(int i) { return this->FieldIndices[i]; }
00420     int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; }
00421     
00422     friend class vtkDataSetAttributes;
00423 
00424   protected:
00425     FieldList(const FieldList&) {} //prevent these methods from being used
00426     void operator=(const FieldList&) {}
00427 
00428   private:
00429     void SetField(int index, vtkDataArray *da);
00430     void RemoveField(const char *name);
00431     void ClearFields();
00432     
00433     //These keep track of what is common across datasets
00434     char** Fields; //the names of the fields (first five are named attributes)
00435     int *FieldTypes; //the types of the fields (first five are named 
00436                      //attributes)
00437     int *FieldComponents; //the number of components in each  fields 
00438                           // (first five are named attributes)
00439     int *FieldIndices; //output data array index 
00440                        // (first five are named attributes)
00441     vtkLookupTable **LUT; //luts associated with each array
00442     vtkIdType NumberOfTuples; //a running total of values
00443     int NumberOfFields; //the number of fields
00444     
00445     //For every vtkDataSetAttributes that are processed, keep track of the 
00446     //indices into various things. The indices are organized so that the
00447     //first NUM_ATTRIBUTES refer to attributes, the next refer to the 
00448     //non-attribute fields, for a total of NUM_ATTRIBUTES + NumberOfFields.
00449     //CurrentInput is the current input being processed.
00450     int **DSAIndices;
00451     int NumberOfDSAIndices;
00452     int CurrentInput;
00453   };
00454 
00455 //ETX
00456 };
00457 
00458 #endif
00459 
00460