Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkDataSetAttributes.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkDataSetAttributes.h,v $
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 =========================================================================*/
00042 #ifndef __vtkDataSetAttributes_h
00043 #define __vtkDataSetAttributes_h
00044 
00045 #include "vtkFieldData.h"
00046 
00047 class VTK_FILTERING_EXPORT vtkDataSetAttributes : public vtkFieldData
00048 {
00049 public:
00051   static vtkDataSetAttributes *New();
00052   
00053   vtkTypeRevisionMacro(vtkDataSetAttributes,vtkFieldData);
00054   void PrintSelf(ostream& os, vtkIndent indent);
00055 
00058   virtual void Initialize();
00059 
00062   virtual void Update() {}
00063 
00070   virtual void PassData(vtkFieldData* fd);
00071 
00073 
00080   void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0,
00081                     vtkIdType ext=1000);
00083 
00091   void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId);
00092 
00094 
00097   void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0,
00098                            vtkIdType ext=1000);
00100   
00102 
00106   void CopyStructuredData(vtkDataSetAttributes *inDsa,
00107                           const int *inExt, const int *outExt);
00109 
00111 
00113   void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId, 
00114                         vtkIdList *ids, double *weights);
00116   
00118 
00122   void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId,
00123                        vtkIdType p1, vtkIdType p2, double t);
00125 
00127 
00134   void InterpolateTime(vtkDataSetAttributes *from1, 
00135                        vtkDataSetAttributes *from2,
00136                        vtkIdType id, double t);
00138 
00141   virtual void DeepCopy(vtkFieldData *pd);
00142 
00144   virtual void ShallowCopy(vtkFieldData *pd);
00145 
00147 
00148   int SetScalars(vtkDataArray* da);
00149   int SetActiveScalars(const char* name);
00150   vtkDataArray* GetScalars();
00152 
00154 
00155   int SetVectors(vtkDataArray* da);
00156   int SetActiveVectors(const char* name);
00157   vtkDataArray* GetVectors();
00159 
00161 
00162   int SetNormals(vtkDataArray* da);
00163   int SetActiveNormals(const char* name);
00164   vtkDataArray* GetNormals();
00166 
00168 
00169   int SetTCoords(vtkDataArray* da);
00170   int SetActiveTCoords(const char* name);
00171   vtkDataArray* GetTCoords();
00173 
00175 
00176   int SetTensors(vtkDataArray* da);
00177   int SetActiveTensors(const char* name);
00178   vtkDataArray* GetTensors();
00180 
00182 
00185   vtkDataArray* GetScalars(const char* name);
00186   vtkDataArray* GetVectors(const char* name);
00187   vtkDataArray* GetNormals(const char* name);
00188   vtkDataArray* GetTCoords(const char* name);
00189   vtkDataArray* GetTensors(const char* name);
00191 
00198   int SetActiveAttribute(const char* name, int attributeType);
00199 
00201   int SetActiveAttribute(int index, int attributeType);
00202 
00204   void SetCopyAttribute (int index, int value);
00205 
00207 
00213   void SetCopyScalars(int i);
00214   int GetCopyScalars();
00215   vtkBooleanMacro(CopyScalars, int);
00217 
00219 
00225   void SetCopyVectors(int i);
00226   int GetCopyVectors();
00227   vtkBooleanMacro(CopyVectors, int);
00229 
00231 
00237   void SetCopyNormals(int i);
00238   int GetCopyNormals();
00239   vtkBooleanMacro(CopyNormals, int);
00241 
00243 
00249   void SetCopyTCoords(int i);
00250   int GetCopyTCoords();
00251   vtkBooleanMacro(CopyTCoords, int);
00253 
00255 
00261   void SetCopyTensors(int i);
00262   int GetCopyTensors();
00263   vtkBooleanMacro(CopyTensors, int);
00265 
00272   virtual void CopyAllOn();
00273 
00280   virtual void CopyAllOff();
00281 
00283 
00287   void CopyTuple(vtkDataArray *fromData, vtkDataArray *toData, 
00288                  vtkIdType fromId, vtkIdType toId);
00290 
00293   void GetAttributeIndices(int* indexArray);
00294 
00299   int IsArrayAnAttribute(int idx);
00300 
00303   vtkDataArray* GetAttribute(int attributeType);
00304 
00306   virtual void RemoveArray(const char *name);
00307 
00310   static const char* GetAttributeTypeAsString(int attributeType);
00311 
00312 //BTX
00313   // Always keep NUM_ATTRIBUTES as the last entry
00314   enum AttributeTypes 
00315   {
00316     SCALARS=0,
00317     VECTORS=1,
00318     NORMALS=2,
00319     TCOORDS=3,
00320     TENSORS=4,
00321     NUM_ATTRIBUTES
00322   };
00323 
00324   enum AttributeLimitTypes 
00325   {
00326     MAX, 
00327     EXACT, 
00328     NOLIMIT
00329   };
00330 
00331   class FieldList;
00332 
00334 
00336   void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0, 
00337                     vtkIdType ext=1000);
00339 
00341 
00345   void CopyData(vtkDataSetAttributes::FieldList& list, 
00346                 vtkDataSetAttributes* dsa, int idx, vtkIdType fromId,
00347                 vtkIdType toId);
00349 
00350   friend class vtkDataSetAttributes::FieldList;
00351 //ETX
00352 
00353 protected:
00354   vtkDataSetAttributes();
00355   ~vtkDataSetAttributes();
00356 
00357   // special methods to support managing data
00358   void InterpolateTuple(vtkDataArray *fromData, vtkDataArray *toData,
00359                         vtkIdType toId, vtkIdList *ptIds, double *weights);
00360   void InterpolateTuple(vtkDataArray *fromData, vtkDataArray *toData,
00361                         vtkIdType toId, vtkIdType id1, vtkIdType id2, 
00362                         double t);
00363   void InterpolateTuple(vtkDataArray *fromData1, vtkDataArray *fromData2, 
00364                         vtkDataArray *toData, vtkIdType id, double t);
00365 
00367   virtual void InitializeFields();
00368 
00369   int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data
00370   int CopyAttributeFlags[NUM_ATTRIBUTES]; //copy flag for attribute data
00371 
00372 //BTX
00373   vtkFieldData::BasicIterator RequiredArrays;
00374 //ETX
00375 
00376   int* TargetIndices;
00377 
00378   virtual void RemoveArray(int index);
00379 
00380   static const int NumberOfAttributeComponents[NUM_ATTRIBUTES];
00381   static const int AttributeLimits[NUM_ATTRIBUTES];
00382   static const char AttributeNames[NUM_ATTRIBUTES][10];
00383 
00384 private:
00385   int SetAttribute(vtkDataArray* da, int attributeType);
00386   static int CheckNumberOfComponents(vtkDataArray* da, int attributeType);
00387 
00388 //BTX
00389   vtkFieldData::BasicIterator  ComputeRequiredArrays(vtkDataSetAttributes* pd);
00390 
00391 private:
00392   vtkDataSetAttributes(const vtkDataSetAttributes&);  // Not implemented.
00393   void operator=(const vtkDataSetAttributes&);  // Not implemented.
00394 
00395 public:
00396   // This public class is used to perform set operations, other misc. 
00397   // operations on fields. For example, vtkAppendFilter uses it to 
00398   // determine which attributes the input datasets share in common.
00399   class VTK_FILTERING_EXPORT FieldList
00400   {
00401   public:
00402     FieldList(int numInputs);
00403     ~FieldList();
00404 
00405     void InitializeFieldList(vtkDataSetAttributes* dsa);
00406     void IntersectFieldList(vtkDataSetAttributes* dsa);
00407 
00408     //Determine whether data is available
00409     int IsAttributePresent(int attrType); //true/false attributes specified
00410     
00411     // Accessor methods.
00412     int GetNumberOfFields() { return this->NumberOfFields; }
00413     int GetFieldIndex(int i) { return this->FieldIndices[i]; }
00414     int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; }
00415     
00416     friend class vtkDataSetAttributes;
00417 
00418   protected:
00419     FieldList(const FieldList&) {} //prevent these methods from being used
00420     void operator=(const FieldList&) {}
00421 
00422   private:
00423     void SetField(int index, vtkDataArray *da);
00424     void RemoveField(const char *name);
00425     void ClearFields();
00426     
00427     //These keep track of what is common across datasets
00428     char** Fields; //the names of the fields (first five are named attributes)
00429     int *FieldTypes; //the types of the fields (first five are named 
00430                      //attributes)
00431     int *FieldComponents; //the number of components in each  fields 
00432                           // (first five are named attributes)
00433     int *FieldIndices; //output data array index 
00434                        // (first five are named attributes)
00435     vtkLookupTable **LUT; //luts associated with each array
00436     vtkIdType NumberOfTuples; //a running total of values
00437     int NumberOfFields; //the number of fields
00438     
00439     //For every vtkDataSetAttributes that are processed, keep track of the 
00440     //indices into various things. The indices are organized so that the
00441     //first NUM_ATTRIBUTES refer to attributes, the next refer to the 
00442     //non-attribute fields, for a total of NUM_ATTRIBUTES + NumberOfFields.
00443     //CurrentInput is the current input being processed.
00444     int **DSAIndices;
00445     int NumberOfDSAIndices;
00446     int CurrentInput;
00447   };
00448 
00449 //ETX
00450 };
00451 
00452 #endif
00453 
00454