VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Common/DataModel/vtkDataSetAttributes.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkDataSetAttributes.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 =========================================================================*/
00049 #ifndef vtkDataSetAttributes_h
00050 #define vtkDataSetAttributes_h
00051 
00052 #include "vtkCommonDataModelModule.h" // For export macro
00053 #include "vtkFieldData.h"
00054 
00055 class vtkLookupTable;
00056 
00057 class VTKCOMMONDATAMODEL_EXPORT vtkDataSetAttributes : public vtkFieldData
00058 {
00059 public:
00061   static vtkDataSetAttributes *New();
00062 
00063   vtkTypeMacro(vtkDataSetAttributes,vtkFieldData);
00064   void PrintSelf(ostream& os, vtkIndent indent);
00065 
00068   virtual void Initialize();
00069 
00072   virtual void Update() {}
00073 
00074   // -- shallow and deep copy -----------------------------------------------
00075 
00078   virtual void DeepCopy(vtkFieldData *pd);
00079 
00082   virtual void ShallowCopy(vtkFieldData *pd);
00083 
00084   // -- attribute types -----------------------------------------------------
00085 //BTX
00086   // Always keep NUM_ATTRIBUTES as the last entry
00087   enum AttributeTypes
00088   {
00089     SCALARS=0,
00090     VECTORS=1,
00091     NORMALS=2,
00092     TCOORDS=3,
00093     TENSORS=4,
00094     GLOBALIDS=5,
00095     PEDIGREEIDS=6,
00096     EDGEFLAG=7,
00097     NUM_ATTRIBUTES
00098   };
00099 
00100   enum AttributeLimitTypes
00101   {
00102     MAX,
00103     EXACT,
00104     NOLIMIT
00105   };
00106 //ETX
00107 
00109 
00110   int SetScalars(vtkDataArray* da);
00111   int SetActiveScalars(const char* name);
00112   vtkDataArray* GetScalars();
00114 
00116 
00117   int SetVectors(vtkDataArray* da);
00118   int SetActiveVectors(const char* name);
00119   vtkDataArray* GetVectors();
00121 
00123 
00124   int SetNormals(vtkDataArray* da);
00125   int SetActiveNormals(const char* name);
00126   vtkDataArray* GetNormals();
00128 
00130 
00131   int SetTCoords(vtkDataArray* da);
00132   int SetActiveTCoords(const char* name);
00133   vtkDataArray* GetTCoords();
00135 
00137 
00138   int SetTensors(vtkDataArray* da);
00139   int SetActiveTensors(const char* name);
00140   vtkDataArray* GetTensors();
00142 
00144 
00145   int SetGlobalIds(vtkDataArray* da);
00146   int SetActiveGlobalIds(const char* name);
00147   vtkDataArray* GetGlobalIds();
00149 
00151 
00152   int SetPedigreeIds(vtkAbstractArray* da);
00153   int SetActivePedigreeIds(const char* name);
00154   vtkAbstractArray* GetPedigreeIds();
00156 
00158 
00161   vtkDataArray* GetScalars(const char* name);
00162   vtkDataArray* GetVectors(const char* name);
00163   vtkDataArray* GetNormals(const char* name);
00164   vtkDataArray* GetTCoords(const char* name);
00165   vtkDataArray* GetTensors(const char* name);
00166   vtkDataArray* GetGlobalIds(const char* name);
00167   vtkAbstractArray* GetPedigreeIds(const char* name);
00169 
00177   int SetActiveAttribute(const char* name, int attributeType);
00178 
00180   int SetActiveAttribute(int index, int attributeType);
00181 
00184   void GetAttributeIndices(int* indexArray);
00185 
00190   int IsArrayAnAttribute(int idx);
00191 
00206   int SetAttribute(vtkAbstractArray* aa, int attributeType);
00207 
00212   vtkDataArray* GetAttribute(int attributeType);
00213 
00219   vtkAbstractArray* GetAbstractAttribute(int attributeType);
00220 
00222 
00223   virtual void RemoveArray(const char *name);
00224   virtual void RemoveArray(int index);
00226 
00227 
00229 
00231   static const char* GetAttributeTypeAsString(int attributeType);
00232   static const char* GetLongAttributeTypeAsString(int attributeType);
00234 
00235   // -- attribute copy properties ------------------------------------------
00236 
00237 //BTX
00238   enum AttributeCopyOperations
00239   {
00240     COPYTUPLE=0,
00241     INTERPOLATE=1,
00242     PASSDATA=2,
00243     ALLCOPY  //all of the above
00244   };
00245 //ETX
00246 
00251   void SetCopyAttribute (int index, int value, int ctype=ALLCOPY);
00252 
00254 
00265   void SetCopyScalars(int i, int ctype=ALLCOPY);
00266   int GetCopyScalars(int ctype=ALLCOPY);
00267   vtkBooleanMacro(CopyScalars, int);
00269 
00271 
00282   void SetCopyVectors(int i, int ctype=ALLCOPY);
00283   int GetCopyVectors(int ctype=ALLCOPY);
00284   vtkBooleanMacro(CopyVectors, int);
00286 
00288 
00299   void SetCopyNormals(int i, int ctype=ALLCOPY);
00300   int GetCopyNormals(int ctype=ALLCOPY);
00301   vtkBooleanMacro(CopyNormals, int);
00303 
00305 
00316   void SetCopyTCoords(int i, int ctype=ALLCOPY);
00317   int GetCopyTCoords(int ctype=ALLCOPY);
00318   vtkBooleanMacro(CopyTCoords, int);
00320 
00322 
00333   void SetCopyTensors(int i, int ctype=ALLCOPY);
00334   int GetCopyTensors(int ctype=ALLCOPY);
00335   vtkBooleanMacro(CopyTensors, int);
00337 
00339 
00350   void SetCopyGlobalIds(int i, int ctype=ALLCOPY);
00351   int GetCopyGlobalIds(int ctype=ALLCOPY);
00352   vtkBooleanMacro(CopyGlobalIds, int);
00354 
00356 
00367   void SetCopyPedigreeIds(int i, int ctype=ALLCOPY);
00368   int GetCopyPedigreeIds(int ctype=ALLCOPY);
00369   vtkBooleanMacro(CopyPedigreeIds, int);
00371 
00383   virtual void CopyAllOn(int ctype=ALLCOPY);
00384 
00396   virtual void CopyAllOff(int ctype=ALLCOPY);
00397 
00398   // -- passthrough operations ----------------------------------------------
00399 
00407   virtual void PassData(vtkFieldData* fd);
00408 
00409   // -- copytuple operations ------------------------------------------------
00410 
00412 
00420   void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0,
00421                     vtkIdType ext=1000)
00422     {
00423       this->CopyAllocate(pd, sze, ext, 0);
00424     }
00425   void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
00426                     vtkIdType ext, int shallowCopyArrays);
00428 
00430 
00432   void CopyStructuredData(vtkDataSetAttributes *inDsa,
00433                           const int *inExt, const int *outExt);
00435 
00437 
00444   void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId);
00445   void CopyData(vtkDataSetAttributes *fromPd,
00446                 vtkIdList *fromIds, vtkIdList *toIds);
00448 
00450 
00453   void CopyData(vtkDataSetAttributes *fromPd, vtkIdType dstStart, vtkIdType n,
00454                 vtkIdType srcStart);
00456 
00458 
00462   void CopyTuple(vtkAbstractArray *fromData, vtkAbstractArray *toData,
00463                  vtkIdType fromId, vtkIdType toId);
00464   void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData,
00465                   vtkIdList *fromIds, vtkIdList *toIds);
00466   void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData,
00467                   vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
00469 
00470 
00471   // -- interpolate operations ----------------------------------------------
00472 
00474 
00479   void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0,
00480                            vtkIdType ext=1000)
00481     {
00482       this->InterpolateAllocate(pd, sze, ext, 0);
00483     }
00484   void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
00485                            vtkIdType ext, int shallowCopyArrays);
00487 
00489 
00494   void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId,
00495                         vtkIdList *ids, double *weights);
00497 
00499 
00506   void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId,
00507                        vtkIdType p1, vtkIdType p2, double t);
00509 
00511 
00521   void InterpolateTime(vtkDataSetAttributes *from1,
00522                        vtkDataSetAttributes *from2,
00523                        vtkIdType id, double t);
00525 
00526 //BTX
00527   class FieldList;
00528 
00529   // field list copy operations ------------------------------------------
00530 
00532 
00534   void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
00535                     vtkIdType ext=1000);
00537 
00539 
00543   void CopyData(vtkDataSetAttributes::FieldList& list,
00544                 vtkDataSetAttributes* dsa, int idx, vtkIdType fromId,
00545                 vtkIdType toId);
00547 
00549 
00554   void InterpolateAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
00555                     vtkIdType ext=1000);
00557 
00559 
00563   void InterpolatePoint(
00564     vtkDataSetAttributes::FieldList& list,
00565     vtkDataSetAttributes *fromPd,
00566     int idx, vtkIdType toId,
00567     vtkIdList *ids, double *weights);
00569 
00570   friend class vtkDataSetAttributes::FieldList;
00571 //ETX
00572 
00573 //BTX
00574 protected:
00575   vtkDataSetAttributes();
00576   ~vtkDataSetAttributes();
00577 
00578   void InternalCopyAllocate(vtkDataSetAttributes* pd,
00579                             int ctype,
00580                             vtkIdType sze=0,
00581                             vtkIdType ext=1000,
00582                             int shallowCopyArrays=0);
00583 
00584   void InternalCopyAllocate(
00585     vtkDataSetAttributes::FieldList& list,
00586     int ctype,
00587     vtkIdType sze, vtkIdType ext);
00588 
00590   virtual void InitializeFields();
00591 
00592   int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data
00593   int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]; //copy flag for attribute data
00594 
00595   vtkFieldData::BasicIterator RequiredArrays;
00596 
00597   int* TargetIndices;
00598 
00599   static const int NumberOfAttributeComponents[NUM_ATTRIBUTES];
00600   static const int AttributeLimits[NUM_ATTRIBUTES];
00601   static const char AttributeNames[NUM_ATTRIBUTES][12];
00602   static const char LongAttributeNames[NUM_ATTRIBUTES][35];
00603 
00604 private:
00605   static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType);
00606 
00607   vtkFieldData::BasicIterator  ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype);
00608 
00609 private:
00610   vtkDataSetAttributes(const vtkDataSetAttributes&);  // Not implemented.
00611   void operator=(const vtkDataSetAttributes&);  // Not implemented.
00612 
00613 public:
00614   // This public class is used to perform set operations, other misc.
00615   // operations on fields. For example, vtkAppendFilter uses it to
00616   // determine which attributes the input datasets share in common.
00617   class vtkInternalComponentNames;
00618   class VTKCOMMONDATAMODEL_EXPORT FieldList
00619   {
00620   public:
00621     FieldList(int numInputs);
00622     ~FieldList();
00623     void PrintSelf(ostream &os, vtkIndent indent);
00624 
00625     void InitializeFieldList(vtkDataSetAttributes* dsa);
00626     void IntersectFieldList(vtkDataSetAttributes* dsa);
00627 
00632     void UnionFieldList(vtkDataSetAttributes* dsa);
00633 
00634     //Determine whether data is available
00635     int IsAttributePresent(int attrType); //true/false attributes specified
00636 
00637     // Accessor methods.
00638     int GetNumberOfFields() { return this->NumberOfFields; }
00639     int GetFieldIndex(int i) { return this->FieldIndices[i]; }
00640     const char* GetFieldName(int i) { return this->Fields[i]; }
00641     int GetFieldComponents(int i) { return this->FieldComponents[i]; }
00642     int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; }
00643 
00644     friend class vtkDataSetAttributes;
00645 
00646   protected:
00647     FieldList(const FieldList&) {} //prevent these methods from being used
00648     void operator=(const FieldList&) {}
00649 
00650     void SetFieldIndex(int i, int index)
00651       { this->FieldIndices[i] = index; }
00652   private:
00653     void SetField(int index, vtkAbstractArray *da);
00654     void RemoveField(const char *name);
00655     void ClearFields();
00656     void GrowBy(unsigned int delta);
00657 
00658     int NumberOfFields; //the number of fields (including five named attributes)
00659     // These keep track of what is common across datasets. The first
00660     // six items are always named attributes.
00661     char** Fields;                     // the names of the fields
00662     int *FieldTypes;                   // the types of the fields
00663     int *FieldComponents;              // the number of components in field
00664     int *FieldIndices;                 // output data array index
00665     vtkLookupTable **LUT;              // luts associated with each array
00666     vtkInformation **FieldInformation; // Information map associated with each array
00667 
00668     vtkInternalComponentNames **FieldComponentsNames;       // the name for each component in the field
00669 
00670     vtkIdType NumberOfTuples; // a running total of values
00671 
00672     //For every vtkDataSetAttributes that are processed, keep track of the
00673     //indices into various things. The indices are organized so that the
00674     //first NUM_ATTRIBUTES refer to attributes, the next refer to the
00675     //non-attribute fields, for a total of NUM_ATTRIBUTES + NumberOfFields.
00676     //CurrentInput is the current input being processed.
00677     int **DSAIndices;
00678     int NumberOfDSAIndices;
00679     int CurrentInput;
00680 
00681   };
00682 //ETX
00683 };
00684 
00685 #endif