00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00049 #ifndef __vtkDataSetAttributes_h
00050 #define __vtkDataSetAttributes_h
00051
00052 #include "vtkFieldData.h"
00053
00054 class vtkLookupTable;
00055
00056 class VTK_FILTERING_EXPORT vtkDataSetAttributes : public vtkFieldData
00057 {
00058 public:
00060 static vtkDataSetAttributes *New();
00061
00062 vtkTypeRevisionMacro(vtkDataSetAttributes,vtkFieldData);
00063 void PrintSelf(ostream& os, vtkIndent indent);
00064
00067 virtual void Initialize();
00068
00071 virtual void Update() {}
00072
00073
00074
00077 virtual void DeepCopy(vtkFieldData *pd);
00078
00081 virtual void ShallowCopy(vtkFieldData *pd);
00082
00083
00084
00085
00086 enum AttributeTypes
00087 {
00088 SCALARS=0,
00089 VECTORS=1,
00090 NORMALS=2,
00091 TCOORDS=3,
00092 TENSORS=4,
00093 GLOBALIDS=5,
00094 PEDIGREEIDS=6,
00095 NUM_ATTRIBUTES
00096 };
00097
00098 enum AttributeLimitTypes
00099 {
00100 MAX,
00101 EXACT,
00102 NOLIMIT
00103 };
00104
00105
00107
00108 int SetScalars(vtkDataArray* da);
00109 int SetActiveScalars(const char* name);
00110 vtkDataArray* GetScalars();
00112
00114
00115 int SetVectors(vtkDataArray* da);
00116 int SetActiveVectors(const char* name);
00117 vtkDataArray* GetVectors();
00119
00121
00122 int SetNormals(vtkDataArray* da);
00123 int SetActiveNormals(const char* name);
00124 vtkDataArray* GetNormals();
00126
00128
00129 int SetTCoords(vtkDataArray* da);
00130 int SetActiveTCoords(const char* name);
00131 vtkDataArray* GetTCoords();
00133
00135
00136 int SetTensors(vtkDataArray* da);
00137 int SetActiveTensors(const char* name);
00138 vtkDataArray* GetTensors();
00140
00142
00143 int SetGlobalIds(vtkDataArray* da);
00144 int SetActiveGlobalIds(const char* name);
00145 vtkDataArray* GetGlobalIds();
00147
00149
00150 int SetPedigreeIds(vtkAbstractArray* da);
00151 int SetActivePedigreeIds(const char* name);
00152 vtkAbstractArray* GetPedigreeIds();
00154
00156
00159 vtkDataArray* GetScalars(const char* name);
00160 vtkDataArray* GetVectors(const char* name);
00161 vtkDataArray* GetNormals(const char* name);
00162 vtkDataArray* GetTCoords(const char* name);
00163 vtkDataArray* GetTensors(const char* name);
00164 vtkDataArray* GetGlobalIds(const char* name);
00165 vtkAbstractArray* GetPedigreeIds(const char* name);
00167
00175 int SetActiveAttribute(const char* name, int attributeType);
00176
00178 int SetActiveAttribute(int index, int attributeType);
00179
00182 void GetAttributeIndices(int* indexArray);
00183
00188 int IsArrayAnAttribute(int idx);
00189
00194 vtkDataArray* GetAttribute(int attributeType);
00195
00201 vtkAbstractArray* GetAbstractAttribute(int attributeType);
00202
00204 virtual void RemoveArray(const char *name);
00205
00207
00209 static const char* GetAttributeTypeAsString(int attributeType);
00210 static const char* GetLongAttributeTypeAsString(int attributeType);
00212
00213
00214
00215
00216 enum AttributeCopyOperations
00217 {
00218 COPYTUPLE=0,
00219 INTERPOLATE=1,
00220 PASSDATA=2,
00221 ALLCOPY
00222 };
00223
00224
00229 void SetCopyAttribute (int index, int value, int ctype=ALLCOPY);
00230
00232
00243 void SetCopyScalars(int i, int ctype=ALLCOPY);
00244 int GetCopyScalars(int ctype=ALLCOPY);
00245 vtkBooleanMacro(CopyScalars, int);
00247
00249
00260 void SetCopyVectors(int i, int ctype=ALLCOPY);
00261 int GetCopyVectors(int ctype=ALLCOPY);
00262 vtkBooleanMacro(CopyVectors, int);
00264
00266
00277 void SetCopyNormals(int i, int ctype=ALLCOPY);
00278 int GetCopyNormals(int ctype=ALLCOPY);
00279 vtkBooleanMacro(CopyNormals, int);
00281
00283
00294 void SetCopyTCoords(int i, int ctype=ALLCOPY);
00295 int GetCopyTCoords(int ctype=ALLCOPY);
00296 vtkBooleanMacro(CopyTCoords, int);
00298
00300
00311 void SetCopyTensors(int i, int ctype=ALLCOPY);
00312 int GetCopyTensors(int ctype=ALLCOPY);
00313 vtkBooleanMacro(CopyTensors, int);
00315
00317
00328 void SetCopyGlobalIds(int i, int ctype=ALLCOPY);
00329 int GetCopyGlobalIds(int ctype=ALLCOPY);
00330 vtkBooleanMacro(CopyGlobalIds, int);
00332
00334
00345 void SetCopyPedigreeIds(int i, int ctype=ALLCOPY);
00346 int GetCopyPedigreeIds(int ctype=ALLCOPY);
00347 vtkBooleanMacro(CopyPedigreeIds, int);
00349
00361 virtual void CopyAllOn(int ctype=ALLCOPY);
00362
00374 virtual void CopyAllOff(int ctype=ALLCOPY);
00375
00376
00377
00385 virtual void PassData(vtkFieldData* fd);
00386
00387
00388
00390
00400 void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0,
00401 vtkIdType ext=1000)
00402 {
00403 this->CopyAllocate(pd, sze, ext, 0);
00404 }
00405 void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
00406 vtkIdType ext, int shallowCopyArrays);
00408
00410
00414 void CopyStructuredData(vtkDataSetAttributes *inDsa,
00415 const int *inExt, const int *outExt);
00417
00427 void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId);
00428
00429
00431
00435 void CopyTuple(vtkAbstractArray *fromData, vtkAbstractArray *toData,
00436 vtkIdType fromId, vtkIdType toId);
00438
00439
00440
00441
00443
00448 void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0,
00449 vtkIdType ext=1000)
00450 {
00451 this->InterpolateAllocate(pd, sze, ext, 0);
00452 }
00453 void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
00454 vtkIdType ext, int shallowCopyArrays);
00456
00458
00463 void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId,
00464 vtkIdList *ids, double *weights);
00466
00468
00475 void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId,
00476 vtkIdType p1, vtkIdType p2, double t);
00478
00480
00490 void InterpolateTime(vtkDataSetAttributes *from1,
00491 vtkDataSetAttributes *from2,
00492 vtkIdType id, double t);
00494
00495
00496 class FieldList;
00497
00498
00499
00501
00505 void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
00506 vtkIdType ext=1000);
00508
00510
00516 void CopyData(vtkDataSetAttributes::FieldList& list,
00517 vtkDataSetAttributes* dsa, int idx, vtkIdType fromId,
00518 vtkIdType toId);
00520
00521 friend class vtkDataSetAttributes::FieldList;
00522
00523
00524 protected:
00525 vtkDataSetAttributes();
00526 ~vtkDataSetAttributes();
00527
00528 void InternalCopyAllocate(vtkDataSetAttributes* pd,
00529 int ctype,
00530 vtkIdType sze=0,
00531 vtkIdType ext=1000,
00532 int shallowCopyArrays=0);
00533
00535 virtual void InitializeFields();
00536
00537 int AttributeIndices[NUM_ATTRIBUTES];
00538 int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES];
00539
00540
00541 vtkFieldData::BasicIterator RequiredArrays;
00542
00543
00544 int* TargetIndices;
00545
00546 virtual void RemoveArray(int index);
00547
00548 static const int NumberOfAttributeComponents[NUM_ATTRIBUTES];
00549 static const int AttributeLimits[NUM_ATTRIBUTES];
00550 static const char AttributeNames[NUM_ATTRIBUTES][12];
00551 static const char LongAttributeNames[NUM_ATTRIBUTES][35];
00552
00553 private:
00554 int SetAttribute(vtkAbstractArray* da, int attributeType);
00555 static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType);
00556
00557
00558 vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype);
00559
00560 private:
00561 vtkDataSetAttributes(const vtkDataSetAttributes&);
00562 void operator=(const vtkDataSetAttributes&);
00563
00564 public:
00565
00566
00567
00568 class VTK_FILTERING_EXPORT FieldList
00569 {
00570 public:
00571 FieldList(int numInputs);
00572 ~FieldList();
00573
00574 void InitializeFieldList(vtkDataSetAttributes* dsa);
00575 void IntersectFieldList(vtkDataSetAttributes* dsa);
00576
00577
00578 int IsAttributePresent(int attrType);
00579
00580
00581 int GetNumberOfFields() { return this->NumberOfFields; }
00582 int GetFieldIndex(int i) { return this->FieldIndices[i]; }
00583 int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; }
00584
00585 friend class vtkDataSetAttributes;
00586
00587 protected:
00588 FieldList(const FieldList&) {}
00589 void operator=(const FieldList&) {}
00590
00591 private:
00592 void SetField(int index, vtkAbstractArray *da);
00593 void RemoveField(const char *name);
00594 void ClearFields();
00595
00596
00597 char** Fields;
00598 int *FieldTypes;
00599
00600 int *FieldComponents;
00601
00602 int *FieldIndices;
00603
00604 vtkLookupTable **LUT;
00605 vtkIdType NumberOfTuples;
00606 int NumberOfFields;
00607
00608
00609
00610
00611
00612
00613 int **DSAIndices;
00614 int NumberOfDSAIndices;
00615 int CurrentInput;
00616 };
00617
00618
00619 };
00620
00621 #endif
00622
00623